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 HWND getCurrentHWND();
|
||||||
|
|
||||||
WINDOW_H_API HDC getCurrentWindowDC();
|
|
||||||
|
|
||||||
WINDOW_H_API HGLRC getCurrentContext();
|
WINDOW_H_API HGLRC getCurrentContext();
|
||||||
|
|
||||||
WINDOW_H_API int getCurrentPixelFormat();
|
|
||||||
|
|
||||||
WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat);
|
WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat);
|
||||||
|
|
||||||
WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc);
|
WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc);
|
||||||
|
|
|
@ -85,14 +85,6 @@ HGLRC getCurrentContext() {
|
||||||
return display_hglrc;
|
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) {
|
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);
|
jclass cls_pixel_format = env->GetObjectClass(pixel_format);
|
||||||
int alpha = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "alpha", "I"));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
extgl_InitWGL(env);
|
extgl_InitWGL(env);
|
||||||
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);
|
jclass cls_pixel_format = env->GetObjectClass(pixel_format);
|
||||||
int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I"));
|
int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I"));
|
||||||
if (arb_success) {
|
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);
|
||||||
wglDeleteContext(display_hglrc);
|
wglDeleteContext(display_hglrc);
|
||||||
|
if (!arb_success) {
|
||||||
|
throwException(env, "Samples > 0 but could not find a suitable ARB pixel format");
|
||||||
|
return;
|
||||||
|
}
|
||||||
display_hglrc = context_arb;
|
display_hglrc = context_arb;
|
||||||
pixel_format_index = pixel_format_index_arb;
|
pixel_format_index = pixel_format_index_arb;
|
||||||
} else if (samples > 0) {
|
} else
|
||||||
wglDeleteContext(display_hglrc);
|
closeWindow(dummy_hwnd, dummy_hdc);
|
||||||
throwException(env, "Samples > 0 but could not find a suitable ARB pixel format");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_destroyContext(JNIEnv *env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_destroyContext(JNIEnv *env, jclass clazz) {
|
||||||
|
|
|
@ -52,7 +52,6 @@ typedef struct _PbufferInfo {
|
||||||
HGLRC Pbuffer_context;
|
HGLRC Pbuffer_context;
|
||||||
HPBUFFERARB Pbuffer;
|
HPBUFFERARB Pbuffer;
|
||||||
HDC Pbuffer_dc;
|
HDC Pbuffer_dc;
|
||||||
bool use_display_context;
|
|
||||||
} PbufferInfo;
|
} PbufferInfo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -140,7 +139,7 @@ static HGLRC createPbufferContext(JNIEnv *env, HDC Pbuffer_dc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
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,
|
jint width, jint height, jobject pixel_format,
|
||||||
jobject pixelFormatCaps, jobject pBufferAttribs)
|
jobject pixelFormatCaps, jobject pBufferAttribs)
|
||||||
{
|
{
|
||||||
|
@ -155,12 +154,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
||||||
} else {
|
} else {
|
||||||
pBufferAttribs_ptr = NULL;
|
pBufferAttribs_ptr = NULL;
|
||||||
}
|
}
|
||||||
if (use_display_context) {
|
Pbuffer = createPbuffer(env, width, height, pixel_format, pixelFormatCaps, pBufferAttribs_ptr);
|
||||||
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) {
|
if (Pbuffer == NULL) {
|
||||||
throwException(env, "Could not create Pbuffer.");
|
throwException(env, "Could not create Pbuffer.");
|
||||||
|
@ -174,22 +168,16 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HGLRC Pbuffer_context;
|
HGLRC Pbuffer_context;
|
||||||
if (use_display_context) {
|
Pbuffer_context = createPbufferContext(env, Pbuffer_dc);
|
||||||
Pbuffer_context = getCurrentContext();
|
if (Pbuffer_context == NULL) {
|
||||||
} else {
|
wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc);
|
||||||
Pbuffer_context = createPbufferContext(env, Pbuffer_dc);
|
wglDestroyPbufferARB(Pbuffer);
|
||||||
if (Pbuffer_context == NULL) {
|
return;
|
||||||
wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc);
|
|
||||||
wglDestroyPbufferARB(Pbuffer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle);
|
PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle);
|
||||||
Pbuffer_info->Pbuffer = Pbuffer;
|
Pbuffer_info->Pbuffer = Pbuffer;
|
||||||
Pbuffer_info->Pbuffer_context = Pbuffer_context;
|
Pbuffer_info->Pbuffer_context = Pbuffer_context;
|
||||||
Pbuffer_info->Pbuffer_dc = Pbuffer_dc;
|
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
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost
|
||||||
|
@ -214,8 +202,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy
|
||||||
(JNIEnv *env, jclass clazz, jobject buffer_handle)
|
(JNIEnv *env, jclass clazz, jobject buffer_handle)
|
||||||
{
|
{
|
||||||
PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle);
|
PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle);
|
||||||
if (!Pbuffer_info->use_display_context)
|
wglDeleteContext(Pbuffer_info->Pbuffer_context);
|
||||||
wglDeleteContext(Pbuffer_info->Pbuffer_context);
|
|
||||||
wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc);
|
wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc);
|
||||||
wglDestroyPbufferARB(Pbuffer_info->Pbuffer);
|
wglDestroyPbufferARB(Pbuffer_info->Pbuffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue