From a2a815a5eb2092c49b1c2e911146ad02ad225205 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sun, 12 Feb 2006 21:02:36 +0000 Subject: Added checking of whether the correct GLContext is current to the DebugGL pipeline. Fixed dependencies in JOGL and JOAL build.xml files so that generated code gets automatically rebuilt if GlueGen is updated. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@15 a78bb65f-1512-4460-ba86-f6dc96a7bf27 --- .../sun/gluegen/opengl/BuildComposablePipeline.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/java') diff --git a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java index 5235631be..542cd5224 100644 --- a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java +++ b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java @@ -307,6 +307,11 @@ public class BuildComposablePipeline output.println(" }"); output.print( " this." + getDownstreamObjectName()); output.println(" = " + getDownstreamObjectName() + ";"); + output.println(" // Fetch GLContext object for better error checking (if possible)"); + output.println(" // FIXME: should probably put this method in GL rather than GLImpl"); + output.println(" if (" + getDownstreamObjectName() + " instanceof com.sun.opengl.impl.GLImpl) {"); + output.println(" _context = ((com.sun.opengl.impl.GLImpl) " + getDownstreamObjectName() + ").getContext();"); + output.println(" }"); output.println(" }"); output.println(); } @@ -398,8 +403,18 @@ public class BuildComposablePipeline output.println(" /** True if the pipeline is inside a glBegin/glEnd pair.*/"); output.println(" private boolean insideBeginEndPair = false;"); output.println(); - + output.println(" private void checkContext() {"); + output.println(" GLContext currentContext = GLContext.getCurrent();"); + output.println(" if (currentContext == null) {"); + output.println(" throw new GLException(\"No OpenGL context is current on this thread\");"); + output.println(" }"); + output.println(" if ((_context != null) && (_context != currentContext)) {"); + output.println(" throw new GLException(\"This GL object is being incorrectly used with a different GLContext than that which created it\");"); + output.println(" }"); + output.println(" }"); + output.println(" private GLContext _context;"); } + protected void emitClassDocComment(PrintWriter output) { output.println("/**

Composable pipline which wraps an underlying {@link GL} implementation,"); @@ -415,6 +430,7 @@ public class BuildComposablePipeline protected void preDownstreamCallHook(PrintWriter output, Method m) { + output.println(" checkContext();"); } protected void postDownstreamCallHook(PrintWriter output, Method m) -- cgit v1.2.3