summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2003-09-05 18:15:16 +0000
committerKenneth Russel <[email protected]>2003-09-05 18:15:16 +0000
commit567c3eb46f05be1dec37e2cfcd90ce13403666e5 (patch)
treeac607b0313608619c6467f7bf39f729aa73d22aa /src
parenta666add538a6afe744a7a0fc0620ddb7800c182a (diff)
Added contribution from user GKW on community.java.net forums to fix
pixel format selection for GLJPanel on Win32 by using ChoosePixelFormat rather than DefaultGLCapabilitiesChooser. Modified dist targets to include Cg native libraries. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@62 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsGLContext.java58
-rw-r--r--src/net/java/games/jogl/impl/windows/WindowsOffscreenGLContext.java11
2 files changed, 38 insertions, 31 deletions
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");
}