diff options
author | Sven Gothel <[email protected]> | 2009-10-05 15:26:28 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-05 15:26:28 -0700 |
commit | 62fb860ffc454fc00ed73f9b6da54bba34a6d64f (patch) | |
tree | cd753aa602beeb429902f1c2b8096e13861fdbb6 /src/jogl/classes/com/sun/opengl/impl/windows | |
parent | 906e3698f1493daab5cf196b893e65b11b2f0d12 (diff) |
Fix On-/Offscreen and PBuffer.
Demos are working again:
demos.jrefract.JRefract
- X11, Win32, OSX
-Dsun.java2d.opengl=true demos.jrefract.JRefract
- X11, Win32
demos.readbuffer.Main [-GL2,-GL2ES1] -test 0 demos.es1.RedSquare
- X11, Win32, OSX, EGL
demos.readbuffer.Main [-GL2,-GL2ES1] -test [12] demos.es1.RedSquare
- X11, Win32
- OSX not, because of the missing feature of
attaching a read surface.
- EGL not, because the emulation I used didn't support
attaching a read surface. Emulation bug .. probably ..
MacOSXWindowSystemInterface.m createContext():
- Verify if passed surface handle _is_ a view,
now it could be a pbuffer etc .. handle as well.
Cleanup GLDrawableImpl.setRealized(boolean realized)
- Calls setRealizedImpl() (implementation) now,
and only if new stated differs ..
- setRealizedImpl() fixed for:
MacOSXPbufferCGLDrawable: recreate/destroy
WindowsOffscreenWGLDrawable: recreate/destroy
WindowsPbufferWGLDrawable: no-recreate/destroy
X11OffscreenGLXDrawable: recreate/destroy
X11PbufferGLXDrawable: recreate/destroy
WindowsWGLContext:
- wglMakeContextCurrent(): uses isFunctionAvailable ..
- create():
Uses WGL.MakeCurrent() and releases the created context,
due to unavailable MakeContextCurrent extensions
before updating the procaddress tables.
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/impl/windows')
5 files changed, 30 insertions, 20 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java index 35fbcc6f5..f254748d1 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java @@ -53,6 +53,14 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable { create(); } + protected void setRealizedImpl() { + if(realized) { + create(); + } else { + destroy(); + } + } + public GLContext createContext(GLContext shareWith) { return new WindowsOffscreenWGLContext(this, shareWith); } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java index 798eafad3..2bc6660fb 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -67,6 +67,14 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } } + protected void setRealizedImpl() { + if(realized) { + throw new GLException("Recreation via setRealized not supported."); + } else { + destroy(); + } + } + public GLContext createContext(GLContext shareWith) { return new WindowsPbufferWGLContext(this, shareWith); } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java index b07cd6046..418336e3f 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -95,9 +95,12 @@ public class WindowsWGLContext extends GLContextImpl { public boolean wglMakeContextCurrent(long hDrawDC, long hReadDC, long hglrc) { WGLExt wglExt = getWGLExt(); if (!wglMakeContextCurrentInitialized) { - wglMakeContextCurrentARBAvailable = (WGL.wglGetProcAddress("wglMakeContextCurrentARB") != 0); - wglMakeContextCurrentEXTAvailable = (WGL.wglGetProcAddress("wglMakeContextCurrentEXT") != 0); + wglMakeContextCurrentARBAvailable = isFunctionAvailable("wglMakeContextCurrentARB"); + wglMakeContextCurrentEXTAvailable = isFunctionAvailable("wglMakeContextCurrentEXT"); wglMakeContextCurrentInitialized = true; + if(DEBUG) { + System.err.println("WindowsWGLContext.wglMakeContextCurrent: ARB "+wglMakeContextCurrentARBAvailable+", EXT "+wglMakeContextCurrentEXTAvailable); + } } if(wglMakeContextCurrentARBAvailable) { return wglExt.wglMakeContextCurrentARB(hDrawDC, hReadDC, hglrc); @@ -163,7 +166,7 @@ public class WindowsWGLContext extends GLContextImpl { if (temp_hglrc == 0) { throw new GLException("Unable to create temp OpenGL context for device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle())); } else { - if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), temp_hglrc)) { + if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_hglrc)) { throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError())); } setGLFunctionAvailability(true); @@ -171,7 +174,7 @@ public class WindowsWGLContext extends GLContextImpl { if( !isFunctionAvailable("wglCreateContextAttribsARB") || !isExtensionAvailable("WGL_ARB_create_context") ) { if(glCaps.getGLProfile().isGL3()) { - wglMakeContextCurrent(0, 0, 0); + WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_hglrc); throw new GLException("Unable to create OpenGL >= 3.1 context (no WGL_ARB_create_context)"); } @@ -230,25 +233,26 @@ public class WindowsWGLContext extends GLContextImpl { if(0==hglrc) { if(glCaps.getGLProfile().isGL3()) { - wglMakeContextCurrent(0, 0, 0); + WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_hglrc); throw new GLException("Unable to create OpenGL >= 3.1 context (have WGL_ARB_create_context)"); } // continue with temp context for GL < 3.0 hglrc = temp_hglrc; - if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) { + if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) { throw new GLException("Error making old context current: 0x" + Integer.toHexString(WGL.GetLastError())); } + updateGLProcAddressTable(); if(DEBUG) { System.err.println("WindowsWGLContext.create done (old ctx < 3.0 - no 3.0) 0x"+Long.toHexString(hglrc)); } } else { hglrc2 = 0; // mark as shared .. - wglMakeContextCurrent(0, 0, 0); + WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_hglrc); - if (!wglMakeContextCurrent(drawable.getNativeWindow().getSurfaceHandle(), drawableRead.getNativeWindow().getSurfaceHandle(), hglrc)) { + if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), hglrc)) { throw new GLException("Error making new context current: 0x" + Integer.toHexString(WGL.GetLastError())); } updateGLProcAddressTable(); @@ -266,6 +270,7 @@ public class WindowsWGLContext extends GLContextImpl { } } GLContextShareSet.contextCreated(this); + WGL.wglMakeCurrent(0, 0); // release immediatly to gain from ARB/EXT wglMakeContextCurrent(draw, read, ctx)! if (DEBUG) { System.err.println(getThreadName() + ": !!! Created OpenGL context " + toHexString(hglrc) + " for " + this + ", device context " + toHexString(drawable.getNativeWindow().getSurfaceHandle()) + ", sharing with " + toHexString(hglrc2)); } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java index 01e259665..91604d18e 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java @@ -60,9 +60,7 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { super(factory, comp, realized); } - public void setRealized(boolean realized) { - super.setRealized(realized); - + protected void setRealizedImpl() { if(!realized) { return; // nothing todo .. } diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index af65861b9..e37179191 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -222,15 +222,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements return detail; } - private void maybeDoSingleThreadedWorkaround(Runnable action) { - if (Threading.isSingleThreaded() && - !Threading.isOpenGLThread()) { - Threading.invokeOnOpenGLThread(action); - } else { - action.run(); - } - } - public boolean canCreateContextOnJava2DSurface() { return false; } |