From: <eli...@us...> - 2006-12-22 10:36:06
|
Revision: 2704 http://svn.sourceforge.net/java-game-lib/?rev=2704&view=rev Author: elias_naur Date: 2006-12-22 02:36:04 -0800 (Fri, 22 Dec 2006) Log Message: ----------- 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). Modified Paths: -------------- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2006-12-21 08:11:29 UTC (rev 2703) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2006-12-22 10:36:04 UTC (rev 2704) @@ -43,7 +43,6 @@ #include "common_tools.h" typedef struct { - WGLExtensions extensions; HGLRC context; } WindowsContext; @@ -56,7 +55,6 @@ HGLRC shared_context = NULL; HDC saved_hdc; HGLRC saved_context; - WGLExtensions extensions; jobject context_handle = newJavaManagedByteBuffer(env, sizeof(WindowsContext)); if (context_handle == NULL) { throwException(env, "Could not create handle buffer"); @@ -77,20 +75,8 @@ 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->context = context; - context_info->extensions = extensions; return context_handle; } @@ -121,9 +107,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nSetSwapInterval (JNIEnv *env, jclass clazz, jobject context_handle, jint value) { - WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle); - if (context_info->extensions.WGL_EXT_swap_control) { - context_info->extensions.wglSwapIntervalEXT(value); + WGLExtensions extensions; + extgl_InitWGL(&extensions); + if (extensions.WGL_EXT_swap_control) { + extensions.wglSwapIntervalEXT(value); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |