From: <eli...@us...> - 2006-09-19 14:17:27
|
Revision: 2575 http://svn.sourceforge.net/java-game-lib/?rev=2575&view=rev Author: elias_naur Date: 2006-09-19 07:17:13 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Windows: Got rid of dummy window in WindowsDisplayPeerInfo Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java trunk/LWJGL/src/native/windows/context.h trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplayPeerInfo.java 2006-09-19 14:17:13 UTC (rev 2575) @@ -42,30 +42,19 @@ * $Id$ */ final class WindowsDisplayPeerInfo extends WindowsPeerInfo { + private final PixelFormat pixel_format; + public WindowsDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { + this.pixel_format = pixel_format; GLContext.loadOpenGLLibrary(); - try { - createDummyDC(getHandle()); - try { - choosePixelFormat(0, 0, pixel_format, null, true, true, false, true); - } catch (LWJGLException e) { - nDestroy(getHandle()); - throw e; - } - } catch (LWJGLException e) { - GLContext.unloadOpenGLLibrary(); - throw e; - } } - private static native void createDummyDC(ByteBuffer peer_info_handle) throws LWJGLException; - void initDC() { + void initDC() throws LWJGLException { nInitDC(getHandle()); + choosePixelFormat(0, 0, pixel_format, null, true, true, false, true); } private static native void nInitDC(ByteBuffer peer_info_handle); - private static native void nDestroy(ByteBuffer peer_info_handle); - protected void doLockAndInitHandle() throws LWJGLException { // NO-OP } @@ -76,7 +65,6 @@ public void destroy() { super.destroy(); - nDestroy(getHandle()); GLContext.unloadOpenGLLibrary(); } } Modified: trunk/LWJGL/src/native/windows/context.h =================================================================== --- trunk/LWJGL/src/native/windows/context.h 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/native/windows/context.h 2006-09-19 14:17:13 UTC (rev 2575) @@ -47,16 +47,12 @@ #include "extgl_wgl.h" typedef struct { - union { - HWND format_hwnd; - struct { - HPBUFFERARB pbuffer; - // Contains the function pointers that - // created the pbuffer - WGLExtensions extensions; - } pbuffer; - } u; - HDC format_hdc; + struct { + HPBUFFERARB pbuffer; + // Contains the function pointers that + // created the pbuffer + WGLExtensions extensions; + } pbuffer; HDC drawable_hdc; } WindowsPeerInfo; Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c 2006-09-19 14:17:13 UTC (rev 2575) @@ -165,24 +165,23 @@ throwException(env, "Could not get Pbuffer DC"); return; } - peer_info->format_hdc = Pbuffer_dc; - peer_info->u.pbuffer.extensions = extensions; - peer_info->u.pbuffer.pbuffer = Pbuffer; + peer_info->pbuffer.extensions = extensions; + peer_info->pbuffer.pbuffer = Pbuffer; peer_info->drawable_hdc = Pbuffer_dc; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->u.pbuffer.extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer.pbuffer, peer_info->drawable_hdc); - peer_info->u.pbuffer.extensions.wglDestroyPbufferARB(peer_info->u.pbuffer.pbuffer); + peer_info->pbuffer.extensions.wglReleasePbufferDCARB(peer_info->pbuffer.pbuffer, peer_info->drawable_hdc); + peer_info->pbuffer.extensions.wglDestroyPbufferARB(peer_info->pbuffer.pbuffer); } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); BOOL buffer_lost; - peer_info->u.pbuffer.extensions.wglQueryPbufferARB(peer_info->u.pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); + peer_info->pbuffer.extensions.wglQueryPbufferARB(peer_info->pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); return buffer_lost ? JNI_TRUE : JNI_FALSE; } @@ -195,17 +194,17 @@ attribs[1] = value; attribs[2] = 0; - peer_info->u.pbuffer.extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer.pbuffer, attribs); + peer_info->pbuffer.extensions.wglSetPbufferAttribARB(peer_info->pbuffer.pbuffer, attribs); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->u.pbuffer.extensions.wglBindTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); + peer_info->pbuffer.extensions.wglBindTexImageARB(peer_info->pbuffer.pbuffer, buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - peer_info->u.pbuffer.extensions.wglReleaseTexImageARB(peer_info->u.pbuffer.pbuffer, buffer); + peer_info->pbuffer.extensions.wglReleaseTexImageARB(peer_info->pbuffer.pbuffer, buffer); } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2006-09-19 14:17:13 UTC (rev 2575) @@ -50,7 +50,5 @@ WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); JAWT_Win32DrawingSurfaceInfo *win32_dsi = (JAWT_Win32DrawingSurfaceInfo *)surface->dsi->platformInfo; - peer_info->u.format_hwnd = win32_dsi->hwnd; - peer_info->format_hdc = win32_dsi->hdc; peer_info->drawable_hdc = win32_dsi->hdc; } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsContextImplementation.c 2006-09-19 14:17:13 UTC (rev 2575) @@ -63,7 +63,7 @@ return NULL; } peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - context = wglCreateContext(peer_info->format_hdc); + context = wglCreateContext(peer_info->drawable_hdc); if (context == NULL) { throwException(env, "Could not create context"); return NULL; @@ -79,7 +79,7 @@ } saved_hdc = wglGetCurrentDC(); saved_context = wglGetCurrentContext(); - if (!wglMakeCurrent(peer_info->format_hdc, context)) { + if (!wglMakeCurrent(peer_info->drawable_hdc, context)) { wglMakeCurrent(saved_hdc, saved_context); wglDeleteContext(context); throwException(env, "Could not make context current"); Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2006-09-19 14:17:13 UTC (rev 2575) @@ -43,36 +43,8 @@ #include "context.h" #include "common_tools.h" -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_createDummyDC - (JNIEnv *env, jclass clazz, jobject peer_info_handle) { - WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - HWND dummy_hwnd = createDummyWindow(0, 0); - HDC dummy_hdc; - if (dummy_hwnd == NULL) { - throwException(env, "Failed to create a dummy window."); - return; - } - dummy_hdc = GetDC(dummy_hwnd); - peer_info->u.format_hwnd = dummy_hwnd; - peer_info->format_hdc = dummy_hdc; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_nDestroy - (JNIEnv *env, jclass clazz, jobject peer_info_handle) { - WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - closeWindow(&peer_info->u.format_hwnd, &peer_info->format_hdc); -} - JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplayPeerInfo_nInitDC (JNIEnv *env, jclass clazz, jobject peer_info_handle) { WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); - int pixel_format; peer_info->drawable_hdc = getCurrentHDC(); - pixel_format = GetPixelFormat(peer_info->format_hdc); - if (pixel_format == 0) { - throwException(env, "Could not get pixel format from dummy hdc"); - return; - } - // If applyPixelFormat fails, just let it throw - applyPixelFormat(env, peer_info->drawable_hdc, pixel_format); } Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c =================================================================== --- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-09-19 13:41:18 UTC (rev 2574) +++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-09-19 14:17:13 UTC (rev 2575) @@ -56,5 +56,5 @@ if (pixel_format_id == -1) return; // Let it throw - applyPixelFormat(env, peer_info->format_hdc, pixel_format_id); + applyPixelFormat(env, peer_info->drawable_hdc, pixel_format_id); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |