diff options
-rw-r--r-- | make/build.xml | 4 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsGLContext.java | 58 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java | 11 |
3 files changed, 40 insertions, 33 deletions
diff --git a/make/build.xml b/make/build.xml index c682e080a..9dad237d6 100644 --- a/make/build.xml +++ b/make/build.xml @@ -1000,10 +1000,10 @@ </jar> <jar destfile="${jogl.dist.dir}/jogl-natives-win32.jar" basedir="${jogl.dist.dir}/jogl-win32" - includes="jogl.dll" /> + includes="jogl.dll,jogl_cg.dll" /> <jar destfile="${jogl.dist.dir}/jogl-natives-linux.jar" basedir="${jogl.dist.dir}/jogl-linux" - includes="libjogl.so" /> + includes="libjogl.so,libjogl_cg.so" /> <jar destfile="${jogl.dist.dir}/jogl-natives-macosx.jar" basedir="${jogl.dist.dir}/jogl-macosx" includes="libjogl.jnilib" /> diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index bdda563b4..9232cf37a 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -254,32 +254,40 @@ public abstract class WindowsGLContext extends GLContext { System.err.println(pfd2GLCapabilities(tmpPFD)); } } else { - int numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null); - if (numFormats == 0) { - throw new GLException("Unable to enumerate pixel formats of window for GLCapabilitiesChooser"); - } - GLCapabilities[] availableCaps = new GLCapabilities[numFormats]; - pfd = new PIXELFORMATDESCRIPTOR(); - for (int i = 0; i < numFormats; i++) { - if (WGL.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) { - throw new GLException("Error describing pixel format " + (1 + i) + " of device context"); + if (onscreen) { + int numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null); + if (numFormats == 0) { + throw new GLException("Unable to enumerate pixel formats of window for GLCapabilitiesChooser"); } - availableCaps[i] = pfd2GLCapabilities(pfd); - } - // Supply information to chooser - pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps); - if ((pixelFormat < 0) || (pixelFormat >= numFormats)) { - throw new GLException("Invalid result " + pixelFormat + - " from GLCapabilitiesChooser (should be between 0 and " + - (numFormats - 1) + ")"); - } - if (DEBUG) { - System.err.println("Chosen pixel format (" + pixelFormat + "):"); - System.err.println(availableCaps[pixelFormat]); - } - pixelFormat += 1; // one-base the index - if (WGL.DescribePixelFormat(hdc, pixelFormat, pfd.size(), pfd) == 0) { - throw new GLException("Error re-describing the chosen pixel format"); + GLCapabilities[] availableCaps = new GLCapabilities[numFormats]; + pfd = new PIXELFORMATDESCRIPTOR(); + for (int i = 0; i < numFormats; i++) { + if (WGL.DescribePixelFormat(hdc, 1 + i, pfd.size(), pfd) == 0) { + throw new GLException("Error describing pixel format " + (1 + i) + " of device context"); + } + availableCaps[i] = pfd2GLCapabilities(pfd); + } + // Supply information to chooser + pixelFormat = chooser.chooseCapabilities(capabilities, availableCaps); + if ((pixelFormat < 0) || (pixelFormat >= numFormats)) { + throw new GLException("Invalid result " + pixelFormat + + " from GLCapabilitiesChooser (should be between 0 and " + + (numFormats - 1) + ")"); + } + if (DEBUG) { + System.err.println("Chosen pixel format (" + pixelFormat + "):"); + System.err.println(availableCaps[pixelFormat]); + } + pixelFormat += 1; // one-base the index + if (WGL.DescribePixelFormat(hdc, pixelFormat, pfd.size(), pfd) == 0) { + throw new GLException("Error re-describing the chosen pixel format"); + } + } else { + // For now, use ChoosePixelFormat for offscreen surfaces until + // we figure out how to properly choose an offscreen- + // compatible pixel format + pfd = glCapabilities2PFD(capabilities, onscreen); + pixelFormat = WGL.ChoosePixelFormat(hdc, pfd); } } if (!WGL.SetPixelFormat(hdc, pixelFormat, pfd)) { diff --git a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java index ef1c9511f..8c2e72a7d 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java @@ -140,16 +140,15 @@ public class WindowsOffscreenGLContext extends WindowsGLContext { header.biCompression(WGL.BI_RGB); header.biSizeImage(width * height * bitsPerPixel / 8); - // CreateDIBSection doesn't really need the device context if we are - // producing a truecolor bitmap. - hbitmap = WGL.CreateDIBSection(0, info, WGL.DIB_RGB_COLORS, 0, 0, 0); - if (hbitmap == 0) { - throw new GLException("Error creating offscreen bitmap"); - } hdc = WGL.CreateCompatibleDC(0); if (hdc == 0) { + System.out.println("LastError: " + WGL.GetLastError()); throw new GLException("Error creating device context for offscreen OpenGL context"); } + hbitmap = WGL.CreateDIBSection(hdc, info, WGL.DIB_RGB_COLORS, 0, 0, 0); + if (hbitmap == 0) { + throw new GLException("Error creating offscreen bitmap"); + } if ((origbitmap = WGL.SelectObject(hdc, hbitmap)) == 0) { throw new GLException("Error selecting bitmap into new device context"); } |