Moved pbuffer supported check into native code to fix the case of no current context when creating the pbuffer
This commit is contained in:
parent
cc8f1d8fdd
commit
a7fa07c2cc
|
@ -175,8 +175,6 @@ public final class Pbuffer {
|
|||
* with the Display context (if created).
|
||||
*/
|
||||
public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Pbuffer shared_context) throws LWJGLException {
|
||||
if ((getCapabilities() & PBUFFER_SUPPORTED) == 0)
|
||||
throw new IllegalStateException("Pbuffers are not supported");
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.handle = createPbuffer(width, height, pixel_format, renderTexture, shared_context != null ? shared_context.handle : null);
|
||||
|
|
|
@ -51,11 +51,15 @@ typedef struct _PbufferInfo {
|
|||
GLXContext context;
|
||||
} PbufferInfo;
|
||||
|
||||
static bool isPbuffersSupported() {
|
||||
// Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension
|
||||
return extgl_Extensions.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
|
||||
(JNIEnv *env, jobject this)
|
||||
{
|
||||
// Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension
|
||||
return extgl_Extensions.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
|
||||
return isPbuffersSupported() ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
|
||||
}
|
||||
|
||||
static void destroyPbuffer(PbufferInfo *buffer_info) {
|
||||
|
@ -127,9 +131,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreatePbuffer(JNIEnv
|
|||
return;
|
||||
}
|
||||
int current_screen = getCurrentScreen();
|
||||
if (!extgl_InitGLX(env, disp, current_screen)) {
|
||||
if (!extgl_InitGLX(env, disp, current_screen) || !isPbuffersSupported()) {
|
||||
decDisplay();
|
||||
throwException(env, "Could not init GLX");
|
||||
throwException(env, "No Pbuffer support");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,15 @@ typedef struct _PbufferInfo {
|
|||
HDC Pbuffer_dc;
|
||||
} PbufferInfo;
|
||||
|
||||
static bool isPbuffersSupported() {
|
||||
return extgl_Extensions.WGL_ARB_pixel_format && extgl_Extensions.WGL_ARB_pbuffer;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getPbufferCapabilities
|
||||
(JNIEnv *env, jobject self)
|
||||
{
|
||||
int caps = 0;
|
||||
if ( extgl_Extensions.WGL_ARB_pixel_format && extgl_Extensions.WGL_ARB_pbuffer )
|
||||
if (isPbuffersSupported())
|
||||
caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED;
|
||||
|
||||
if (extgl_Extensions.WGL_ARB_render_texture)
|
||||
|
@ -110,11 +114,16 @@ static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pix
|
|||
return NULL;
|
||||
}
|
||||
extgl_InitWGL(env);
|
||||
|
||||
bool pbuffers_supported = isPbuffersSupported();
|
||||
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, false);
|
||||
if (iPixelFormat == -1)
|
||||
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true);
|
||||
wglDeleteContext(dummy_hglrc);
|
||||
if (!pbuffers_supported) {
|
||||
closeWindow(dummy_hwnd, dummy_hdc);
|
||||
throwException(env, "No Pbuffer support.");
|
||||
return NULL;
|
||||
}
|
||||
if (iPixelFormat == -1) {
|
||||
closeWindow(dummy_hwnd, dummy_hdc);
|
||||
throwException(env, "Could not find suitable pixel format.");
|
||||
|
|
Loading…
Reference in New Issue