Removed shared context ability from Pbuffer (win32)
This commit is contained in:
parent
6fb9a62cab
commit
250bbea979
|
@ -60,12 +60,8 @@
|
|||
|
||||
WINDOW_H_API HWND getCurrentHWND();
|
||||
|
||||
WINDOW_H_API HDC getCurrentWindowDC();
|
||||
|
||||
WINDOW_H_API HGLRC getCurrentContext();
|
||||
|
||||
WINDOW_H_API int getCurrentPixelFormat();
|
||||
|
||||
WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat);
|
||||
|
||||
WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc);
|
||||
|
|
|
@ -85,14 +85,6 @@ HGLRC getCurrentContext() {
|
|||
return display_hglrc;
|
||||
}
|
||||
|
||||
HDC getCurrentWindowDC() {
|
||||
return display_hdc;
|
||||
}
|
||||
|
||||
int getCurrentPixelFormat() {
|
||||
return pixel_format_index;
|
||||
}
|
||||
|
||||
static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool pbuffer, bool double_buffer) {
|
||||
jclass cls_pixel_format = env->GetObjectClass(pixel_format);
|
||||
int alpha = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "alpha", "I"));
|
||||
|
@ -708,20 +700,22 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_createContext(JNIEnv *env,
|
|||
return;
|
||||
}
|
||||
extgl_InitWGL(env);
|
||||
jclass cls_pixel_format = env->GetObjectClass(pixel_format);
|
||||
int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I"));
|
||||
if (samples > 0) {
|
||||
int pixel_format_index_arb;
|
||||
HGLRC context_arb;
|
||||
bool arb_success = createARBContextAndPixelFormat(env, dummy_hdc, pixel_format, &pixel_format_index_arb, &context_arb);
|
||||
closeWindow(dummy_hwnd, dummy_hdc);
|
||||
jclass cls_pixel_format = env->GetObjectClass(pixel_format);
|
||||
int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I"));
|
||||
if (arb_success) {
|
||||
wglDeleteContext(display_hglrc);
|
||||
if (!arb_success) {
|
||||
throwException(env, "Samples > 0 but could not find a suitable ARB pixel format");
|
||||
return;
|
||||
}
|
||||
display_hglrc = context_arb;
|
||||
pixel_format_index = pixel_format_index_arb;
|
||||
} else if (samples > 0) {
|
||||
wglDeleteContext(display_hglrc);
|
||||
throwException(env, "Samples > 0 but could not find a suitable ARB pixel format");
|
||||
}
|
||||
} else
|
||||
closeWindow(dummy_hwnd, dummy_hdc);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_destroyContext(JNIEnv *env, jclass clazz) {
|
||||
|
|
|
@ -52,7 +52,6 @@ typedef struct _PbufferInfo {
|
|||
HGLRC Pbuffer_context;
|
||||
HPBUFFERARB Pbuffer;
|
||||
HDC Pbuffer_dc;
|
||||
bool use_display_context;
|
||||
} PbufferInfo;
|
||||
|
||||
/*
|
||||
|
@ -140,7 +139,7 @@ static HGLRC createPbufferContext(JNIEnv *env, HDC Pbuffer_dc) {
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
||||
(JNIEnv *env, jclass clazz, jobject buffer_handle, jboolean use_display_context,
|
||||
(JNIEnv *env, jclass clazz, jobject buffer_handle,
|
||||
jint width, jint height, jobject pixel_format,
|
||||
jobject pixelFormatCaps, jobject pBufferAttribs)
|
||||
{
|
||||
|
@ -155,12 +154,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
|||
} else {
|
||||
pBufferAttribs_ptr = NULL;
|
||||
}
|
||||
if (use_display_context) {
|
||||
int iPixelFormat = getCurrentPixelFormat();
|
||||
Pbuffer = wglCreatePbufferARB(getCurrentWindowDC(), iPixelFormat, width, height, pBufferAttribs_ptr);
|
||||
} else {
|
||||
Pbuffer = createPbuffer(env, width, height, pixel_format, pixelFormatCaps, pBufferAttribs_ptr);
|
||||
}
|
||||
|
||||
if (Pbuffer == NULL) {
|
||||
throwException(env, "Could not create Pbuffer.");
|
||||
|
@ -174,22 +168,16 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
|||
return;
|
||||
}
|
||||
HGLRC Pbuffer_context;
|
||||
if (use_display_context) {
|
||||
Pbuffer_context = getCurrentContext();
|
||||
} else {
|
||||
Pbuffer_context = createPbufferContext(env, Pbuffer_dc);
|
||||
if (Pbuffer_context == NULL) {
|
||||
wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc);
|
||||
wglDestroyPbufferARB(Pbuffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle);
|
||||
Pbuffer_info->Pbuffer = Pbuffer;
|
||||
Pbuffer_info->Pbuffer_context = Pbuffer_context;
|
||||
Pbuffer_info->Pbuffer_dc = Pbuffer_dc;
|
||||
Pbuffer_info->use_display_context = use_display_context == JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost
|
||||
|
@ -214,7 +202,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy
|
|||
(JNIEnv *env, jclass clazz, jobject buffer_handle)
|
||||
{
|
||||
PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle);
|
||||
if (!Pbuffer_info->use_display_context)
|
||||
wglDeleteContext(Pbuffer_info->Pbuffer_context);
|
||||
wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc);
|
||||
wglDestroyPbufferARB(Pbuffer_info->Pbuffer);
|
||||
|
|
Loading…
Reference in New Issue