Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AWTGLCanvas gives error when activating sRGB #81

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/org/lwjgl/opengl/awt/GLData.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public static enum ReleaseBehavior {
/**
* Whether to use sRGB color space.
*/
public boolean sRGB;
public boolean sRGB;
/**
* Used to determine the sRGB extension to use
*/
boolean extBuffer_sRGB = true;
/**
* Whether to use a floating point pixel format.
*/
Expand Down
13 changes: 9 additions & 4 deletions src/org/lwjgl/opengl/awt/PlatformWin32GLCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static org.lwjgl.opengl.WGLARBCreateContext.*;
import static org.lwjgl.opengl.WGLARBCreateContextProfile.*;
import static org.lwjgl.opengl.WGLARBCreateContextRobustness.*;
import static org.lwjgl.opengl.WGLARBFramebufferSRGB.*;
import static org.lwjgl.opengl.WGLARBMultisample.WGL_SAMPLES_ARB;
import static org.lwjgl.opengl.WGLARBMultisample.WGL_SAMPLE_BUFFERS_ARB;
import static org.lwjgl.opengl.WGLARBPixelFormat.*;
Expand Down Expand Up @@ -110,7 +111,7 @@ private static void encodePixelFormatAttribs(IntBuffer ib, GLData attribs) {
if (attribs.accumRedSize > 0 || attribs.accumGreenSize > 0 || attribs.accumBlueSize > 0 || attribs.accumAlphaSize > 0)
ib.put(WGL_ACCUM_BITS_ARB).put(attribs.accumRedSize + attribs.accumGreenSize + attribs.accumBlueSize + attribs.accumAlphaSize);
if (attribs.sRGB)
ib.put(WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT).put(1);
ib.put(attribs.extBuffer_sRGB ? WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT : WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB).put(1);
if (attribs.samples > 0) {
ib.put(WGL_SAMPLE_BUFFERS_ARB).put(1);
ib.put(WGL_SAMPLES_ARB).put(attribs.samples);
Expand Down Expand Up @@ -426,14 +427,18 @@ private static long create(MemoryStack stack, long windowHandle, long dummyWindo
}
}
if (attribs.sRGB) {
// Check for WGL_EXT_framebuffer_sRGB
boolean has_WGL_EXT_framebuffer_sRGB = wglExtensionsList.contains("WGL_EXT_framebuffer_sRGB");
if (!has_WGL_EXT_framebuffer_sRGB) {
// Check for WGL_EXT_framebuffer_sRGB | WGL_ARB_framebuffer_sRGB
boolean has_WGL_EXT_framebuffer_sRGB = wglExtensionsList.contains("WGL_EXT_framebuffer_sRGB"),
has_WGL_ARB_framebuffer_sRGB = wglExtensionsList.contains("WGL_ARB_framebuffer_sRGB");

if (! (has_WGL_EXT_framebuffer_sRGB || has_WGL_ARB_framebuffer_sRGB) ) {
ReleaseDC(windowHandle, hDC);
wglDeleteContext(dummyContext);
wglMakeCurrent(currentDc, currentContext);
throw new AWTException("sRGB color space requested but WGL_EXT_framebuffer_sRGB is unavailable");
}

attribs.extBuffer_sRGB = has_WGL_EXT_framebuffer_sRGB;
}
if (attribs.pixelFormatFloat) {
// Check for WGL_ARB_pixel_format_float
Expand Down