diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl')
2 files changed, 30 insertions, 31 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index e87d3cce2..c85545b48 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -44,38 +44,42 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLProfile; +import javax.media.nativewindow.AbstractGraphicsScreen; import com.jogamp.nativewindow.impl.ProxySurface; import com.jogamp.nativewindow.impl.windows.GDI; -import com.jogamp.nativewindow.impl.windows.PIXELFORMATDESCRIPTOR; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLException; public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { private long hwnd, hdc; - protected WindowsDummyWGLDrawable(GLDrawableFactory factory, GLCapabilitiesImmutable caps) { - super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, null)), true); + protected WindowsDummyWGLDrawable(GLDrawableFactory factory, GLCapabilitiesImmutable caps, AbstractGraphicsScreen absScreen) { + super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, absScreen)), true); hwnd = GDI.CreateDummyWindow(0, 0, 1, 1); hdc = GDI.GetDC(hwnd); ProxySurface ns = (ProxySurface) getNativeSurface(); ns.setSurfaceHandle(hdc); WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); - // Choose a (hopefully hardware-accelerated) OpenGL pixel format for this device context - PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD((GLCapabilitiesImmutable)config.getChosenCapabilities()); - int pixelFormat = GDI.ChoosePixelFormat(hdc, pfd); - if ((pixelFormat == 0) || - (!GDI.SetPixelFormat(hdc, pixelFormat, pfd))) { - destroy(); + + try { + config.updateGraphicsConfiguration(factory, ns); + if (DEBUG) { + System.err.println("!!! WindowsDummyWGLDrawable: "+config); + } + } catch (Throwable t) { + destroyImpl(); + throw new GLException(t); } } - public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp) { + public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp, AbstractGraphicsScreen absScreen) { GLCapabilities caps = new GLCapabilities(glp); caps.setDepthBits(16); caps.setDoubleBuffered(true); caps.setOnscreen (true); caps.setPBuffer (true); - return new WindowsDummyWGLDrawable(factory, caps); + return new WindowsDummyWGLDrawable(factory, caps, absScreen); } public void setSize(int width, int height) { 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 c9fda109f..87bbec018 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 @@ -137,7 +137,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio AbstractGraphicsDevice device = config.getScreen().getDevice(); WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device); if (null == sharedContext) { - throw new InternalError("SharedContext is null: " + device); + if (DEBUG) { + System.err.println("updateGraphicsConfigurationARB: SharedContext is null: "+device); + } + return false; } GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); boolean onscreen = capsChosen.isOnscreen(); @@ -152,17 +155,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio int numFormats = -1; int recommendedIndex = -1; - if ((pixelFormatSet = GDI.GetPixelFormat(hdc)) != 0) { - // Pixelformat already set by either - // - a previous updateGraphicsConfiguration() call on the same HDC, - // - the graphics driver, copying the HDC's pixelformat to the new one, - // - or the Java2D/OpenGL pipeline's configuration - if (DEBUG) { - System.err.println("updateGraphicsConfigurationARB: Pixel format already chosen for HDC: " + toHexString(hdc) - + ", pixelformat " + pixelFormatSet); - } - } - synchronized (sharedContext) { sharedContext.makeCurrent(); try { @@ -172,10 +164,18 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } return false; } - if (pixelFormatSet >= 1) { + if ((pixelFormatSet = GDI.GetPixelFormat(hdc)) >= 1) { + // Pixelformat already set by either + // - a previous updateGraphicsConfiguration() call on the same HDC, + // - the graphics driver, copying the HDC's pixelformat to the new one, + // - or the Java2D/OpenGL pipeline's configuration + if (DEBUG) { + System.err.println("updateGraphicsConfigurationARB: Pixel format already chosen for HDC: " + toHexString(hdc) + + ", pixelformat " + pixelFormatSet); + } + // only fetch the specific one .. - pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedContext, hdc, pixelFormatSet, - glProfile, onscreen, usePBuffer); + pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedContext, hdc, pixelFormatSet, glProfile, onscreen, usePBuffer); } else { int[] iattributes = new int[2 * WindowsWGLGraphicsConfiguration.MAX_ATTRIBS]; float[] fattributes = new float[1]; @@ -292,11 +292,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio private static boolean updateGraphicsConfigurationGDI(long hdc, WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, WindowsWGLDrawableFactory factory) { - AbstractGraphicsDevice device = config.getScreen().getDevice(); - WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device); - if (null == sharedContext) { - throw new InternalError("SharedContext is null: " + device); - } GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); boolean onscreen = capsChosen.isOnscreen(); boolean usePBuffer = capsChosen.isPBuffer(); |