* Fixed issue 550

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9985 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 12 years ago
parent fead899369
commit be59bd91fb
  1. 97
      engine/src/lwjgl/com/jme3/system/lwjgl/LwjglContext.java

@ -112,52 +112,83 @@ public abstract class LwjglContext implements JmeContext {
} }
protected int determineMaxSamples(int requestedSamples) { protected int determineMaxSamples(int requestedSamples) {
boolean displayWasCurrent = false;
try {
// If we already have a valid context, determine samples using current
// context.
if (Display.isCreated() && Display.isCurrent()) {
if (GLContext.getCapabilities().GL_ARB_framebuffer_object) {
return GL11.glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES);
} else if (GLContext.getCapabilities().GL_EXT_framebuffer_multisample) {
return GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT);
}
// Doesn't support any of the needed extensions .. continue down.
displayWasCurrent = true;
}
} catch (LWJGLException ex) {
listener.handleError("Failed to check if display is current", ex);
}
if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) { if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
// No pbuffer, assume everything is supported. // No pbuffer, assume everything is supported.
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} else { } else {
Pbuffer pb = null; Pbuffer pb = null;
// OpenGL2 method: Create pbuffer and query samples if (!displayWasCurrent) {
// from GL_ARB_framebuffer_object or GL_EXT_framebuffer_multisample. // OpenGL2 method: Create pbuffer and query samples
try { // from GL_ARB_framebuffer_object or GL_EXT_framebuffer_multisample.
pb = new Pbuffer(1, 1, new PixelFormat(0, 0, 0), null); try {
pb.makeCurrent(); pb = new Pbuffer(1, 1, new PixelFormat(0, 0, 0), null);
pb.makeCurrent();
if (GLContext.getCapabilities().GL_ARB_framebuffer_object) { if (GLContext.getCapabilities().GL_ARB_framebuffer_object) {
return GL11.glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES); return GL11.glGetInteger(ARBFramebufferObject.GL_MAX_SAMPLES);
} else if (GLContext.getCapabilities().GL_EXT_framebuffer_multisample) { } else if (GLContext.getCapabilities().GL_EXT_framebuffer_multisample) {
return GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT); return GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT);
} }
// OpenGL2 method failed. // OpenGL2 method failed.
} catch (LWJGLException ex) { } catch (LWJGLException ex) {
// Something else failed. // Something else failed.
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} finally { } finally {
if (pb != null) { if (pb != null) {
pb.destroy(); pb.destroy();
pb = null; pb = null;
}
} }
} }
// OpenGL1 method // OpenGL1 method (DOESNT WORK RIGHT NOW ..)
requestedSamples = FastMath.nearestPowerOfTwo(requestedSamples); requestedSamples = FastMath.nearestPowerOfTwo(requestedSamples);
while (requestedSamples > 1) { try {
try { requestedSamples = Integer.MAX_VALUE;
pb = new Pbuffer(1, 1, new PixelFormat(0, 0, 0, requestedSamples), null); /*
} catch (LWJGLException ex) { while (requestedSamples > 1) {
if (ex.getMessage().startsWith("Failed to find ARB pixel format")) { try {
// Unsupported format, so continue. pb = new Pbuffer(1, 1, new PixelFormat(16, 0, 8, 0, requestedSamples), null);
requestedSamples /= 2; } catch (LWJGLException ex) {
} else { if (ex.getMessage().startsWith("Failed to find ARB pixel format")) {
// Something else went wrong .. // Unsupported format, so continue.
return Integer.MAX_VALUE; requestedSamples = FastMath.nearestPowerOfTwo(requestedSamples / 2);
} else {
// Something else went wrong ..
return Integer.MAX_VALUE;
}
} finally {
if (pb != null){
pb.destroy();
pb = null;
}
} }
} finally { }*/
if (pb != null){ } finally {
pb.destroy(); if (displayWasCurrent) {
pb = null; try {
Display.makeCurrent();
} catch (LWJGLException ex) {
listener.handleError("Failed to make display current after checking samples", ex);
} }
} }
} }

Loading…
Cancel
Save