Windows: Simplify context creation and don't cache the extensions information struct in native code. Just reload it at each use (only at setSwapInterval currently).
This commit is contained in:
parent
0eb8a4ee4f
commit
d2e9a9fb4a
|
@ -43,7 +43,6 @@
|
||||||
#include "common_tools.h"
|
#include "common_tools.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WGLExtensions extensions;
|
|
||||||
HGLRC context;
|
HGLRC context;
|
||||||
} WindowsContext;
|
} WindowsContext;
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCr
|
||||||
HGLRC shared_context = NULL;
|
HGLRC shared_context = NULL;
|
||||||
HDC saved_hdc;
|
HDC saved_hdc;
|
||||||
HGLRC saved_context;
|
HGLRC saved_context;
|
||||||
WGLExtensions extensions;
|
|
||||||
jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext));
|
jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext));
|
||||||
if (context_handle == NULL) {
|
if (context_handle == NULL) {
|
||||||
throwException(env, "Could not create handle buffer");
|
throwException(env, "Could not create handle buffer");
|
||||||
|
@ -77,20 +75,8 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nCr
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saved_hdc = wglGetCurrentDC();
|
|
||||||
saved_context = wglGetCurrentContext();
|
|
||||||
if (!wglMakeCurrent(peer_info->drawable_hdc, context)) {
|
|
||||||
wglMakeCurrent(saved_hdc, saved_context);
|
|
||||||
wglDeleteContext(context);
|
|
||||||
throwException(env, "Could not make context current");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
extgl_InitWGL(&extensions);
|
|
||||||
if (!wglMakeCurrent(saved_hdc, saved_context))
|
|
||||||
printfDebugJava(env, "Failed to restore current context");
|
|
||||||
context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
|
context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
|
||||||
context_info->context = context;
|
context_info->context = context;
|
||||||
context_info->extensions = extensions;
|
|
||||||
return context_handle;
|
return context_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,9 +107,10 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nI
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval
|
||||||
(JNIEnv *env, jclass clazz, jobject context_handle, jint value) {
|
(JNIEnv *env, jclass clazz, jobject context_handle, jint value) {
|
||||||
WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
|
WGLExtensions extensions;
|
||||||
if (context_info->extensions.WGL_EXT_swap_control) {
|
extgl_InitWGL(&extensions);
|
||||||
context_info->extensions.wglSwapIntervalEXT(value);
|
if (extensions.WGL_EXT_swap_control) {
|
||||||
|
extensions.wglSwapIntervalEXT(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue