aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax/media/opengl/awt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-07-02 19:42:52 +0200
committerSven Gothel <[email protected]>2012-07-02 19:42:52 +0200
commiteed8508ae1132e5f45f788e9cb3f3d5a1050ac70 (patch)
treee1eec83da8dee44392407b59672134109fc63b6f /src/jogl/classes/javax/media/opengl/awt
parent08e3f9bff494a5366781328734e83ae0202696fa (diff)
GLAutoDrawable: Refine API doc; Use new abstract impl. GLAutoDrawableBase (GLWindow, ..); Add new GLAutoDrawableDelegate.
- Refine API doc - 'void setContext(GLContext)' -> 'GLContext setContext(GLContext)' - Add note to createContext(GLContext) override -Use new abstract impl. GLAutoDrawableBase, used by: - GLWindow - GLAutoDrawableDelegate - GLPbufferImpl - Add new GLAutoDrawableDelegate incl. unit test
Diffstat (limited to 'src/jogl/classes/javax/media/opengl/awt')
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java27
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java24
2 files changed, 33 insertions, 18 deletions
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 71026a247..8c6e594b5 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -392,10 +392,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public GLContext createContext(GLContext shareWith) {
- return (null != drawable) ? drawable.createContext(shareWith) : null;
+ public GLContext createContext(final GLContext shareWith) {
+ if(drawable != null) {
+ final GLContext _ctx = drawable.createContext(shareWith);
+ _ctx.setContextCreationFlags(additionalCtxCreationFlags);
+ return _ctx;
+ }
+ return null;
}
-
+
@Override
public void setRealized(boolean realized) {
}
@@ -694,11 +699,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void setContext(GLContext ctx) {
- context=(GLContextImpl)ctx;
- if(null != context) {
- context.setContextCreationFlags(additionalCtxCreationFlags);
- }
+ public GLContext setContext(GLContext newCtx) {
+ final GLContext oldCtx = context;
+ final boolean newCtxCurrent = drawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags);
+ context=(GLContextImpl)newCtx;
+ if(newCtxCurrent) {
+ context.makeCurrent();
+ }
+ return oldCtx;
}
@Override
@@ -744,6 +752,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
@Override
public void setContextCreationFlags(int flags) {
additionalCtxCreationFlags = flags;
+ if(null != context) {
+ context.setContextCreationFlags(additionalCtxCreationFlags);
+ }
}
@Override
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 152326006..c6c7cf9a1 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -456,16 +456,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
@Override
- public void setContext(GLContext ctx) {
- if (backend == null) {
- return;
- }
- if(null != ctx) {
- ctx.setContextCreationFlags(additionalCtxCreationFlags);
- }
- backend.setContext(ctx);
+ public GLContext setContext(GLContext newCtx) {
+ if (backend == null) {
+ return null;
+ }
+ final GLContext oldCtx = backend.getContext();
+ final boolean newCtxCurrent = drawableHelper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags);
+ backend.setContext(newCtx);
+ if(newCtxCurrent) {
+ newCtx.makeCurrent();
+ }
+ return oldCtx;
}
+
@Override
public GLContext getContext() {
if (backend == null) {
@@ -1160,7 +1164,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public void setContext(GLContext ctx) {
- if (pbuffer == null && Beans.isDesignTime()) {
+ if (pbuffer == null || Beans.isDesignTime()) {
return;
}
pbuffer.setContext(ctx);
@@ -1169,7 +1173,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public GLContext getContext() {
// Workaround for crashes in NetBeans GUI builder
- if (pbuffer == null && Beans.isDesignTime()) {
+ if (null == pbuffer || Beans.isDesignTime()) {
return null;
}
return pbuffer.getContext();