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).
|
* with the Display context (if created).
|
||||||
*/
|
*/
|
||||||
public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture, Pbuffer shared_context) throws LWJGLException {
|
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.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.handle = createPbuffer(width, height, pixel_format, renderTexture, shared_context != null ? shared_context.handle : null);
|
this.handle = createPbuffer(width, height, pixel_format, renderTexture, shared_context != null ? shared_context.handle : null);
|
||||||
|
|
|
@ -51,11 +51,15 @@ typedef struct _PbufferInfo {
|
||||||
GLXContext context;
|
GLXContext context;
|
||||||
} PbufferInfo;
|
} 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
|
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
|
||||||
(JNIEnv *env, jobject this)
|
(JNIEnv *env, jobject this)
|
||||||
{
|
{
|
||||||
// Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension
|
return isPbuffersSupported() ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
|
||||||
return extgl_Extensions.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyPbuffer(PbufferInfo *buffer_info) {
|
static void destroyPbuffer(PbufferInfo *buffer_info) {
|
||||||
|
@ -127,9 +131,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreatePbuffer(JNIEnv
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int current_screen = getCurrentScreen();
|
int current_screen = getCurrentScreen();
|
||||||
if (!extgl_InitGLX(env, disp, current_screen)) {
|
if (!extgl_InitGLX(env, disp, current_screen) || !isPbuffersSupported()) {
|
||||||
decDisplay();
|
decDisplay();
|
||||||
throwException(env, "Could not init GLX");
|
throwException(env, "No Pbuffer support");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,20 +55,24 @@ typedef struct _PbufferInfo {
|
||||||
HDC Pbuffer_dc;
|
HDC Pbuffer_dc;
|
||||||
} PbufferInfo;
|
} 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
|
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Win32Display_getPbufferCapabilities
|
||||||
(JNIEnv *env, jobject self)
|
(JNIEnv *env, jobject self)
|
||||||
{
|
{
|
||||||
int caps = 0;
|
int caps = 0;
|
||||||
if ( extgl_Extensions.WGL_ARB_pixel_format && extgl_Extensions.WGL_ARB_pbuffer )
|
if (isPbuffersSupported())
|
||||||
caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED;
|
caps |= org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED;
|
||||||
|
|
||||||
if ( extgl_Extensions.WGL_ARB_render_texture )
|
if (extgl_Extensions.WGL_ARB_render_texture)
|
||||||
caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED;
|
caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_SUPPORTED;
|
||||||
|
|
||||||
if ( extgl_Extensions.WGL_NV_render_texture_rectangle )
|
if (extgl_Extensions.WGL_NV_render_texture_rectangle)
|
||||||
caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED;
|
caps |= org_lwjgl_opengl_Pbuffer_RENDER_TEXTURE_RECTANGLE_SUPPORTED;
|
||||||
|
|
||||||
if ( extgl_Extensions.WGL_NV_render_depth_texture )
|
if (extgl_Extensions.WGL_NV_render_depth_texture)
|
||||||
caps |= org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED;
|
caps |= org_lwjgl_opengl_Pbuffer_RENDER_DEPTH_TEXTURE_SUPPORTED;
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
|
@ -110,11 +114,16 @@ static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pix
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
extgl_InitWGL(env);
|
extgl_InitWGL(env);
|
||||||
|
bool pbuffers_supported = isPbuffersSupported();
|
||||||
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, false);
|
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, false);
|
||||||
if (iPixelFormat == -1)
|
if (iPixelFormat == -1)
|
||||||
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true);
|
iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true);
|
||||||
wglDeleteContext(dummy_hglrc);
|
wglDeleteContext(dummy_hglrc);
|
||||||
|
if (!pbuffers_supported) {
|
||||||
|
closeWindow(dummy_hwnd, dummy_hdc);
|
||||||
|
throwException(env, "No Pbuffer support.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (iPixelFormat == -1) {
|
if (iPixelFormat == -1) {
|
||||||
closeWindow(dummy_hwnd, dummy_hdc);
|
closeWindow(dummy_hwnd, dummy_hdc);
|
||||||
throwException(env, "Could not find suitable pixel format.");
|
throwException(env, "Could not find suitable pixel format.");
|
||||||
|
|
Loading…
Reference in New Issue