Permalink
Browse files

Examples now uses DebuggingFearLwjgl

  • Loading branch information...
1 parent 56d6a05 commit 9745f1cf3502b370d7c2dc86e0ab09d64531e070 @magnus-gustafsson magnus-gustafsson committed Mar 29, 2012
@@ -10,41 +10,29 @@
public class DebuggingFearLwjgl implements InvocationHandler {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final FearGl fearGl;
- private int lastError;
- private final boolean throwException;
- private DebuggingFearLwjgl(boolean throwException) {
- this.throwException = throwException;
+ private DebuggingFearLwjgl() {
fearGl = new FearLwjgl();
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (method.getName().equals("glGetError")) {
- int error = lastError;
- lastError = 0;
- return error;
- }
Object returnValue = method.invoke(fearGl, args);
int error = fearGl.glGetError();
if (error != 0) {
String message = "OpenGL error " + error;
- RuntimeException runtimeException = new RuntimeException(message);
- logger.error(message, runtimeException);
- if (throwException) {
- throw runtimeException;
- }
+ throw new RuntimeException(message);
+
}
- lastError = error;
return returnValue;
}
- public static FearGl create(boolean throwException) {
- return (FearGl) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class<?>[]{FearGl.class}, new DebuggingFearLwjgl(throwException));
+ public static FearGl create() {
+ return (FearGl) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class<?>[]{FearGl.class}, new DebuggingFearLwjgl());
}
}
@@ -42,7 +42,7 @@
private ShaderProgram shaderProgram;
public ColladaExample() throws IOException {
- fearGl = new FearLwjgl();
+ fearGl = DebuggingFearLwjgl.create();
textureManager = new FearlessTextureLoader(fearGl);
init();
log.info(org.lwjgl.opengl.GL11.glGetString(org.lwjgl.opengl.GL11.GL_VERSION));
@@ -39,7 +39,7 @@
private ShaderProgram shaderProgram;
public DirectionalLightExample() throws IOException {
- fearGl = new FearLwjgl();
+ fearGl = DebuggingFearLwjgl.create();
textureManager = new FearlessTextureLoader(fearGl);
init();
@@ -41,7 +41,7 @@
private ShaderProgram shaderProgram;
public Main() throws IOException {
- fearGl = new FearLwjgl();
+ fearGl = DebuggingFearLwjgl.create();
textureManager = new FearlessTextureLoader(fearGl);
init();
@@ -44,7 +44,7 @@
private ShaderProgram shaderProgram;
public Main2() {
- fearGl = new FearLwjgl();
+ fearGl = DebuggingFearLwjgl.create();
init();
shaderProgram = createShaderProgram();
@@ -45,7 +45,7 @@
private final ExampleRenderer renderer;
public ManyOrbs() {
- fearGl = new FearLwjgl();
+ fearGl = DebuggingFearLwjgl.create();
init();
int numOrbs = 20;
@@ -57,7 +57,7 @@ public static void main(String[] args) throws LWJGLException {
DisplayUtil.create(w, h, "Shader Setup");
- FearGl fearGl = new FearLwjgl();
+ FearGl fearGl = DebuggingFearLwjgl.create();
fearGl.glViewport(0, 0, w, h);
PerspectiveBuilder perspectiveBuilder = new PerspectiveBuilder(45.0f, ((float) w / (float) h), 0.1f, 200.0f);

0 comments on commit 9745f1c

Please sign in to comment.