aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/windows
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-20 11:46:26 +0200
committerSven Gothel <[email protected]>2010-04-20 11:46:26 +0200
commit32790c376583beccd030eecd7c56cbe66d380172 (patch)
tree894613c7fc6a598aed59db87e5812ef6a44b83dd /src/jogl/classes/com/jogamp/opengl/impl/windows
parentaa7084700bbf74d8bcc98cf0239f57cff2983423 (diff)
JOGL GL4 preperation (cont):
- All available OpenGL versions (native/platform) are verified at GLProfile initialization and can be queried .. A mapping of major,compat -> major,minor,options is created. - Removal of temp context creation, when creating a context. This was necessary to query general availability of ARB_create_context. Due to the shared context of X11GLXDrawableFactory and WindowsWGLDrawableFactory, this is no more necessary. Due to the version mapping, the ARB_create_context paramters are known. - NativeWindow X11Lib: Added X11ErrorHandler, throwing a RuntimeException. Necessary to catch BadMatch .. etc X11 errors, eg for glXCreateContextAttribsARB Hence all X11 calls are covered now. - X11DummyGLXDrawable needs to use an own Window, otherwise GLn n>2 fails - Flattening the desktop GL* implementation, all use GL4bcImpl, which reduces the footprint dramatically. - GL*Impl.isGL*() (desktop) utilizes the GLContext.isGL*(), hence the results reflect the actual native context version. - GLContextImpl makeCurrent/create: Added workflow documentation, clarified code, defined abstract methods to have a protocol. - Removed moved files (from here to gluegen), see gluegen a01cb3d59715a41153380f1977ec75263b762dc6 - NativeLibLoader -> <TYPE>JNILibLoader - Fixed Exception Handling (as in gluegen bce53b52c8638729750c4286dbc04cb14329fd34), ie removed empty catch Throwable .. - GLContext.setSwapInterval(): Nop in offscreen case, otherwise X11IOError (NVIDIA Bug) Test: Tests - Junit - demos.gears.Gears - demos.jrefract.JRefract Platforms - Linux 64/32 ATI/NVidia - MacOsX - Windows (virtualbox 3.1.6, offscreen failed) TODO/BUGS: - FIXME ATI GLn n>2 with AWT, can't make context current, works well on NVIDIA though - FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available! - Add GL 3.3 to GL3/gl3ext.h - Add GL 4.0 to GL3/gl3ext.h and fix the GL3/GL4 seperation - Rename jogl.gl2.jar -> jogl.gldesktop.jar (as done with it's native lib already)
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/windows')
-rwxr-xr-xsrc/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java16
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java52
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java1
4 files changed, 32 insertions, 39 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
index aae376a6c..e712d8568 100755
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsExternalWGLContext.java
@@ -56,7 +56,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
System.err.println(getThreadName() + ": !!! Created external OpenGL context " + toHexString(hglrc) + " for " + this);
}
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, 0);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
cfg.updateCapabilitiesByWGL(this);
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 95706a7a1..0f1f9813f 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -122,13 +122,18 @@ public class WindowsWGLContext extends GLContextImpl {
protected Map/*<String, String>*/ getExtensionNameMap() { return extensionNameMap; }
+ protected void destroyContextARBImpl(long context) {
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(context);
+ }
+
protected long createContextARBImpl(long share, boolean direct, int ctp, int major, int minor) {
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
WGLExt wglExt;
if(null==factory.getSharedContext()) {
wglExt = getWGLExt();
} else {
- wglExt = factory.getSharedContext().getWGLExt();
+ wglExt = ((WindowsWGLContext)factory.getSharedContext()).getWGLExt();
}
boolean ctBwdCompat = 0 != ( CTX_PROFILE_COMPAT & ctp ) ;
@@ -235,7 +240,7 @@ public class WindowsWGLContext extends GLContextImpl {
if (!WGL.wglMakeCurrent(drawable.getNativeWindow().getSurfaceHandle(), temp_hglrc)) {
throw new GLException("Error making temp context current: 0x" + Integer.toHexString(WGL.GetLastError()));
}
- setGLFunctionAvailability(true, 0, 0, 0);
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
if( createContextARBTried ||
!isFunctionAvailable("wglCreateContextAttribsARB") ||
@@ -257,9 +262,6 @@ public class WindowsWGLContext extends GLContextImpl {
if(0!=hglrc) {
share = 0; // mark as shared ..
- // need to update the GL func table ..
- setGLFunctionAvailability(true, major[0], minor[0], ctp[0]);
-
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_hglrc);
@@ -302,10 +304,10 @@ public class WindowsWGLContext extends GLContextImpl {
boolean created = false;
if (hglrc == 0) {
create();
+ created = true;
if (DEBUG) {
System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
}
- created = true;
}
if (WGL.wglGetCurrentContext() != hglrc) {
@@ -320,7 +322,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
if (created) {
- setGLFunctionAvailability(false, -1, -1, -1);
+ setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
WindowsWGLGraphicsConfiguration config =
(WindowsWGLGraphicsConfiguration)drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index bc99338ab..a4bf89b81 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -45,8 +45,9 @@ import java.util.*;
import javax.media.nativewindow.*;
import javax.media.nativewindow.windows.*;
import javax.media.opengl.*;
+import com.jogamp.common.JogampRuntimeException;
+import com.jogamp.common.util.*;
import com.jogamp.opengl.impl.*;
-import com.jogamp.nativewindow.impl.NWReflection;
import com.jogamp.nativewindow.impl.NullWindow;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
@@ -66,40 +67,38 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
// The act of constructing them causes them to be registered
new WindowsWGLGraphicsConfigurationFactory();
try {
- NWReflection.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
+ ReflectionUtil.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory",
new Object[] {});
- } catch (Throwable t) { }
+ } catch (JogampRuntimeException jre) { /* n/a .. */ }
loadOpenGL32Library();
+
+ sharedDrawable = new WindowsDummyWGLDrawable(this, null);
+ WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
+ ctx.makeCurrent();
+ canCreateGLPbuffer = ctx.getGL().isExtensionAvailable("GL_ARB_pbuffer");
+ ctx.release();
+ sharedContext = ctx;
+ if(null==sharedContext) {
+ throw new GLException("Couldn't init shared resources");
+ }
+ if (DEBUG) {
+ System.err.println("!!! SharedContext: "+sharedContext+", pbuffer supported "+canCreateGLPbuffer);
+ }
}
WindowsDummyWGLDrawable sharedDrawable=null;
WindowsWGLContext sharedContext=null;
boolean canCreateGLPbuffer = false;
- // package private ..
- final WindowsWGLContext getSharedContext() {
+ protected final GLDrawableImpl getSharedDrawable() {
validate();
- return sharedContext;
+ return sharedDrawable;
}
- void initShared() {
- if(null==sharedDrawable) {
- sharedDrawable = new WindowsDummyWGLDrawable(this, null);
- WindowsWGLContext _sharedContext = (WindowsWGLContext) sharedDrawable.createContext(null);
- {
- _sharedContext.makeCurrent();
- canCreateGLPbuffer = _sharedContext.getGL().isExtensionAvailable("GL_ARB_pbuffer");
- _sharedContext.release();
- }
- _sharedContext = _sharedContext;
- if (DEBUG) {
- System.err.println("!!! SharedContext: "+sharedContext+", pbuffer supported "+canCreateGLPbuffer);
- }
- if(null==sharedContext) {
- throw new GLException("Couldn't init shared resources");
- }
- }
+ protected final GLContextImpl getSharedContext() {
+ validate();
+ return sharedContext;
}
public void shutdown() {
@@ -124,7 +123,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
return new WindowsOnscreenWGLDrawable(this, target);
}
@@ -133,13 +131,11 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
return new WindowsOffscreenWGLDrawable(this, target);
}
public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
validate();
- initShared(); // setup canCreateGLPBuffer
return canCreateGLPbuffer;
}
@@ -148,7 +144,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- initShared();
final List returnList = new ArrayList();
final GLDrawableFactory factory = this;
final WindowsWGLContext _sharedContext = sharedContext;
@@ -180,7 +175,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
protected NativeWindow createOffscreenWindow(GLCapabilities capabilities, GLCapabilitiesChooser chooser, int width, int height) {
validate();
- initShared();
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault();
NullWindow nw = new NullWindow(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
capabilities, chooser, screen) );
@@ -190,7 +184,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
public GLContext createExternalGLContext() {
validate();
- initShared();
return WindowsExternalWGLContext.create(this, null);
}
@@ -201,7 +194,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
public GLDrawable createExternalGLDrawable() {
validate();
- initShared();
return WindowsExternalWGLDrawable.create(this, null);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index c9805fef1..ab3227257 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -135,7 +135,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
// Produce a recommended pixel format selection for the GLCapabilitiesChooser.
// Use wglChoosePixelFormatARB if user requested multisampling and if we have it available
- factory.initShared();
factory.sharedContext.makeCurrent();
WGLExt wglExt = factory.sharedContext.getWGLExt();