aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-04-15 07:24:20 +0200
committerSven Gothel <[email protected]>2010-04-15 07:24:20 +0200
commitbd4904fb04ab2168aeaf76e74385b3991429289a (patch)
treec21cc1e959caecbeaed109506acbfb8b853eeda2 /src/jogl
parent2ae28d54858ff684bc2368e0476a7a357dc63432 (diff)
JOGL (Windows):
- WindowsWGLDrawableFactory is using [singleton] shared dummy resources for - Drawable and Context which are utilized in case they are needed .. They are removed at shutdown call - GLCapabilities - Set pbuffer as the HW capabilities show, hence onscreen && pbuffer is valid - DefaultGLCapabilitiesChooser: Respect PBuffer selection (fixed) Only skip a config, if request is !onscreen && pbuffer, but pbuffer n/a Tests: - JUnit Passed (Windows32: Chromium - Except PBuffer (n/a)
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java101
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java34
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java5
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java4
8 files changed, 77 insertions, 84 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
index 616640bad..0cc10b35e 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/GLDrawableFactoryImpl.java
@@ -79,9 +79,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
GLCapabilities caps = (GLCapabilities) target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
GLDrawable result = null;
if(caps.isOnscreen()) {
- if(caps.isPBuffer()) {
- throw new IllegalArgumentException("Onscreen target can't be PBuffer: "+caps);
- }
if(DEBUG) {
System.out.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java
index 2d5154442..176628633 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -179,11 +179,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
} */
}
if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SURFACE_TYPE, val, 0)) {
- if(EGLConfigDrawableTypeVerify(val[0], onscreen, usePBuffer)) {
- caps.setDoubleBuffered(onscreen);
- caps.setOnscreen(onscreen);
- caps.setPBuffer(usePBuffer);
- } else if(relaxed) {
+ if(EGLConfigDrawableTypeVerify(val[0], onscreen, usePBuffer) || relaxed) {
caps.setDoubleBuffered( 0 != (val[0] & EGL.EGL_WINDOW_BIT) );
caps.setOnscreen( 0 != (val[0] & EGL.EGL_WINDOW_BIT) );
caps.setPBuffer ( 0 != (val[0] & EGL.EGL_PBUFFER_BIT) );
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 cb3ee19e0..e3938f9fe 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
@@ -43,6 +43,7 @@ import com.jogamp.common.os.DynamicLookupHelper;
import java.nio.*;
import java.util.*;
import javax.media.nativewindow.*;
+import javax.media.nativewindow.windows.*;
import javax.media.opengl.*;
import com.jogamp.opengl.impl.*;
import com.jogamp.nativewindow.impl.NWReflection;
@@ -72,7 +73,45 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
loadOpenGL32Library();
}
+ WindowsDummyWGLDrawable sharedDrawable=null;
+ WindowsWGLContext sharedContext=null;
+ boolean canCreateGLPbuffer = false;
+
+ void initShared() {
+ if(null==sharedDrawable) {
+ sharedDrawable = new WindowsDummyWGLDrawable(this, null);
+ sharedContext = (WindowsWGLContext) sharedDrawable.createContext(null);
+ sharedContext.makeCurrent();
+ canCreateGLPbuffer = sharedContext.getGL().isExtensionAvailable("GL_ARB_pbuffer");
+ sharedContext.release();
+ if (DEBUG) {
+ System.err.println("!!! SharedContext: "+sharedContext+", pbuffer supported "+canCreateGLPbuffer);
+ }
+ if(null==sharedContext) {
+ throw new GLException("Couldn't init shared resources");
+ }
+ }
+ }
+
+ public void shutdown() {
+ super.shutdown();
+ if (DEBUG) {
+ System.err.println("!!! Shutdown Shared:");
+ System.err.println("!!! CTX : "+sharedContext);
+ System.err.println("!!! Drawable: "+sharedDrawable);
+ Exception e = new Exception("Debug");
+ e.printStackTrace();
+ }
+ if(null!=sharedContext) {
+ sharedContext.destroy(); // implies release, if current
+ }
+ if(null!=sharedDrawable) {
+ sharedDrawable.destroy();
+ }
+ }
+
public GLDrawableImpl createOnscreenDrawable(NativeWindow target) {
+ validate();
if (target == null) {
throw new IllegalArgumentException("Null target");
}
@@ -83,67 +122,33 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
return new WindowsOffscreenWGLDrawable(this, target);
}
- private boolean pbufferSupportInitialized = false;
- private boolean canCreateGLPbuffer = false;
public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
- if (!pbufferSupportInitialized) {
- final GLDrawableFactory factory = this;
- Runnable r = new Runnable() {
- public void run() {
- WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory, null);
- GLContext dummyContext = dummyDrawable.createContext(null);
- if (dummyContext != null) {
- GLContext lastContext = GLContext.getCurrent();
- if (lastContext != null) {
- lastContext.release();
- }
- dummyContext.makeCurrent();
- GL dummyGL = dummyContext.getGL();
- canCreateGLPbuffer = dummyGL.isExtensionAvailable("GL_ARB_pbuffer");
- pbufferSupportInitialized = true;
- dummyContext.release();
- dummyContext.destroy();
- dummyDrawable.destroy();
- if (lastContext != null) {
- lastContext.makeCurrent();
- }
- }
- }
- };
- maybeDoSingleThreadedWorkaround(r);
- }
- if (DEBUG) {
- System.err.println("WindowsWGLDrawableFactory.canCreateGLPbuffer() = " + canCreateGLPbuffer);
- }
+ validate();
+ initShared();
return canCreateGLPbuffer;
}
protected GLDrawableImpl createGLPbufferDrawableImpl(final NativeWindow target) {
+ initShared();
final List returnList = new ArrayList();
final GLDrawableFactory factory = this;
+ final WindowsWGLContext _sharedContext = sharedContext;
+ final WindowsDummyWGLDrawable _sharedDrawable = sharedDrawable;
Runnable r = new Runnable() {
public void run() {
- WindowsDummyWGLDrawable dummyDrawable = new WindowsDummyWGLDrawable(factory, null);
- WindowsWGLContext dummyContext = (WindowsWGLContext) dummyDrawable.createContext(null);
GLContext lastContext = GLContext.getCurrent();
if (lastContext != null) {
lastContext.release();
}
- dummyContext.makeCurrent();
- WGLExt dummyWGLExt = dummyContext.getWGLExt();
+ _sharedContext.makeCurrent();
+ WGLExt wglExt = _sharedContext.getWGLExt();
try {
GLDrawableImpl pbufferDrawable = new WindowsPbufferWGLDrawable(factory, target,
- dummyDrawable,
- dummyWGLExt);
+ _sharedDrawable,
+ wglExt);
returnList.add(pbufferDrawable);
} finally {
- if(null!=dummyContext) {
- dummyContext.release();
- dummyContext.destroy();
- }
- if(null!=dummyDrawable) {
- dummyDrawable.destroy();
- }
+ _sharedContext.release();
if (lastContext != null) {
lastContext.makeCurrent();
}
@@ -163,18 +168,22 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public GLContext createExternalGLContext() {
+ validate();
return WindowsExternalWGLContext.create(this, null);
}
public boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) {
+ validate();
return true;
}
public GLDrawable createExternalGLDrawable() {
+ validate();
return WindowsExternalWGLDrawable.create(this, null);
}
public void loadOpenGL32Library() {
+ validate();
if (hopengl32 == 0) {
hopengl32 = WGL.LoadLibraryA("OpenGL32");
if (DEBUG) {
@@ -186,6 +195,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public void loadGLULibrary() {
+ validate();
if (hglu32 == 0) {
hglu32 = WGL.LoadLibraryA("GLU32");
if (hglu32 == 0) {
@@ -195,6 +205,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public long dynamicLookupFunction(String glFuncName) {
+ validate();
long res = WGL.wglGetProcAddress(glFuncName);
if (res == 0) {
// It may happen that a driver doesn't return the OpenGL32 core function pointer
@@ -227,11 +238,13 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements
}
public boolean canCreateContextOnJava2DSurface(AbstractGraphicsDevice device) {
+ validate();
return false;
}
public GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith)
throws GLException {
+ validate();
throw new GLException("Unimplemented on this platform");
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index aed4012a4..15823b6dc 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -428,10 +428,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
boolean relaxed, boolean onscreen, boolean usePBuffer) {
GLCapabilities res = new GLCapabilities(glp);
int drawableTypeBits = WGLConfig2DrawableTypeBits(iattribs, niattribs, iresults);
- if(WGLConfigDrawableTypeVerify(drawableTypeBits, onscreen, usePBuffer)) {
- res.setOnscreen(onscreen);
- res.setPBuffer(usePBuffer);
- } else if(relaxed) {
+ if(WGLConfigDrawableTypeVerify(drawableTypeBits, onscreen, usePBuffer) || relaxed) {
res.setOnscreen( 0 != (drawableTypeBits & WINDOW_BIT) );
res.setPBuffer ( 0 != (drawableTypeBits & PBUFFER_BIT) );
} else {
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 1a375699c..c9805fef1 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
@@ -87,7 +87,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
protected static void updateGraphicsConfiguration(CapabilitiesChooser chooser,
- GLDrawableFactory factory, NativeWindow nativeWindow) {
+ GLDrawableFactory _factory, NativeWindow nativeWindow) {
+ WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory) _factory;
if (nativeWindow == null) {
throw new IllegalArgumentException("NativeWindow is null");
}
@@ -134,25 +135,16 @@ 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
- WindowsWGLDrawable dummyDrawable = null;
- GLContextImpl dummyContext = null;
- WGLExt dummyWGLExt = null;
- if (capabilities.getSampleBuffers()) {
- dummyDrawable = new WindowsDummyWGLDrawable(factory, glProfile);
- dummyContext = (GLContextImpl) dummyDrawable.createContext(null);
- if (dummyContext != null) {
- dummyContext.makeCurrent();
- dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions();
- }
- } else if (DEBUG) {
- System.err.println(getThreadName() + ": Not using WGL_ARB_pixel_format, because multisampling not requested");
- }
+ factory.initShared();
+ factory.sharedContext.makeCurrent();
+ WGLExt wglExt = factory.sharedContext.getWGLExt();
+
int recommendedPixelFormat = pixelFormat; // 1-based pixel format
boolean haveWGLChoosePixelFormatARB = false;
boolean gotAvailableCaps = false;
- if (dummyWGLExt != null) {
+ if (wglExt != null) {
try {
- haveWGLChoosePixelFormatARB = dummyWGLExt.isExtensionAvailable("WGL_ARB_pixel_format");
+ haveWGLChoosePixelFormatARB = wglExt.isExtensionAvailable("WGL_ARB_pixel_format");
if (haveWGLChoosePixelFormatARB) {
if(pixelFormat<=0) {
int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS];
@@ -160,12 +152,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if(WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
iattributes,
- dummyWGLExt,
+ wglExt,
false,
null)) {
int[] pformats = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS];
int[] numFormatsTmp = new int[1];
- if (dummyWGLExt.wglChoosePixelFormatARB(hdc,
+ if (wglExt.wglChoosePixelFormatARB(hdc,
iattributes, 0,
fattributes, 0,
WindowsWGLGraphicsConfiguration.MAX_PFORMATS,
@@ -196,16 +188,14 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
}
- availableCaps = WindowsWGLGraphicsConfiguration.HDC2GLCapabilities(dummyWGLExt, hdc, -1, glProfile, pixelFormatSet, onscreen, usePBuffer);
+ availableCaps = WindowsWGLGraphicsConfiguration.HDC2GLCapabilities(wglExt, hdc, -1, glProfile, pixelFormatSet, onscreen, usePBuffer);
gotAvailableCaps = null!=availableCaps ;
choosenBywGLPixelFormat = gotAvailableCaps ;
} else if (DEBUG) {
System.err.println(getThreadName() + ": wglChoosePixelFormatARB not available");
}
} finally {
- dummyContext.release();
- dummyContext.destroy();
- dummyDrawable.destroy();
+ factory.sharedContext.release();
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index eda480d5f..cfcd5cbe3 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -99,6 +99,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna
if (DEBUG) {
System.err.println("!!! SharedContext: "+sharedContext);
}
+ if(null==sharedContext) {
+ throw new GLException("Couldn't init shared resources");
+ }
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 35daf0ae0..393891bab 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -250,10 +250,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
GLCapabilities res = new GLCapabilities(glp);
val = glXGetFBConfig(display, fbcfg, GLX.GLX_DRAWABLE_TYPE, tmp, 0);
- if(GLXFBConfigDrawableTypeVerify(val, onscreen, usePBuffer)) {
- res.setOnscreen(onscreen);
- res.setPBuffer(usePBuffer);
- } else if(relaxed) {
+ if(GLXFBConfigDrawableTypeVerify(val, onscreen, usePBuffer) || relaxed) {
res.setOnscreen( 0 != (val & GLX.GLX_WINDOW_BIT) );
res.setPBuffer ( 0 != (val & GLX.GLX_PBUFFER_BIT) );
} else {
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index c5ded88f6..ee41c9161 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -138,8 +138,8 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
if (_desired.isOnscreen() != cur.isOnscreen()) {
continue;
}
- if (_desired.isPBuffer() != cur.isPBuffer()) {
- continue;
+ if (!_desired.isOnscreen() && _desired.isPBuffer() && !cur.isPBuffer()) {
+ continue; // only skip if requested Offscreen && PBuffer, but no PBuffer available
}
if (_desired.getStereo() != cur.getStereo()) {
continue;