summaryrefslogtreecommitdiffstats
path: root/src/net/java/games
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/games')
-rw-r--r--src/net/java/games/jogl/impl/GLContext.java1
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContext.java43
2 files changed, 33 insertions, 11 deletions
diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java
index 0e20a5691..a70b195ac 100644
--- a/src/net/java/games/jogl/impl/GLContext.java
+++ b/src/net/java/games/jogl/impl/GLContext.java
@@ -46,6 +46,7 @@ import net.java.games.gluegen.runtime.*;
public abstract class GLContext {
protected static final boolean DEBUG = Debug.debug("GLContext");
protected static final boolean VERBOSE = Debug.verbose();
+ protected static final boolean NO_FREE = Debug.isPropertyDefined("jogl.GLContext.nofree");
static {
NativeLibLoader.load();
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
index d808634f2..f597d56b7 100644
--- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
+++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java
@@ -140,12 +140,24 @@ public abstract class WindowsGLContext extends GLContext {
created = true;
}
- if (!WGL.wglMakeCurrent(hdc, hglrc)) {
- throw new GLException("Error making context current: " + WGL.GetLastError());
- } else {
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + hdcToString(hdc) +
- ", hglrc " + hdcToString(hglrc) + ") succeeded");
+ boolean skipMakeCurrent = false;
+ if (NO_FREE) {
+ if (WGL.wglGetCurrentContext() == hglrc) {
+ if (DEBUG && VERBOSE) {
+ System.err.println(getThreadName() + ": skipping wglMakeCurrent because context already current");
+ }
+ skipMakeCurrent = true;
+ }
+ }
+
+ if (!skipMakeCurrent) {
+ if (!WGL.wglMakeCurrent(hdc, hglrc)) {
+ throw new GLException("Error making context current: " + WGL.GetLastError());
+ } else {
+ if (DEBUG && VERBOSE) {
+ System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + hdcToString(hdc) +
+ ", hglrc " + hdcToString(hglrc) + ") succeeded");
+ }
}
}
@@ -174,8 +186,10 @@ public abstract class WindowsGLContext extends GLContext {
}
protected synchronized void free() throws GLException {
- if (!WGL.wglMakeCurrent(0, 0)) {
- throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError());
+ if (!NO_FREE) {
+ if (!WGL.wglMakeCurrent(0, 0)) {
+ throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError());
+ }
}
}
@@ -550,9 +564,6 @@ public abstract class WindowsGLContext extends GLContext {
WGL.PFD_GENERIC_ACCELERATED);
if (caps.getDoubleBuffered()) {
pfdFlags |= WGL.PFD_DOUBLEBUFFER;
- if (onscreen) {
- pfdFlags |= WGL.PFD_SWAP_EXCHANGE;
- }
}
if (onscreen) {
pfdFlags |= WGL.PFD_DRAW_TO_WINDOW;
@@ -565,7 +576,17 @@ public abstract class WindowsGLContext extends GLContext {
pfd.cRedBits ((byte) caps.getRedBits());
pfd.cGreenBits((byte) caps.getGreenBits());
pfd.cBlueBits ((byte) caps.getBlueBits());
+ pfd.cAlphaBits((byte) caps.getAlphaBits());
+ int accumDepth = (caps.getAccumRedBits() +
+ caps.getAccumGreenBits() +
+ caps.getAccumBlueBits());
+ pfd.cAccumBits ((byte) accumDepth);
+ pfd.cAccumRedBits ((byte) caps.getAccumRedBits());
+ pfd.cAccumGreenBits((byte) caps.getAccumGreenBits());
+ pfd.cAccumBlueBits ((byte) caps.getAccumBlueBits());
+ pfd.cAccumAlphaBits((byte) caps.getAccumAlphaBits());
pfd.cDepthBits((byte) caps.getDepthBits());
+ pfd.cStencilBits((byte) caps.getStencilBits());
pfd.iLayerType((byte) WGL.PFD_MAIN_PLANE);
return pfd;
}