* When creating display pixel format, do not use withSRGB as it could cause display creation to fail (when gamma correction is enabled). Based on online research, it seems that it is not necessary, and simply enabling SRGB writes on the main framebuffer is enough.

* Added additional checks when enabling SRGB writes to ensure the default framebuffer actually supports it, and print a warning if it doesn't.
This commit is contained in:
shadowislord 2014-06-03 23:16:34 -04:00
parent 52cd458601
commit cfcc86dd8b
4 changed files with 18 additions and 10 deletions

View File

@ -2565,10 +2565,21 @@ public class LwjglRenderer implements Renderer {
return; return;
} }
setFrameBuffer(null);
if (enableSrgb) { if (enableSrgb) {
if (!glGetBoolean(GL30.GL_FRAMEBUFFER_SRGB_CAPABLE)) { if (!glGetBoolean(GL30.GL_FRAMEBUFFER_SRGB_CAPABLE)) {
logger.warning("Driver claims that default framebuffer " + logger.warning("Driver claims that default framebuffer "
"is not sRGB capable. Enabling anyway."); + "is not sRGB capable. Enabling anyway.");
}
int encoding = GL30.glGetFramebufferAttachmentParameteri(GL30.GL_DRAW_FRAMEBUFFER,
GL_FRONT_LEFT,
GL30.GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING);
if (encoding != GL21.GL_SRGB) {
logger.warning("Driver claims that default framebuffer "
+ "is not using sRGB color encoding. Enabling anyway.");
} }
glEnable(GL30.GL_FRAMEBUFFER_SRGB); glEnable(GL30.GL_FRAMEBUFFER_SRGB);

View File

@ -323,8 +323,7 @@ public class LwjglCanvas extends LwjglAbstractDisplay implements JmeCanvasContex
0, 0,
0, 0,
0, 0,
settings.useStereo3D()) settings.useStereo3D());
.withSRGB(settings.getGammaCorrection());
} }
return canvasFormat; return canvasFormat;
} }

View File

@ -91,8 +91,7 @@ public class LwjglDisplay extends LwjglAbstractDisplay {
0, 0,
0, 0,
0, 0,
settings.useStereo3D()) settings.useStereo3D());
.withSRGB(settings.getGammaCorrection());
frameRate = settings.getFrameRate(); frameRate = settings.getFrameRate();
logger.log(Level.FINE, "Selected display mode: {0}", displayMode); logger.log(Level.FINE, "Selected display mode: {0}", displayMode);

View File

@ -65,8 +65,7 @@ public class LwjglOffscreenBuffer extends LwjglContext implements Runnable {
0, 0,
settings.getDepthBits(), settings.getDepthBits(),
settings.getStencilBits(), settings.getStencilBits(),
samples) samples);
.withSRGB(settings.getGammaCorrection());
width = settings.getWidth(); width = settings.getWidth();
height = settings.getHeight(); height = settings.getHeight();