com.threed.jpct
Class AWTGLRenderer

java.lang.Object
  extended bycom.threed.jpct.GLBase
      extended bycom.threed.jpct.AWTGLRenderer
All Implemented Interfaces:
IRenderer
Direct Known Subclasses:
JOGLRenderer

public class AWTGLRenderer
extends com.threed.jpct.GLBase
implements IRenderer

This is the renderer to support hardware acceleration via OpenGL into a Canvas using the LWJGL. To be more precise, it renders into an AWTGLCanvas provided by LWJGL. Therefore, all rendering has to be done in the AWT event dispatch thread. jPCT itself doesn't care for this thread and works totally independant from it. To get them both together, this renderer does quite a lot of work to queue jPCT's rendering commands until the Canvas gets repainted. The consequence is, that a call to FrameBuffer.display(...) no longer renders the image when using this renderer but just signals the renderer that the queue is ready for rendering. The actual rendering of the queued commands is done, when the Canvas gets repainted.
When using this renderer, it's required to execute the render(...); draw(...);display(...)-sequence for each frame or in other words: It's not a good idea to leave out the display(...)-step for a frame, because that will cause the queue to overflow.
All available parameters in the Config-class for configuring this renderer are marked with the prefix "gl".


Field Summary
 
Fields inherited from interface com.threed.jpct.IRenderer
MODE_LEGACY, MODE_OPENGL, RENDERER_OPENGL, RENDERER_SOFTWARE
 
Method Summary
 void dispose()
          Disposes the renderer and all its resources if it's not used any longer.
 void drawPolygon(VisList visList, int ind, FrameBuffer buf, World world)
          Draws a polygon.
 void drawStrip(VisList visList, int ind, int length, FrameBuffer buffer, World world)
          Draws a triangle strip.
 void drawVertexArray(VisList visList, int start, int end, FrameBuffer buffer, World world)
          Draws a vertex array.
 void drawWireframe(VisList visList, int ind, int color, FrameBuffer buffer, World world)
          Draws a polygon's wireframe.
 void execute(int mode, java.lang.Object[] params)
          Executes the renderer specific function.
 VideoMode[] getAvailableVideoModes()
          Get all available video modes.
 java.lang.Object getLock()
           
 void init(int x, int y, int cbpp, int zbpp, int samples)
          Initialize the renderer.
 boolean isInitialized()
          Returns true, if the Renderer has been initialized and false otherwise.
 boolean isPrewarmTextures()
           
 void removeBuffer(int bufferID)
           
 void setPaintListener(IPaintListener listener)
          Sets a listener that will be called before the actual painting starts and after it has finished.
 void setPrewarmTextures(boolean prewarmTextures)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.threed.jpct.IRenderer
getAvailableVideoModes, isInitialized, setPaintListener
 

Method Detail

getLock

public java.lang.Object getLock()

init

public void init(int x,
                 int y,
                 int cbpp,
                 int zbpp,
                 int samples)
Description copied from interface: IRenderer
Initialize the renderer. This method is called by the FrameBuffer class and there should be no need to call it directly.

Specified by:
init in interface IRenderer
Parameters:
x - the width of the videomode/framebuffer
y - the height of the videomode/framebuffer
cbpp - the minimal colordepth
zbpp - the minimal depthbuffer-depth
samples - the number of samples to take when using multi sampling AA

dispose

public void dispose()
Description copied from interface: IRenderer
Disposes the renderer and all its resources if it's not used any longer. Will be called automatically if needed...there's no need to call it directly from inside an application.

Specified by:
dispose in interface IRenderer

execute

public void execute(int mode,
                    java.lang.Object[] params)
Description copied from interface: IRenderer
Executes the renderer specific function. As usual, there is no need to call this directly so the functions are not documented here.

Specified by:
execute in interface IRenderer
Parameters:
mode - the mode
params - the parameters for this mode

drawStrip

public void drawStrip(VisList visList,
                      int ind,
                      int length,
                      FrameBuffer buffer,
                      World world)
Description copied from interface: IRenderer
Draws a triangle strip. No need to call this method directly.

Specified by:
drawStrip in interface IRenderer
Parameters:
visList - the VisibilityList
ind - the index of the strip
length - the length of the strip
buffer - the current FrameBuffer
world - the current instance of World

drawPolygon

public void drawPolygon(VisList visList,
                        int ind,
                        FrameBuffer buf,
                        World world)
Description copied from interface: IRenderer
Draws a polygon. No need to call this method directly.

Specified by:
drawPolygon in interface IRenderer
Parameters:
visList - the VisibilityList
ind - the index of the polygon
buf - the current FrameBuffer
world - the current instance of World

drawVertexArray

public void drawVertexArray(VisList visList,
                            int start,
                            int end,
                            FrameBuffer buffer,
                            World world)
Description copied from interface: IRenderer
Draws a vertex array. No need to call this method directly.

Specified by:
drawVertexArray in interface IRenderer
Parameters:
visList - the VisibilityList
start - the index of the first polygon
end - the index of the last polygon
buffer - the current FrameBuffer
world - the current instance of World

drawWireframe

public void drawWireframe(VisList visList,
                          int ind,
                          int color,
                          FrameBuffer buffer,
                          World world)
Description copied from interface: IRenderer
Draws a polygon's wireframe. No need to call this method directly.

Specified by:
drawWireframe in interface IRenderer
Parameters:
visList - the VisibilityList
ind - the index of the polygon
color - the wireframe's color
buffer - the current FrameBuffer

isPrewarmTextures

public boolean isPrewarmTextures()

setPrewarmTextures

public void setPrewarmTextures(boolean prewarmTextures)

removeBuffer

public void removeBuffer(int bufferID)

setPaintListener

public final void setPaintListener(IPaintListener listener)

isInitialized

public final boolean isInitialized()

getAvailableVideoModes

public VideoMode[] getAvailableVideoModes()