hmi.graphics.jogl
Class JOGLRenderer

java.lang.Object
  extended by hmi.graphics.jogl.JOGLRenderer
All Implemented Interfaces:
ClockListener, EventListener, javax.media.opengl.GLEventListener

public class JOGLRenderer
extends Object
implements javax.media.opengl.GLEventListener, ClockListener

A basic renderer with basic support for animation.

Author:
Job Zwiers

Field Summary
private  double aspect
           
private  double bottom
           
private  ClockListener clockListener
           
static double DEFAULT_FAR
           
static double DEFAULT_FOVY
           
static double DEFAULT_NEAR
           
private  double far
           
private  double fovy
           
private static double FULLCIRCLE_DEGREES
           
private  JOGLContext glc
           
private  javax.media.opengl.GLAutoDrawable glDrawable
           
private  int height
           
private  boolean joglInitialized
           
private  double left
           
private  double mediaTime
           
private  double near
           
private  double right
           
private  GLRenderObject scene
           
private  double top
           
private  boolean useVsync
           
private  int width
           
 
Constructor Summary
JOGLRenderer(javax.media.opengl.GLAutoDrawable glDrawable)
          Create a new renderer, using an existing GLDrawable (i.e. a GLCanvas or GLJPanel) that should have its capabilities set, like wheter antialiasing should be used, how many stencilbits etcetera.
JOGLRenderer(int numFSAA_Samples)
          Create a new renderer, like JOGLRenderer(numFSAA_Samples, 0), i.e. with FSAA specified but no stencil buffer
JOGLRenderer(int numFSAASamples, int numStencilBits)
          Create a new renderer, using a new GLCanvas with capabilities set to default values, except for the antialiasing setting.
 
Method Summary
 void addKeyListener(KeyListener listener)
          Adds a KeyListener to the internal GLCanvas or GLJPanel
private  void calculateFrustumFromFOVY()
           
 void display(javax.media.opengl.GLAutoDrawable glDrawable)
          Jogl callback for rendering the screen.
 void displayChanged(javax.media.opengl.GLAutoDrawable glDrawable, boolean modeChanged, boolean deviceChanged)
           
 Component getAWTComponent()
          return the internal GLCanvas or GLJPanel, in the form of an AWT Component, that could be added to an AWT or Swing Component.
 void init(javax.media.opengl.GLAutoDrawable glDrawable)
          GLEventListener callback, called by a Jogl GLCanvas upon OpenGL context creation.
 void initTime(double t)
          The time method required by the ClockListener interface; It sets the current media time, and then causes a Jogl display() call.
 void reshape(javax.media.opengl.GLAutoDrawable glDrawable, int x, int y, int w, int h)
          Called when the glDrawable has been resized.
 void reshape(javax.media.opengl.GL gl, int x, int y, int w, int h)
           
 void setClockListener(ClockListener listener)
          Sets theClockListener
 void setFar(double far)
          Sets the (positive) distance to the far clipping plane.
 void setFOVY(double fovy)
          Sets the field of view in the Y direction, specified in degrees(!)
 void setNear(double near)
          Sets the (positive) distance to the near clipping plane.
 void setScene(GLRenderObject scene)
          Sets the 3D scene object, to be rendered.
 void setVsync(boolean useVsync)
          Sets the vsync mode
 void time(double t)
          The time method required by the ClockListener interface; It sets the current media time, and then causes a Jogl display() call.
 void useDebugGL()
          Turn on the Jogl DebugGL mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

glDrawable

private javax.media.opengl.GLAutoDrawable glDrawable

scene

private GLRenderObject scene

glc

private JOGLContext glc

clockListener

private ClockListener clockListener

mediaTime

private volatile double mediaTime

joglInitialized

private volatile boolean joglInitialized

useVsync

private boolean useVsync

DEFAULT_FOVY

public static final double DEFAULT_FOVY
See Also:
Constant Field Values

DEFAULT_NEAR

public static final double DEFAULT_NEAR
See Also:
Constant Field Values

DEFAULT_FAR

public static final double DEFAULT_FAR
See Also:
Constant Field Values

fovy

private double fovy

aspect

private double aspect

width

private int width

height

private int height

left

private double left

right

private double right

bottom

private double bottom

top

private double top

near

private double near

far

private double far

FULLCIRCLE_DEGREES

private static final double FULLCIRCLE_DEGREES
See Also:
Constant Field Values
Constructor Detail

JOGLRenderer

public JOGLRenderer(javax.media.opengl.GLAutoDrawable glDrawable)
Create a new renderer, using an existing GLDrawable (i.e. a GLCanvas or GLJPanel) that should have its capabilities set, like wheter antialiasing should be used, how many stencilbits etcetera.


JOGLRenderer

public JOGLRenderer(int numFSAASamples,
                    int numStencilBits)
Create a new renderer, using a new GLCanvas with capabilities set to default values, except for the antialiasing setting. The numFSAA_Samples parameter determines the (FSAA) antialiasting seting: 0 or 1 means no antialiasing, values like 2, 4, or 8 will use FSAA with the number of samples as specified. The number of stencilbits is specified as well. A 0 value here means that no stencil buffer is used


JOGLRenderer

public JOGLRenderer(int numFSAA_Samples)
Create a new renderer, like JOGLRenderer(numFSAA_Samples, 0), i.e. with FSAA specified but no stencil buffer

Method Detail

useDebugGL

public void useDebugGL()
Turn on the Jogl DebugGL mode.


addKeyListener

public void addKeyListener(KeyListener listener)
Adds a KeyListener to the internal GLCanvas or GLJPanel


getAWTComponent

public Component getAWTComponent()
return the internal GLCanvas or GLJPanel, in the form of an AWT Component, that could be added to an AWT or Swing Component.


setScene

public void setScene(GLRenderObject scene)
Sets the 3D scene object, to be rendered.


setClockListener

public void setClockListener(ClockListener listener)
Sets theClockListener


initTime

public void initTime(double t)
The time method required by the ClockListener interface; It sets the current media time, and then causes a Jogl display() call.

Specified by:
initTime in interface ClockListener

time

public void time(double t)
The time method required by the ClockListener interface; It sets the current media time, and then causes a Jogl display() call.

Specified by:
time in interface ClockListener

setVsync

public void setVsync(boolean useVsync)
Sets the vsync mode


init

public void init(javax.media.opengl.GLAutoDrawable glDrawable)
GLEventListener callback, called by a Jogl GLCanvas upon OpenGL context creation. It initializes the render engine.

Specified by:
init in interface javax.media.opengl.GLEventListener

display

public void display(javax.media.opengl.GLAutoDrawable glDrawable)
Jogl callback for rendering the screen. The current media time is forwarded to the scene, by calling its time() method, thereafter, the scne is rendered, by means of calling its glRender() method.

Specified by:
display in interface javax.media.opengl.GLEventListener

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable glDrawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

setFOVY

public void setFOVY(double fovy)
Sets the field of view in the Y direction, specified in degrees(!)


setNear

public void setNear(double near)
Sets the (positive) distance to the near clipping plane.


setFar

public void setFar(double far)
Sets the (positive) distance to the far clipping plane.


calculateFrustumFromFOVY

private void calculateFrustumFromFOVY()

reshape

public void reshape(javax.media.opengl.GLAutoDrawable glDrawable,
                    int x,
                    int y,
                    int w,
                    int h)
Called when the glDrawable has been resized.

Specified by:
reshape in interface javax.media.opengl.GLEventListener

reshape

public void reshape(javax.media.opengl.GL gl,
                    int x,
                    int y,
                    int w,
                    int h)