summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/x11
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-04-18 19:14:35 +0200
committerSven Gothel <[email protected]>2013-04-18 19:14:35 +0200
commit0a7cd9c58537d80131dbebf102f1f639ca0eb334 (patch)
treedb9305071c9f9f029d05145e40cef5c7c72eeae2 /src/jogl/classes/jogamp/opengl/x11
parent0a9ecf74540659a3258ea71d3355eeb45697db96 (diff)
Bug 718: WindowsBitmapWGLDrawable: Requires GLProfile.GL2, fix BITMAP GLCaps ASAP at Ctor instead of setRealized(true); WindowsWGLContext: Exclude ARB creation for BITMAP
Unit Test TestGLAutoDrawableFactoryGLnBitmapCapsNEWT added using BITMAP on GLProfile.getDefault() Also: X11GLXContext, WindowsWGLContext: Cleanup formatting in createImpl(..)
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/x11')
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index c60619452..c3c35ed49 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -284,28 +284,30 @@ public class X11GLXContext extends GLContextImpl {
final X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContextImpl(device);
long display = device.getHandle();
- long share = 0;
- if (shareWith != null) {
- share = shareWith.getHandle();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- direct = GLX.glXIsDirect(display, share);
+ final long share;
+ if ( null != shareWith ) {
+ share = shareWith.getHandle();
+ if (share == 0) {
+ throw new GLException("GLContextShareSet returned an invalid OpenGL context");
+ }
+ direct = GLX.glXIsDirect(display, share);
+ } else {
+ share = 0;
}
- GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
- GLProfile glp = glCaps.getGLProfile();
+ final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+ final GLProfile glp = glCaps.getGLProfile();
- if(config.getFBConfigID()<0) {
+ if( config.getFBConfigID() < 0 ) {
// not able to use FBConfig
if(glp.isGL3()) {
throw new GLException(getThreadName()+": Unable to create OpenGL >= 3.1 context");
}
contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct);
- if (contextHandle == 0) {
+ if ( 0 == contextHandle ) {
throw new GLException(getThreadName()+": Unable to create context(0)");
}
- if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) {
throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION
@@ -319,23 +321,23 @@ public class X11GLXContext extends GLContextImpl {
boolean createContextARBTried = false;
// utilize the shared context's GLXExt in case it was using the ARB method and it already exists
- if(null!=sharedContext && sharedContext.isCreatedWithARBMethod()) {
+ if( null != sharedContext && sharedContext.isCreatedWithARBMethod() ) {
contextHandle = createContextARB(share, direct);
createContextARBTried = true;
- if (DEBUG && 0!=contextHandle) {
+ if ( DEBUG && 0 != contextHandle ) {
System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+share);
}
}
- long temp_ctx = 0;
- if(0==contextHandle) {
+ final long temp_ctx;
+ if( 0 == contextHandle ) {
// To use GLX_ARB_create_context, we have to make a temp context current,
// so we are able to use GetProcAddress
temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, direct);
- if (temp_ctx == 0) {
+ if ( 0 == temp_ctx ) {
throw new GLException(getThreadName()+": Unable to create temp OpenGL context(1)");
}
- if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) {
+ if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx) ) {
throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable);
}
setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION
@@ -349,7 +351,7 @@ public class X11GLXContext extends GLContextImpl {
contextHandle = createContextARB(share, direct);
createContextARBTried=true;
if (DEBUG) {
- if(0!=contextHandle) {
+ if( 0 != contextHandle ) {
System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share);
} else {
System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share);
@@ -360,18 +362,20 @@ public class X11GLXContext extends GLContextImpl {
", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable);
}
}
+ } else {
+ temp_ctx = 0;
}
- if(0!=contextHandle) {
- if(0!=temp_ctx) {
+ if( 0 != contextHandle ) {
+ if( 0 != temp_ctx ) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
- if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) {
throw new GLException(getThreadName()+": Cannot make previous verified context current");
}
}
} else {
- if(glp.isGL3()) {
+ if( glp.isGL3() ) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
throw new GLException(getThreadName()+": X11GLXContext.createContextImpl ctx !ARB, profile > GL2 requested (OpenGL >= 3.0.1). Requested: "+glp+", current: "+getGLVersion());
@@ -382,7 +386,7 @@ public class X11GLXContext extends GLContextImpl {
// continue with temp context for GL <= 3.0
contextHandle = temp_ctx;
- if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) {
glXMakeContextCurrent(display, 0, 0, 0);
GLX.glXDestroyContext(display, temp_ctx);
throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);