* 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.
experimental
shadowislord 11 years ago
parent 52cd458601
commit cfcc86dd8b
  1. 19
      jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java
  2. 3
      jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglCanvas.java
  3. 3
      jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglDisplay.java
  4. 3
      jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java

@ -2565,14 +2565,25 @@ public class LwjglRenderer implements Renderer {
return;
}
setFrameBuffer(null);
if (enableSrgb) {
if (!glGetBoolean(GL30.GL_FRAMEBUFFER_SRGB_CAPABLE)) {
logger.warning("Driver claims that default framebuffer " +
"is not sRGB capable. Enabling anyway.");
logger.warning("Driver claims that default framebuffer "
+ "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);
logger.log(Level.FINER, "SRGB FrameBuffer enabled (Gamma Correction)");
} else {
glDisable(GL30.GL_FRAMEBUFFER_SRGB);

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

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

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

Loading…
Cancel
Save