org.newdawn.slick.opengl
Class SlickCallable

java.lang.Object
  extended by org.newdawn.slick.opengl.SlickCallable

public abstract class SlickCallable
extends java.lang.Object

A utility to allow performing GL operations without contaminating the Slick OpenGL state. Note this will not protect you from OpenGL programming errors like a glBegin() without a glEnd(), or glPush() without glPop() etc. Expected usage: SlickCallable callable = new SlickCallable() { public performGLOperations() throws SlickException { GL.glTranslate(0,0,1); glBegin(GL.GL_POLYGONS); glVertex(..); ... glEnd(); } } callable.call(); Alternatively you can use the static methods directly SlickCallable.enterSafeBlock(); GL.glTranslate(0,0,1); glBegin(GL.GL_POLYGONS); glVertex(..); ... glEnd(); SlickCallable.leaveSafeBlock();

Author:
kevin

Constructor Summary
SlickCallable()
           
 
Method Summary
 void call()
          Cause this callable to perform it's GL operations (@see performGLOperations()).
static void enterSafeBlock()
          Enter a safe block ensuring that all the OpenGL state that slick uses is safe before touching the GL state directly.
static void leaveSafeBlock()
          Leave a safe block ensuring that all of Slick's OpenGL state is restored since the last enter.
protected abstract  void performGLOperations()
          Perform the GL operations that this callable is intended to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlickCallable

public SlickCallable()
Method Detail

enterSafeBlock

public static void enterSafeBlock()
Enter a safe block ensuring that all the OpenGL state that slick uses is safe before touching the GL state directly.


leaveSafeBlock

public static void leaveSafeBlock()
Leave a safe block ensuring that all of Slick's OpenGL state is restored since the last enter.


call

public final void call()
                throws SlickException
Cause this callable to perform it's GL operations (@see performGLOperations()). This method will block until the GL operations have been performed.

Throws:
SlickException - Indicates a failure while performing the GL operations or maintaing SlickState

performGLOperations

protected abstract void performGLOperations()
                                     throws SlickException
Perform the GL operations that this callable is intended to. This operations should not effect the slick OpenGL state.

Throws:
SlickException - Indicates a failure of some sort. This is user exception


Copyright © 2006 New Dawn Software. All Rights Reserved.