|
From: Elias N. <eli...@us...> - 2005-02-23 11:42:14
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26806/win32 Modified Files: Window.h org_lwjgl_opengl_Display.c org_lwjgl_opengl_Pbuffer.c Log Message: Clean out commented code Index: org_lwjgl_opengl_Pbuffer.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_opengl_Pbuffer.c 21 Feb 2005 14:46:47 -0000 1.10 +++ org_lwjgl_opengl_Pbuffer.c 23 Feb 2005 11:42:04 -0000 1.11 @@ -78,78 +78,6 @@ return caps; } -/*static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pixel_format, jobject pixelFormatCaps, const int *pBufferAttribs_ptr) { - HWND dummy_hwnd = createWindow(0, 0, 1, 1, false, false); - HDC dummy_hdc; - int iPixelFormat; - HGLRC dummy_hglrc; - BOOL result; - HPBUFFERARB Pbuffer; - bool pbuffers_supported; - - if (dummy_hwnd == NULL) { - throwException(env, "Could not create dummy window"); - return NULL; - } - dummy_hdc = GetDC(dummy_hwnd); - iPixelFormat = findPixelFormat(env, dummy_hdc, pixel_format); - if (iPixelFormat == -1) { - return NULL; - } - if (!applyPixelFormat(dummy_hdc, iPixelFormat)) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not apply pixel format to window"); - return NULL; - } - - dummy_hglrc = wglCreateContext(dummy_hdc); - if (dummy_hglrc == NULL) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Failed to create OpenGL rendering context"); - return NULL; - } - result = wglMakeCurrent(dummy_hdc, dummy_hglrc); - if (!result) { - wglDeleteContext(dummy_hglrc); - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not bind context to dummy window"); - return NULL; - } - extgl_InitWGL(env); - pbuffers_supported = isPbuffersSupported(); - iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, false); - if (iPixelFormat == -1) - iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, true); - wglDeleteContext(dummy_hglrc); - if (!pbuffers_supported) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "No Pbuffer support."); - return NULL; - } - if (iPixelFormat == -1) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not find suitable pixel format."); - return NULL; - } - Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribs_ptr); - closeWindow(&dummy_hwnd, &dummy_hdc); - return Pbuffer; -} - -static HGLRC createPbufferContext(JNIEnv *env, HDC Pbuffer_dc, HGLRC shared_context) { - HGLRC Pbuffer_context = wglCreateContext(Pbuffer_dc); - if (Pbuffer_context == NULL) { - throwException(env, "Failed to create Pbuffer rendering context"); - return NULL; - } - if (shared_context != NULL && !wglShareLists(shared_context, Pbuffer_context)) { - wglDeleteContext(Pbuffer_context); - throwException(env, "Could not share buffer context."); - return NULL; - } - return Pbuffer_context; -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nCreate (JNIEnv *env, jobject self, jobject peer_info_handle, jint width, jint height, jobject pixel_format, @@ -214,71 +142,6 @@ wglQueryPbufferARB(peer_info->pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); return buffer_lost ? JNI_TRUE : JNI_FALSE; } -/* HDC Pbuffer_dc; - HGLRC Pbuffer_context; - HGLRC shared_context; - PbufferInfo *Pbuffer_info; - if ((*env)->GetDirectBufferCapacity(env, buffer_handle) < sizeof(PbufferInfo)) { - throwException(env, "Buffer handle not large enough"); - return; - } - Pbuffer = createPbuffer(env, width, height, pixel_format, pixelFormatCaps, pBufferAttribs_ptr); - - if (Pbuffer == NULL) { - throwException(env, "Could not create Pbuffer."); - return; - } - - Pbuffer_dc = wglGetPbufferDCARB(Pbuffer); - if (Pbuffer_dc == NULL) { - wglDestroyPbufferARB(Pbuffer); - throwException(env, "Could not get Pbuffer dc."); - return; - } - shared_context = getCurrentContext(); - if (shared_context_handle_buffer != NULL) { - Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, shared_context_handle_buffer); - shared_context = Pbuffer_info->Pbuffer_context; - } - Pbuffer_context = createPbufferContext(env, Pbuffer_dc, shared_context); - if (Pbuffer_context == NULL) { - wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc); - wglDestroyPbufferARB(Pbuffer); - return; - } - Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - Pbuffer_info->Pbuffer = Pbuffer; - Pbuffer_info->Pbuffer_context = Pbuffer_context; - Pbuffer_info->Pbuffer_dc = Pbuffer_dc; -} - -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isBufferLost - (JNIEnv *env, jobject self, jobject buffer_handle) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - BOOL buffer_lost; - wglQueryPbufferARB(Pbuffer_info->Pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost); - return buffer_lost ? JNI_TRUE : JNI_FALSE; -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_makePbufferCurrent - (JNIEnv *env, jobject self, jobject buffer_handle) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); -// PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; - if (!wglMakeCurrent(Pbuffer_info->Pbuffer_dc, Pbuffer_info->Pbuffer_context)) - throwException(env, "Could not make pbuffer context current"); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyPbuffer - (JNIEnv *env, jobject self, jobject buffer_handle) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - wglDeleteContext(Pbuffer_info->Pbuffer_context); - wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc); - wglDestroyPbufferARB(Pbuffer_info->Pbuffer); -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32PbufferPeerInfo_nSetPbufferAttrib (JNIEnv *env, jclass clazz, jobject peer_info_handle, jint attrib, jint value) { @@ -303,31 +166,3 @@ Win32PeerInfo *peer_info = (Win32PeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); wglReleaseTexImageARB(peer_info->pbuffer, buffer); } -/* -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setPbufferAttrib - (JNIEnv *env, jobject self, jobject buffer_handle, jint attrib, jint value) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - - int attribs[3]; - - attribs[0] = attrib; - attribs[1] = value; - attribs[2] = 0; - - wglSetPbufferAttribARB(Pbuffer_info->Pbuffer, attribs); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_bindTexImageToPbuffer - (JNIEnv *env, jobject self, jobject buffer_handle, jint buffer) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - wglBindTexImageARB(Pbuffer_info->Pbuffer, buffer); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_releaseTexImageFromPbuffer - (JNIEnv *env, jobject self, jobject buffer_handle, jint buffer) -{ - PbufferInfo *Pbuffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, buffer_handle); - wglReleaseTexImageARB(Pbuffer_info->Pbuffer, buffer); -}*/ Index: org_lwjgl_opengl_Display.c =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- org_lwjgl_opengl_Display.c 21 Feb 2005 14:46:47 -0000 1.16 +++ org_lwjgl_opengl_Display.c 23 Feb 2005 11:42:04 -0000 1.17 @@ -51,7 +51,6 @@ static HWND display_hwnd = NULL; // Handle to the window static HDC display_hdc = NULL; // Device context -//static HGLRC display_hglrc = NULL; // OpenGL context static bool isFullScreen = false; // Whether we're fullscreen or not static bool isMinimized = false; // Whether we're minimized or not static bool isFocused = false; // whether we're focused or not @@ -61,24 +60,9 @@ // has recovered from minimized static bool closerequested; -//static int pixel_format_index; #define WINDOWCLASSNAME "LWJGL" -/*bool applyPixelFormat(HDC hdc, int iPixelFormat) { - PIXELFORMATDESCRIPTOR desc; - if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { - return false; - } - - // make that the pixel format of the device context - if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) { - return false; - } - return true; -} -*/ - HDC getCurrentHDC() { return display_hdc; } @@ -87,185 +71,6 @@ return display_hwnd; } -/*HGLRC getCurrentContext() { - return display_hglrc; -} - -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(env, pixel_format); - int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); - int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); - int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); - int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); - int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); - int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); - jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); - int iPixelFormat; - unsigned int num_formats_returned; - attrib_list_t attrib_list; - GLuint *pixelFormatCaps_ptr; - jlong pixelFormatCapsSize; - BOOL result; - jlong i; - - initAttribList(&attrib_list); - if (window) { - putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE); - } - if (pbuffer) { - putAttrib(&attrib_list, WGL_DRAW_TO_PBUFFER_ARB); putAttrib(&attrib_list, TRUE); - } - putAttrib(&attrib_list, WGL_ACCELERATION_ARB); putAttrib(&attrib_list, WGL_FULL_ACCELERATION_ARB); - putAttrib(&attrib_list, WGL_PIXEL_TYPE_ARB); putAttrib(&attrib_list, WGL_TYPE_RGBA_ARB); - putAttrib(&attrib_list, WGL_DOUBLE_BUFFER_ARB); putAttrib(&attrib_list, double_buffer ? TRUE : FALSE); - putAttrib(&attrib_list, WGL_SUPPORT_OPENGL_ARB); putAttrib(&attrib_list, TRUE); - putAttrib(&attrib_list, WGL_COLOR_BITS_ARB); putAttrib(&attrib_list, bpp); - putAttrib(&attrib_list, WGL_ALPHA_BITS_ARB); putAttrib(&attrib_list, alpha); - putAttrib(&attrib_list, WGL_DEPTH_BITS_ARB); putAttrib(&attrib_list, depth); - putAttrib(&attrib_list, WGL_STENCIL_BITS_ARB); putAttrib(&attrib_list, stencil); - if (samples > 0 && extension_flags.WGL_ARB_multisample) { - putAttrib(&attrib_list, WGL_SAMPLE_BUFFERS_ARB); putAttrib(&attrib_list, 1); - putAttrib(&attrib_list, WGL_SAMPLES_ARB); putAttrib(&attrib_list, samples); - } - putAttrib(&attrib_list, WGL_ACCUM_BITS_ARB); putAttrib(&attrib_list, accum_bpp); - putAttrib(&attrib_list, WGL_ACCUM_ALPHA_BITS_ARB); putAttrib(&attrib_list, accum_alpha); - putAttrib(&attrib_list, WGL_STEREO_ARB); putAttrib(&attrib_list, stereo ? TRUE : FALSE); - putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers); - if ( pixelFormatCaps != NULL ) { - if ( !extension_flags.WGL_ARB_render_texture ) { - return -1; - } - - pixelFormatCaps_ptr = (GLuint *)(*env)->GetDirectBufferAddress(env, pixelFormatCaps); - pixelFormatCapsSize = (*env)->GetDirectBufferCapacity(env, pixelFormatCaps); - - for (i = 0; i < pixelFormatCapsSize; i++) - putAttrib(&attrib_list, pixelFormatCaps_ptr[i]); - } - putAttrib(&attrib_list, 0); putAttrib(&attrib_list, 0); - result = wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned); - - if (result == FALSE || num_formats_returned < 1) { - return -1; - } - return iPixelFormat; -} - -int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { - int bpp; - int iPixelFormat; - jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - if (use_hdc_bpp) { - bpp = GetDeviceCaps(hdc, BITSPIXEL); - iPixelFormat = findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); - if (iPixelFormat == -1) - bpp = 16; - else - return iPixelFormat; - } else - bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "bpp", "I")); - return findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); -} -*/ -/* - * Find an appropriate pixel format - */ -/* -static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp) -{ - jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I")); - int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I")); - int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I")); - int samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I")); - int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I")); - int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I")); - jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z")); - unsigned int flags = PFD_DRAW_TO_WINDOW | // support window - PFD_SUPPORT_OPENGL | - PFD_DOUBLEBUFFER | - (stereo ? PFD_STEREO : 0); - PIXELFORMATDESCRIPTOR desc; - int iPixelFormat; - PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd - 1, // version number - flags, // RGBA type - PFD_TYPE_RGBA, - (BYTE)bpp, - 0, 0, 0, 0, 0, 0, // color bits ignored - (BYTE)alpha, - 0, // shift bit ignored - accum_bpp + accum_alpha, // no accumulation buffer - 0, 0, 0, 0, // accum bits ignored - (BYTE)depth, - (BYTE)stencil, - num_aux_buffers, - PFD_MAIN_PLANE, // main layer - 0, // reserved - 0, 0, 0 // layer masks ignored - }; - // get the best available match of pixel format for the device context - iPixelFormat = ChoosePixelFormat(hdc, &pfd); - if (iPixelFormat == 0) { - printfDebugJava(env, "Failed to choose pixel format"); - return -1; - } - - if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { - printfDebugJava(env, "Could not describe pixel format"); - return -1; - } - - if (desc.cColorBits < bpp) { - printfDebugJava(env, "Insufficient color precision"); - return -1; - } - - if (desc.cAlphaBits < alpha) { - printfDebugJava(env, "Insufficient alpha precision"); - return -1; - } - - if (desc.cStencilBits < stencil) { - printfDebugJava(env, "Insufficient stencil precision"); - return -1; - } - - if (desc.cDepthBits < depth) { - printfDebugJava(env, "Insufficient depth buffer precision"); - return -1; - } - - if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0 || (desc.dwFlags & PFD_GENERIC_ACCELERATED) != 0) { - jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL"); - // secondary check for software override - if(!allowSoftwareOpenGL) { - printfDebugJava(env, "Pixel format not accelerated"); - return -1; - } - } - - if ((desc.dwFlags & flags) != flags) { - printfDebugJava(env, "Capabilities not supported"); - return -1; - } - - return iPixelFormat; -} - -int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format) { - int bpp = GetDeviceCaps(hdc, BITSPIXEL); - int iPixelFormat; - iPixelFormat = findPixelFormatFromBPP(env, hdc, pixel_format, bpp); - if (iPixelFormat == -1) { - return findPixelFormatFromBPP(env, hdc, pixel_format, 16); - } else - return iPixelFormat; -} -*/ /* * Called when the application is alt-tabbed to or from */ @@ -408,36 +213,6 @@ } /* - * Register the LWJGL window class. - * Returns true for success, or false for failure - */ -/*static bool registerWindow() -{ - WNDCLASS windowClass; - if (!oneShotInitialised) { - windowClass.style = CS_OWNDC; - windowClass.lpfnWndProc = lwjglWindowProc; - windowClass.cbClsExtra = 0; - windowClass.cbWndExtra = 0; - windowClass.hInstance = dll_handle; - windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); - windowClass.hbrBackground = NULL; - windowClass.lpszMenuName = NULL; - windowClass.lpszClassName = WINDOWCLASSNAME; - - if (RegisterClass(&windowClass) == 0) { - printfDebug("Failed to register window class\n"); - return false; - } - printfDebug("Window registered\n"); - oneShotInitialised = true; - } - - return true; -} -*/ -/* * Handle native Win32 messages */ void handleMessages(void) @@ -473,11 +248,6 @@ free(title); } -/* - * Class: org_lwjgl_Window - * Method: update - * Signature: ()V - */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_nUpdate (JNIEnv * env, jobject self) { @@ -485,23 +255,6 @@ } -/* - * Class: org_lwjgl_Window - * Method: swapBuffers - * Signature: ()V - */ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_swapBuffers - (JNIEnv * env, jobject self) -{ - isDirty = false; - SwapBuffers(display_hdc); -} -*/ -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsDirty - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isDirty (JNIEnv *env, jobject self) { bool result = isDirty; @@ -509,21 +262,11 @@ return result ? JNI_TRUE : JNI_FALSE; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsVisible - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isVisible (JNIEnv *env, jobject self) { return isMinimized ? JNI_FALSE : JNI_TRUE; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsCloseRequested - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isCloseRequested (JNIEnv *env, jobject self) { bool saved = closerequested; @@ -531,41 +274,11 @@ return saved; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nIsActive - * Signature: ()Z - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Win32Display_isActive (JNIEnv *env, jobject self) { return isFocused; } -/* - * Class: org_lwjgl_opengl_Window - * Method: nSetVSyncEnabled - * Signature: (Z)Z - */ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setVSyncEnabled - (JNIEnv * env, jobject self, jboolean sync) -{ - if (extension_flags.WGL_EXT_swap_control) { - if (sync == JNI_TRUE) { - wglSwapIntervalEXT(1); - } else { - wglSwapIntervalEXT(0); - } - } -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_makeCurrent - (JNIEnv *env, jobject self) -{ - BOOL result = wglMakeCurrent(display_hdc, display_hglrc); - if (!result) - throwException(env, "Could not make display context current"); -} -*/ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_Win32Display_getAvailableDisplayModes(JNIEnv *env, jobject self) { return getAvailableDisplayModes(env); } @@ -598,12 +311,6 @@ return; } display_hdc = GetDC(display_hwnd); -/* if (!applyPixelFormat(display_hdc, pixel_format_index)) { - closeWindow(&display_hwnd, &display_hdc); - throwException(env, "Could not apply pixel format to window"); - return; - } -*/ ShowWindow(display_hwnd, SW_SHOWDEFAULT); UpdateWindow(display_hwnd); SetForegroundWindow(display_hwnd); @@ -642,119 +349,6 @@ return initDisplay(env); } -/*bool createARBContextAndPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format, int *pixel_format_index_return, HGLRC *context_return) { - int pixel_format_index; - HWND arb_hwnd; - HDC arb_hdc; - HGLRC arb_context; - - // Some crazy strangeness here so we can use ARB_pixel_format to specify the number - // of multisamples we want. If the extension is present we'll delete the existing - // rendering context and start over, using the ARB extension instead to pick the context. - if (!extension_flags.WGL_ARB_pixel_format) - return false; - pixel_format_index = findPixelFormatARB(env, hdc, pixel_format, NULL, true, true, true, true); - if (pixel_format_index == -1) { - pixel_format_index = findPixelFormatARB(env, hdc, pixel_format, NULL, true, true, false, true); - if ( pixel_format_index == -1) - return false; - } - - arb_hwnd = createWindow(0, 0, 1, 1, false, false); - if (arb_hwnd == NULL) - return false; - - arb_hdc = GetDC(arb_hwnd); - if (!applyPixelFormat(arb_hdc, pixel_format_index)) { - closeWindow(&arb_hwnd, &arb_hdc); - return false; - } - - arb_context = wglCreateContext(arb_hdc); - if (arb_context == NULL) { - closeWindow(&arb_hwnd, &arb_hdc); - return false; - } - if (!wglMakeCurrent(arb_hdc, arb_context)) { - wglDeleteContext(arb_context); - closeWindow(&arb_hwnd, &arb_hdc); - return false; - } - - extgl_InitWGL(env); - wglMakeCurrent(NULL, NULL); - closeWindow(&arb_hwnd, &arb_hdc); - *pixel_format_index_return = pixel_format_index; - *context_return = arb_context; - - return true; -} -*/ -/*JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createContext(JNIEnv *env, jobject self, jobject pixel_format) { - HWND dummy_hwnd; - HDC dummy_hdc; - BOOL result; - jclass cls_pixel_format; - int samples; - int pixel_format_index_arb; - HGLRC context_arb; - bool arb_success; - dummy_hwnd = createWindow(0, 0, 1, 1, false, false); - if (dummy_hwnd == NULL) { - throwException(env, "Failed to create the window."); - return; - } - dummy_hdc = GetDC(dummy_hwnd); - pixel_format_index = findPixelFormat(env, dummy_hdc, pixel_format); - if (pixel_format_index == -1) { - return; - } - if (!applyPixelFormat(dummy_hdc, pixel_format_index)) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Could not apply pixel format to window"); - return; - } - display_hglrc = wglCreateContext(dummy_hdc); - if (display_hglrc == NULL) { - closeWindow(&dummy_hwnd, &dummy_hdc); - throwException(env, "Failed to create OpenGL rendering context"); - return; - } - result = wglMakeCurrent(dummy_hdc, display_hglrc); - if (!result) { - throwException(env, "Could not bind context to dummy window"); - wglDeleteContext(display_hglrc); - closeWindow(&dummy_hwnd, &dummy_hdc); - return; - } - extgl_InitWGL(env); - cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); - samples = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "samples", "I")); - if (samples > 0) { - arb_success = createARBContextAndPixelFormat(env, dummy_hdc, pixel_format, &pixel_format_index_arb, &context_arb); - closeWindow(&dummy_hwnd, &dummy_hdc); - 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 - closeWindow(&dummy_hwnd, &dummy_hdc); -} - -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_destroyContext(JNIEnv *env, jobject self) { - wglMakeCurrent(NULL, NULL); - - // Delete the rendering context - if (display_hglrc != NULL) { - printfDebug("Deleting GL context\n"); - wglDeleteContext(display_hglrc); - display_hglrc = NULL; - } -} -*/ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_reshape(JNIEnv *env, jobject self, jint x, jint y, jint width, jint height) { int exstyle, windowflags; RECT clientSize; Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Window.h 21 Feb 2005 14:46:47 -0000 1.23 +++ Window.h 23 Feb 2005 11:42:04 -0000 1.24 @@ -64,12 +64,6 @@ WINDOW_H_API HDC getCurrentHDC(); -// WINDOW_H_API HGLRC getCurrentContext(); - -// WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat); - -// WINDOW_H_API void closeWindow(HWND *hwnd, HDC *hdc); - WINDOW_H_API void handleMouseMoved(int x, int y); WINDOW_H_API void handleMouseScrolled(int dwheel); @@ -79,17 +73,6 @@ WINDOW_H_API void handleMessages(void); /* - * Find a suitable pixel format - */ -// WINDOW_H_API int findPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format); - - /* - * Find a suitable pixel format using the WGL_ARB_pixel_format extension - */ -// WINDOW_H_API int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer); - - - /* * Handle native Win32 messages */ WINDOW_H_API void handleMessage(JNIEnv * env, jobject obj); |