Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 additions & 0 deletions src/org/lwjgl/opengl/awt/GLData.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public static enum API {
public static enum ReleaseBehavior {
NONE, FLUSH;
}

public static enum SRGB {
EXT_sRGB, ARB_sRGB
}

/**
* The major GL context version to use. It defaults to 0 for "not specified".
Expand Down Expand Up @@ -120,6 +124,11 @@ public static enum ReleaseBehavior {
* Whether to use sRGB color space.
*/
public boolean sRGB;

/**
* <b>For internal use only</b>, used to determine the sRGB extension to use
*/
public SRGB buffer_sRGB = SRGB.EXT_sRGB;
/**
* Whether to use a floating point pixel format.
*/
Expand Down
21 changes: 17 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,11 @@ 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);
if (attribs.buffer_sRGB == GLData.SRGB.EXT_sRGB) {
ib.put(WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT).put(1);
} else {
ib.put(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 +431,22 @@ 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");
}

if (has_WGL_ARB_framebuffer_sRGB) {
attribs.buffer_sRGB = GLData.SRGB.ARB_sRGB;
} else {
attribs.buffer_sRGB = GLData.SRGB.EXT_sRGB;
}
}
if (attribs.pixelFormatFloat) {
// Check for WGL_ARB_pixel_format_float
Expand Down
Loading