You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
1
|
2
(10) |
3
(47) |
|
4
(12) |
5
(15) |
6
(14) |
7
(5) |
8
|
9
(1) |
10
|
|
11
(6) |
12
|
13
|
14
|
15
(3) |
16
(3) |
17
(5) |
|
18
|
19
(2) |
20
|
21
(11) |
22
(12) |
23
(5) |
24
(12) |
|
25
(6) |
26
(13) |
27
(2) |
28
(2) |
29
(9) |
30
(4) |
31
(2) |
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14967/src/native/win32 Modified Files: Window.h org_lwjgl_Sys.cpp org_lwjgl_input_Controller.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Display.cpp Log Message: Simplify Mouse cursor positions and replace display_hwnd global variable with getCurrentHWND() (Win32) Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- org_lwjgl_opengl_Display.cpp 24 Jul 2004 22:06:43 -0000 1.17 +++ org_lwjgl_opengl_Display.cpp 26 Jul 2004 17:01:56 -0000 1.18 @@ -49,7 +49,7 @@ static bool oneShotInitialised = false; // Registers the LWJGL window class -HWND display_hwnd = NULL; // Handle to the window +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 @@ -58,7 +58,6 @@ static bool isDirty = false; // Whether we're dirty or not static bool isUndecorated = false; // Whether we're undecorated or not extern HINSTANCE dll_handle; // Handle to the LWJGL dll -RECT clientSize; static bool closerequested; static int pixel_format_index; @@ -78,6 +77,10 @@ return true; } +HWND getCurrentHWND() { + return display_hwnd; +} + HGLRC getCurrentContext() { return display_hglrc; } @@ -440,6 +443,7 @@ // If we're not a fullscreen window, adjust the height to account for the // height of the title bar (unless undecorated) + RECT clientSize; clientSize.bottom = height; clientSize.left = 0; clientSize.right = width; @@ -573,43 +577,6 @@ throwException(env, "Could not make display context current"); } -/* -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nReshape - (JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) -{ - if (isFullScreen) { - return; - } - - int exstyle, windowflags; - - if (isUndecorated) { - exstyle = WS_EX_APPWINDOW; - windowflags = WS_OVERLAPPED; - } else { - exstyle = WS_EX_APPWINDOW; - windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU; - } - - // If we're not a fullscreen window, adjust the height to account for the - // height of the title bar: - clientSize.bottom = height; - clientSize.left = 0; - clientSize.right = width; - clientSize.top = 0; - - AdjustWindowRectEx( - &clientSize, // client-rectangle structure - windowflags, // window styles - FALSE, // menu-present option - exstyle // extended window style - ); - - SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, - clientSize.bottom - clientSize.top, SWP_NOZORDER); -} -*/ - JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_Display_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz) { return getAvailableDisplayModes(env); } Index: org_lwjgl_input_Controller.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Controller.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_input_Controller.cpp 6 Jul 2004 07:50:32 -0000 1.23 +++ org_lwjgl_input_Controller.cpp 26 Jul 2004 17:01:55 -0000 1.24 @@ -318,7 +318,7 @@ } // set the cooperative level - if(cDIDevice->SetCooperativeLevel(display_hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { + if(cDIDevice->SetCooperativeLevel(getCurrentHWND(), DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { printfDebug("SetCooperativeLevel failed\n"); cCreate_success = false; return; Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Window.h 24 Jul 2004 22:06:43 -0000 1.15 +++ Window.h 26 Jul 2004 17:01:54 -0000 1.16 @@ -52,15 +52,13 @@ #else #define WINDOW_H_API extern - extern HWND display_hwnd; // Handle to the window -// extern HDC display_hdc; // Device context extern bool isFullScreen; // Whether we're fullscreen or not extern bool isMinimized; // Whether we're minimized or not extern bool isFocused; // Whether we're focused or not extern bool isDirty; // Whether we're dirty or not - extern RECT clientSize; -// extern HGLRC display_hglrc; #endif /* _PRIVATE_WINDOW_H_ */ + + WINDOW_H_API HWND getCurrentHWND(); WINDOW_H_API HDC getCurrentWindowDC(); Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- org_lwjgl_input_Mouse.cpp 25 Jul 2004 14:51:28 -0000 1.58 +++ org_lwjgl_input_Mouse.cpp 26 Jul 2004 17:01:56 -0000 1.59 @@ -71,25 +71,29 @@ void InitializeMouseFields(); void UpdateMouseFields(JNIEnv *env, jclass clsMouse, jobject coord_buffer_obj, jobject button_buffer_obj); -static void getScreenClientRect(RECT* clientRect, RECT* windowRect) +/* Return the RECT of the current client area in the current window + * in screen coordinates + */ +static void getScreenClientRect(RECT* screen_client_rect) { - GetClientRect(display_hwnd, clientRect); - // transform clientRect to screen coordinates - clientRect->top = -clientSize.top + windowRect->top; - clientRect->left = -clientSize.left + windowRect->left; - clientRect->bottom += clientRect->top; - clientRect->right += clientRect->left; + /* We can't use GetClientRect directly, because it is in + * local window coordinates and we can't use GetWindowRect + * because it returns the screen coordinate RECT of the entire + * window, inluding decoration. Luckily, the WINDOWINFO structure contains + * the client rect in screen coordinates. + */ + WINDOWINFO window_info; + window_info.cbSize = sizeof(WINDOWINFO); + GetWindowInfo(getCurrentHWND(), &window_info); + *screen_client_rect = window_info.rcClient; } static void resetCursorPos(void) { /* Reset cursor position to middle of the window */ RECT clientRect; - GetWindowRect(display_hwnd, &windowRect); - getScreenClientRect(&clientRect, &windowRect); + getScreenClientRect(&clientRect); cursorPos.x = (clientRect.left + clientRect.right)/2; cursorPos.y = clientRect.bottom - 1 - (clientRect.bottom - clientRect.top)/2; -/* SetCursorPos(cursorPos.x, cursorPos.y); - GetCursorPos(&cursorPos);*/ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_input_Mouse_nHasWheel(JNIEnv *, jclass) { @@ -230,11 +234,10 @@ if (handle_buffer != NULL) { HCURSOR *cursor_handle = (HCURSOR *)env->GetDirectBufferAddress(handle_buffer); HCURSOR cursor = *cursor_handle; -// HCURSOR cursor = (HCURSOR)cursor_handle; - SetClassLong(display_hwnd, GCL_HCURSOR, (LONG)cursor); + SetClassLong(getCurrentHWND(), GCL_HCURSOR, (LONG)cursor); SetCursor(cursor); } else { - SetClassLong(display_hwnd, GCL_HCURSOR, (LONG)NULL); + SetClassLong(getCurrentHWND(), GCL_HCURSOR, (LONG)NULL); SetCursor(LoadCursor(NULL, IDC_ARROW)); } } @@ -279,7 +282,7 @@ resetCursorPos(); } mDIDevice->Unacquire(); - if(mDIDevice->SetCooperativeLevel(display_hwnd, mouseMask) != DI_OK) { + if(mDIDevice->SetCooperativeLevel(getCurrentHWND(), mouseMask) != DI_OK) { throwException(env, "Could not set the CooperativeLevel."); return; } @@ -375,7 +378,7 @@ mDIDevice->SetProperty(DIPROP_BUFFERSIZE, &dipropdw.diph); // set the cooperative level - if(mDIDevice->SetCooperativeLevel(display_hwnd, mouseMask) != DI_OK) { + if(mDIDevice->SetCooperativeLevel(getCurrentHWND(), mouseMask) != DI_OK) { printfDebug("SetCooperativeLevel failed\n"); mCreate_success = false; return; @@ -394,18 +397,18 @@ } static void getGDICursorDelta(int* return_dx, int* return_dy) { - int dx = 0; - int dy = 0; + int dx; + int dy; POINT newCursorPos; GetCursorPos(&newCursorPos); RECT clientRect; RECT newWindowRect; - GetWindowRect(display_hwnd, &newWindowRect); + GetWindowRect(getCurrentHWND(), &newWindowRect); cursorPos.x += newWindowRect.left - windowRect.left; cursorPos.y += newWindowRect.top - windowRect.top; windowRect = newWindowRect; - getScreenClientRect(&clientRect, &windowRect); + getScreenClientRect(&clientRect); // Clip the position to the client rect newCursorPos.x = cap(newCursorPos.x, clientRect.left, clientRect.right - 1); newCursorPos.y = cap(newCursorPos.y, clientRect.top, clientRect.bottom - 1); Index: org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- org_lwjgl_input_Keyboard.cpp 6 Jul 2004 07:50:32 -0000 1.34 +++ org_lwjgl_input_Keyboard.cpp 26 Jul 2004 17:01:56 -0000 1.35 @@ -81,18 +81,13 @@ return; } - if (display_hwnd == NULL) { - throwException(env, "No window."); - return; - } - // Create a keyboard device if (lpdi->CreateDevice(GUID_SysKeyboard, &lpdiKeyboard, NULL) != DI_OK) { throwException(env, "Failed to create keyboard."); return; } - if (lpdiKeyboard->SetCooperativeLevel(display_hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { + if (lpdiKeyboard->SetCooperativeLevel(getCurrentHWND(), DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DI_OK) { throwException(env, "Failed to set keyboard cooperation mode."); return; } Index: org_lwjgl_Sys.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_Sys.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- org_lwjgl_Sys.cpp 6 Jul 2004 07:50:32 -0000 1.27 +++ org_lwjgl_Sys.cpp 26 Jul 2004 17:01:55 -0000 1.28 @@ -123,7 +123,7 @@ jboolean copy = JNI_FALSE; const char * eMessageText = env->GetStringUTFChars(message, ©); const char * cTitleBarText = env->GetStringUTFChars(title, ©); - MessageBox(display_hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); + MessageBox(getCurrentHWND(), eMessageText, cTitleBarText, MB_OK | MB_TOPMOST); printfDebug("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText); |
|
From: Elias N. <eli...@us...> - 2004-07-26 14:50:45
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20039/src/java/org/lwjgl/opengl Modified Files: GLContext.java Log Message: GLContext now only loads native stubs of they're not already loaded Index: GLContext.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLContext.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- GLContext.java 24 Jul 2004 16:34:07 -0000 1.25 +++ GLContext.java 26 Jul 2004 14:50:33 -0000 1.26 @@ -185,6 +185,7 @@ private static Map exts; private static int gl_ref_count = 0; private static boolean did_auto_load = false; + private static boolean loaded_stubs = false; static { Sys.initialize(); @@ -250,7 +251,6 @@ did_auto_load = true; } try { - GL11.initNativeStubs(); loadStubs(); currentContext = new WeakReference(context); VBOTracker.setCurrent(context); @@ -340,7 +340,10 @@ } } - private static void loadStubs() { + private static void loadStubs() throws LWJGLException { + if (loaded_stubs) + return; + GL11.initNativeStubs(); exts = new HashMap(); Set exts_names = new HashSet(); getExtensionClassesAndNames(exts, exts_names); @@ -359,9 +362,13 @@ } } determineAvailableExtensions(exts_names); + loaded_stubs = true; } private static void unloadStubs() { + if (!loaded_stubs) + return; + loaded_stubs = false; Iterator exts_it = exts.keySet().iterator(); while (exts_it.hasNext()) { Class ext_class = (Class)exts_it.next(); |
|
From: Elias N. <eli...@us...> - 2004-07-26 14:42:24
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18724/src/native/linux Modified Files: org_lwjgl_opengl_Pbuffer.cpp Log Message: Linux part of letting Pbuffer fallback to double buffered formats Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- org_lwjgl_opengl_Pbuffer.cpp 26 Jul 2004 13:36:04 -0000 1.24 +++ org_lwjgl_opengl_Pbuffer.cpp 26 Jul 2004 14:42:13 -0000 1.25 @@ -101,8 +101,11 @@ static bool createPbufferUsingUniqueContext(JNIEnv *env, PbufferInfo *pbuffer_info, jobject pixel_format, int width, int height, const int *buffer_attribs) { GLXFBConfig *configs = chooseVisualGLX13(env, pixel_format, false, GLX_PBUFFER_BIT, false); if (configs == NULL) { - throwException(env, "No matching pixel format"); - return false; + GLXFBConfig *configs = chooseVisualGLX13(env, pixel_format, false, GLX_PBUFFER_BIT, true); + if (configs == NULL) { + throwException(env, "No matching pixel format"); + return false; + } } if (!checkPbufferCaps(env, configs[0], width, height)) { XFree(configs); @@ -186,10 +189,8 @@ return false; } GLXFBConfig config = chooseSingleBufferedConfigFromConfig(getCurrentGLXFBConfig()); - if (config == NULL) { - throwException(env, "Could not find a suitable GLXFBConfig"); - return false; - } + if (config == NULL) + config = getCurrentGLXFBConfig(); GLXPbuffer buffer = glXCreatePbuffer(getDisplay(), config, buffer_attribs); buffer_info->buffer = buffer; buffer_info->context = getCurrentGLXContext(); |
|
From: Elias N. <eli...@us...> - 2004-07-26 14:27:57
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15850/src/native/win32 Modified Files: org_lwjgl_opengl_Pbuffer.cpp Log Message: Win32 part of single-buffered Pbuffers Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- org_lwjgl_opengl_Pbuffer.cpp 25 Jul 2004 14:51:28 -0000 1.16 +++ org_lwjgl_opengl_Pbuffer.cpp 26 Jul 2004 14:27:34 -0000 1.17 @@ -112,6 +112,8 @@ extgl_InitWGL(env); 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 (iPixelFormat == -1) { closeWindow(dummy_hwnd, dummy_hdc); @@ -137,6 +139,54 @@ return Pbuffer_context; } +static bool formatMatches(HDC hdc, int pixel_format1, int pixel_format2, int attribute) { + int format_val1; + int format_val2; + if (wglGetPixelFormatAttribivARB(hdc, pixel_format1, 0, 1, &attribute, &format_val1) != TRUE) + return false; + if (wglGetPixelFormatAttribivARB(hdc, pixel_format2, 0, 1, &attribute, &format_val2) != TRUE) + return false; + return format_val1 == format_val2; +} + +static int chooseSingleBufferedFormatFromFormat(HDC hdc, int orig_pixel_format) { + int max_pixel_format_index = DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL); + for (int i = 1; i <= max_pixel_format_index; i++) { + int attribute = WGL_DOUBLE_BUFFER_ARB; + int double_buffer; + if (wglGetPixelFormatAttribivARB(hdc, i, 0, 1, &attribute, &double_buffer) != TRUE) { + return -1; + } + attribute = WGL_DRAW_TO_PBUFFER_ARB; + int draw_to_pbuffer; + if (wglGetPixelFormatAttribivARB(hdc, i, 0, 1, &attribute, &draw_to_pbuffer) != TRUE) { + return -1; + } + if (double_buffer != FALSE || draw_to_pbuffer != TRUE) + continue; + if (formatMatches(hdc, i, orig_pixel_format, WGL_RED_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_GREEN_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_BLUE_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_ALPHA_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_ACCUM_RED_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_ACCUM_GREEN_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_ACCUM_BLUE_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_ACCUM_ALPHA_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_DEPTH_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_STENCIL_BITS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_ACCELERATION_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_SUPPORT_OPENGL_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_STEREO_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_AUX_BUFFERS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_PIXEL_TYPE_ARB) && + (!extgl_Extensions.WGL_ARB_multisample || (formatMatches(hdc, i, orig_pixel_format, WGL_SAMPLE_BUFFERS_ARB) && + formatMatches(hdc, i, orig_pixel_format, WGL_SAMPLES_ARB)))) { + return i; + } + } + return -1; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate (JNIEnv *env, jclass clazz, jobject buffer_handle, jboolean use_display_context, jint width, jint height, jobject pixel_format, @@ -154,7 +204,9 @@ pBufferAttribs_ptr = NULL; } if (use_display_context) { - int iPixelFormat = getCurrentPixelFormat(); + int iPixelFormat = chooseSingleBufferedFormatFromFormat(getCurrentWindowDC(), getCurrentPixelFormat()); + if (iPixelFormat == -1) + iPixelFormat = getCurrentPixelFormat(); Pbuffer = wglCreatePbufferARB(getCurrentWindowDC(), iPixelFormat, width, height, pBufferAttribs_ptr); } else { Pbuffer = createPbuffer(env, width, height, pixel_format, pixelFormatCaps, pBufferAttribs_ptr); |
|
From: Elias N. <eli...@us...> - 2004-07-26 14:27:44
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15850/src/java/org/lwjgl/opengl Modified Files: Pbuffer.java Log Message: Win32 part of single-buffered Pbuffers Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Pbuffer.java 26 Jul 2004 13:36:04 -0000 1.27 +++ Pbuffer.java 26 Jul 2004 14:27:34 -0000 1.28 @@ -175,7 +175,7 @@ } /** - * Create an instance of a Pbuffer using the Display context. The buffer is single-buffered, unlike the Display. + * Create an instance of a Pbuffer using the Display context. The buffer is single-buffered if possible. * <p/> * NOTE: The Pbuffer will use the same context as the Display and requires that the Display has been created. Therefore, * no separate pixel format can be specified. All OpenGL state, @@ -195,7 +195,7 @@ } /** - * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered. + * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered if possible. * <p/> * NOTE: The Pbuffer will have its own context that shares display lists and textures with the Display context (if it is created), * but it will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa. |
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6148/src/java/org/lwjgl/opengl Modified Files: ARBBufferObject.java ARBImaging.java ARBMatrixPalette.java ARBOcclusionQuery.java ARBProgram.java ARBShaderObjects.java ARBTextureCompression.java ARBVertexBlend.java ARBVertexShader.java ARBWindowPos.java ATIDrawBuffers.java ATIElementArray.java ATIVertexArrayObject.java BufferChecks.java EXTDrawRangeElements.java EXTFogCoord.java EXTMultiDrawArrays.java EXTPointParameters.java EXTSecondaryColor.java EXTVertexShader.java EXTVertexWeighting.java GL11.java GL12.java GL13.java GL14.java GL15.java NVEvaluators.java NVFence.java NVFragmentProgram.java NVHalfFloat.java NVOcclusionQuery.java NVPixelDataRange.java NVProgram.java NVVertexArrayRange.java NVVertexProgram.java Pbuffer.java Log Message: Make Pbuffers that share the display context be single-buffered (linux part) Index: NVOcclusionQuery.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVOcclusionQuery.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NVOcclusionQuery.java 4 Jul 2004 13:14:05 -0000 1.6 +++ NVOcclusionQuery.java 26 Jul 2004 13:36:04 -0000 1.7 @@ -47,10 +47,12 @@ static native void initNativeStubs() throws LWJGLException; public static void glGenOcclusionQueriesNV(IntBuffer piIDs) { + BufferChecks.checkDirect(piIDs); nglGenOcclusionQueriesNV(piIDs.remaining(), piIDs, piIDs.position()); } private static native void nglGenOcclusionQueriesNV(int n, IntBuffer piIDs, int piIDs_offset); public static void glDeleteOcclusionQueriesNV(IntBuffer piIDs) { + BufferChecks.checkDirect(piIDs); nglDeleteOcclusionQueriesNV(piIDs.remaining(), piIDs, piIDs.position()); } private static native void nglDeleteOcclusionQueriesNV(int n, IntBuffer piIDs, int piIDs_offset); Index: EXTFogCoord.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/EXTFogCoord.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- EXTFogCoord.java 4 Jul 2004 13:14:05 -0000 1.7 +++ EXTFogCoord.java 26 Jul 2004 13:36:03 -0000 1.8 @@ -51,6 +51,7 @@ public static native void glFogCoordfEXT(float coord); public static void glFogCoordPointerEXT(int stride, FloatBuffer data) { + BufferChecks.checkDirect(data); BufferChecks.ensureArrayVBOdisabled(); nglFogCoordPointerEXT(GL11.GL_FLOAT, stride, data, data.position() << 2); } Index: EXTVertexShader.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/EXTVertexShader.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- EXTVertexShader.java 4 Jul 2004 13:14:05 -0000 1.7 +++ EXTVertexShader.java 26 Jul 2004 13:36:03 -0000 1.8 @@ -210,6 +210,7 @@ nglSetInvariantEXT(id, GL11.GL_FLOAT, pAddr, pAddr.position()<<2); } public static void glSetInvariantEXT(int id, boolean unsigned, IntBuffer pAddr) { + BufferChecks.checkBuffer(pAddr); nglSetInvariantEXT(id, unsigned ? GL11.GL_UNSIGNED_INT : GL11.GL_INT, pAddr, pAddr.position()<<2); } private static native void nglSetInvariantEXT(int id, int type, Buffer pAddr, int pAddr_offset); @@ -274,18 +275,22 @@ } private static native void nglVariantuivEXT(int id, IntBuffer piAddr, int piAddr_offset); public static void glVariantPointerEXT(int id, boolean unsigned, int stride, ByteBuffer pAddr) { + BufferChecks.checkDirect(pAddr); BufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, stride, pAddr, pAddr.position()); } public static void glVariantPointerEXT(int id, boolean unsigned, int stride, ShortBuffer pAddr) { + BufferChecks.checkDirect(pAddr); BufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, unsigned ? GL11.GL_UNSIGNED_SHORT : GL11.GL_SHORT, stride, pAddr, pAddr.position()<<1); } public static void glVariantPointerEXT(int id, int stride, FloatBuffer pAddr) { + BufferChecks.checkDirect(pAddr); BufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, GL11.GL_FLOAT, stride, pAddr, pAddr.position()<<2); } public static void glVariantPointerEXT(int id, boolean unsigned, int stride, IntBuffer pAddr) { + BufferChecks.checkDirect(pAddr); BufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, unsigned ? GL11.GL_UNSIGNED_INT : GL11.GL_INT, stride, pAddr, pAddr.position()<<2); } @@ -311,46 +316,55 @@ public static native boolean glIsVariantEnabledEXT(int id, int cap); public static void glGetVariantBooleanEXT(int id, int value, ByteBuffer pbData) { + BufferChecks.checkDirect(pbData); nglGetVariantBooleanvEXT(id, value, pbData, pbData.position()); } private static native void nglGetVariantBooleanvEXT(int id, int value, ByteBuffer pbData, int pbData_offset); public static void glGetVariantIntegerEXT(int id, int value, IntBuffer piData) { + BufferChecks.checkDirect(piData); nglGetVariantIntegervEXT(id, value, piData, piData.position()); } private static native void nglGetVariantIntegervEXT(int id, int value, IntBuffer piData, int piData_offset); public static void glGetVariantFloatEXT(int id, int value, FloatBuffer pfData) { + BufferChecks.checkDirect(pfData); nglGetVariantFloatvEXT(id, value, pfData, pfData.position()); } private static native void nglGetVariantFloatvEXT(int id, int value, FloatBuffer pfData, int pfData_offset); public static native ByteBuffer glGetVariantPointerEXT(int id, int value, int size); public static void glGetInvariantBooleanEXT(int id, int value, ByteBuffer pbData) { + BufferChecks.checkDirect(pbData); nglGetInvariantBooleanvEXT(id, value, pbData, pbData.position()); } private static native void nglGetInvariantBooleanvEXT(int id, int value, ByteBuffer pbData, int pbData_offset); public static void glGetInvariantIntegerEXT(int id, int value, IntBuffer piData) { + BufferChecks.checkDirect(piData); nglGetInvariantIntegervEXT(id, value, piData, piData.position()); } private static native void nglGetInvariantIntegervEXT(int id, int value, IntBuffer piData, int piData_offset); public static void glGetInvariantFloatEXT(int id, int value, FloatBuffer pfData) { + BufferChecks.checkDirect(pfData); nglGetInvariantFloatvEXT(id, value, pfData, pfData.position()); } private static native void nglGetInvariantFloatvEXT(int id, int value, FloatBuffer pfData, int pfData_offset); public static void glGetLocalConstantBooleanEXT(int id, int value, ByteBuffer pbData) { + BufferChecks.checkDirect(pbData); nglGetLocalConstantBooleanvEXT(id, value, pbData, pbData.position()); } private static native void nglGetLocalConstantBooleanvEXT(int id, int value, ByteBuffer pbData, int pbData_offset); public static void glGetLocalConstantIntegerEXT(int id, int value, IntBuffer piData) { + BufferChecks.checkDirect(piData); nglGetLocalConstantIntegervEXT(id, value, piData, piData.position()); } private static native void nglGetLocalConstantIntegervEXT(int id, int value, IntBuffer piData, int piData_offset); public static void glGetLocalConstantFloatEXT(int id, int value, FloatBuffer pfData) { + BufferChecks.checkDirect(pfData); nglGetLocalConstantFloatvEXT(id, value, pfData, pfData.position()); } private static native void nglGetLocalConstantFloatvEXT(int id, int value, FloatBuffer pfData, int pfData_offset); Index: ATIVertexArrayObject.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ATIVertexArrayObject.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ATIVertexArrayObject.java 4 Jul 2004 13:14:05 -0000 1.6 +++ ATIVertexArrayObject.java 26 Jul 2004 13:36:02 -0000 1.7 @@ -52,40 +52,50 @@ static native void initNativeStubs() throws LWJGLException; public static int glNewObjectBufferATI(int size, ByteBuffer pPointer, int usage) { - return nglNewObjectBufferATI(size, pPointer, pPointer != null ? pPointer.position() : 0, usage); + BufferChecks.checkDirectOrNull(pPointer); + return nglNewObjectBufferATI(pPointer != null ? pPointer.remaining() : size, pPointer, pPointer != null ? pPointer.position() : 0, usage); } public static int glNewObjectBufferATI(int size, ShortBuffer pPointer, int usage) { - return nglNewObjectBufferATI(size, pPointer, pPointer != null ? pPointer.position()<<1 : 0, usage); + BufferChecks.checkDirectOrNull(pPointer); + return nglNewObjectBufferATI(pPointer != null ? pPointer.remaining()<<1 : size, pPointer, pPointer != null ? pPointer.position()<<1 : 0, usage); } public static int glNewObjectBufferATI(int size, FloatBuffer pPointer, int usage) { - return nglNewObjectBufferATI(size, pPointer, pPointer != null ? pPointer.position()<<2 : 0, usage); + BufferChecks.checkDirectOrNull(pPointer); + return nglNewObjectBufferATI(pPointer != null ? pPointer.remaining()<<2 : size, pPointer, pPointer != null ? pPointer.position()<<2 : 0, usage); } public static int glNewObjectBufferATI(int size, IntBuffer pPointer, int usage) { - return nglNewObjectBufferATI(size, pPointer, pPointer != null ? pPointer.position()<<2 : 0, usage); + BufferChecks.checkDirectOrNull(pPointer); + return nglNewObjectBufferATI(pPointer != null ? pPointer.remaining()<<2 : size, pPointer, pPointer != null ? pPointer.position()<<2 : 0, usage); } private static native int nglNewObjectBufferATI(int size, Buffer pPointer, int pPointer_offset, int usage); public static native boolean glIsObjectBufferATI(int buffer); public static void glUpdateObjectBufferATI(int buffer, int offset, ByteBuffer pPointer, int preserve) { + BufferChecks.checkDirect(pPointer); nglUpdateObjectBufferATI(buffer, offset, pPointer.remaining(), pPointer, pPointer.position(), preserve); } public static void glUpdateObjectBufferATI(int buffer, int offset, ShortBuffer pPointer, int preserve) { + BufferChecks.checkDirect(pPointer); nglUpdateObjectBufferATI(buffer, offset, pPointer.remaining()<<1, pPointer, pPointer.position()<<1, preserve); } public static void glUpdateObjectBufferATI(int buffer, int offset, FloatBuffer pPointer, int preserve) { + BufferChecks.checkDirect(pPointer); nglUpdateObjectBufferATI(buffer, offset, pPointer.remaining()<<2, pPointer, pPointer.position()<<2, preserve); } public static void glUpdateObjectBufferATI(int buffer, int offset, IntBuffer pPointer, int preserve) { + BufferChecks.checkDirect(pPointer); nglUpdateObjectBufferATI(buffer, offset, pPointer.remaining()<<2, pPointer, pPointer.position()<<2, preserve); } private static native void nglUpdateObjectBufferATI(int buffer, int offset, int size, Buffer pPointer, int pPointer_offset, int preserve); public static void glGetObjectBufferATI(int buffer, int pname, FloatBuffer pfParams) { + BufferChecks.checkDirect(pfParams); nglGetObjectBufferfvATI(buffer, pname, pfParams, pfParams.position()); } private static native void nglGetObjectBufferfvATI(int buffer, int pname, FloatBuffer pfParams, int pfParams_offset); public static void glGetObjectBufferATI(int buffer, int pname, IntBuffer piParams) { + BufferChecks.checkDirect(piParams); nglGetObjectBufferivATI(buffer, pname, piParams, piParams.position()); } private static native void nglGetObjectBufferivATI(int buffer, int pname, IntBuffer piParams, int piParams_offset); Index: ARBOcclusionQuery.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBOcclusionQuery.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ARBOcclusionQuery.java 4 Jul 2004 13:14:05 -0000 1.7 +++ ARBOcclusionQuery.java 26 Jul 2004 13:35:59 -0000 1.8 @@ -60,6 +60,7 @@ // --------------------------- public static void glGenQueriesARB(IntBuffer ids) { + BufferChecks.checkDirect(ids); nglGenQueriesARB(ids.remaining(), ids, ids.position()); } @@ -68,6 +69,7 @@ // --------------------------- public static void glDeleteQueriesARB(IntBuffer ids) { + BufferChecks.checkDirect(ids); nglDeleteQueriesARB(ids.remaining(), ids, ids.position()); } Index: GL14.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GL14.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- GL14.java 4 Jul 2004 13:14:05 -0000 1.10 +++ GL14.java 26 Jul 2004 13:36:03 -0000 1.11 @@ -89,10 +89,11 @@ static native void initNativeStubs() throws LWJGLException; - public static native void glBlendEquation(int mode); - public static native void glBlendColor(float red, float green, float blue, float alpha); + public static native void glBlendEquation(int mode); + public static native void glBlendColor(float red, float green, float blue, float alpha); public static native void glFogCoordf(float coord); public static void glFogCoordPointer(int stride, FloatBuffer data) { + BufferChecks.checkDirect(data); BufferChecks.ensureArrayVBOdisabled(); nglFogCoordPointer(GL11.GL_FLOAT, stride, data, data.position() << 2); } @@ -103,6 +104,8 @@ } private static native void nglFogCoordPointerVBO(int type, int stride, int buffer_offset); public static void glMultiDrawArrays(int mode, IntBuffer piFirst, IntBuffer piCount) { + BufferChecks.checkDirect(piFirst); + BufferChecks.checkDirect(piCount); if (piFirst.remaining() != piCount.remaining()) { throw new IllegalArgumentException("piFirst.remaining() != piCount.remaining()"); } @@ -120,10 +123,12 @@ public static native void glSecondaryColor3f (float red, float green, float blue); public static native void glSecondaryColor3ub (byte red, byte green, byte blue); public static void glSecondaryColorPointer(int size, boolean unsigned, int stride, ByteBuffer data) { + BufferChecks.checkDirect(data); BufferChecks.ensureArrayVBOdisabled(); nglSecondaryColorPointer(size, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, stride, data, data.position()); } public static void glSecondaryColorPointer(int size, int stride, FloatBuffer data) { + BufferChecks.checkDirect(data); BufferChecks.ensureArrayVBOdisabled(); nglSecondaryColorPointer(size, GL11.GL_FLOAT, stride, data, data.position() << 2); } Index: NVFragmentProgram.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVFragmentProgram.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- NVFragmentProgram.java 4 Jul 2004 13:14:05 -0000 1.9 +++ NVFragmentProgram.java 26 Jul 2004 13:36:03 -0000 1.10 @@ -62,6 +62,7 @@ // --------------------------- public static void glProgramNamedParameter4fNV(int id, ByteBuffer name, float x, float y, float z, float w) { + BufferChecks.checkDirect(name); nglProgramNamedParameter4fNV(id, name.remaining(), name, name.position(), x, y, z, w); } @@ -80,6 +81,7 @@ // --------------------------- public static void glGetProgramNamedParameterNV(int id, ByteBuffer name, FloatBuffer params) { + BufferChecks.checkDirect(name); BufferChecks.checkBuffer(params); nglGetProgramNamedParameterfvNV(id, name.remaining(), name, name.position(), params, params.position()); } Index: ARBBufferObject.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBBufferObject.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ARBBufferObject.java 4 Jul 2004 13:14:05 -0000 1.5 +++ ARBBufferObject.java 26 Jul 2004 13:35:59 -0000 1.6 @@ -93,50 +93,64 @@ if (VBOTracker.getVBOArrayStack().getState() == buffer_handle) VBOTracker.getVBOArrayStack().setState(0); } + BufferChecks.checkDirect(buffers); nglDeleteBuffersARB(buffers.remaining(), buffers, buffers.position()); } private static native void nglDeleteBuffersARB(int n, IntBuffer buffers, int buffers_offset); public static void glGenBuffersARB(IntBuffer buffers) { + BufferChecks.checkDirect(buffers); nglGenBuffersARB(buffers.remaining(), buffers, buffers.position()); } private static native void nglGenBuffersARB(int n, IntBuffer buffers, int buffers_offset); public static native boolean glIsBufferARB(int buffer); public static void glBufferDataARB(int target, int size, ByteBuffer data, int usage) { - nglBufferDataARB(target, size, data, data != null ? data.position() : 0, usage); + BufferChecks.checkDirectOrNull(data); + nglBufferDataARB(target, data != null ? data.remaining() : size, data, data != null ? data.position() : 0, usage); } public static void glBufferDataARB(int target, int size, ShortBuffer data, int usage) { - nglBufferDataARB(target, size, data, data != null ? data.position()<<1 : 0, usage); + BufferChecks.checkDirectOrNull(data); + nglBufferDataARB(target, data != null ? data.remaining()<<1 : size, data, data != null ? data.position()<<1 : 0, usage); } public static void glBufferDataARB(int target, int size, FloatBuffer data, int usage) { - nglBufferDataARB(target, size, data, data != null ? data.position()<<2 : 0, usage); + BufferChecks.checkDirectOrNull(data); + nglBufferDataARB(target, data != null ? data.remaining()<<2 : size, data, data != null ? data.position()<<2 : 0, usage); } public static void glBufferDataARB(int target, int size, IntBuffer data, int usage) { - nglBufferDataARB(target, size, data, data != null ? data.position()<<2 : 0, usage); + BufferChecks.checkDirectOrNull(data); + nglBufferDataARB(target, data != null ? data.remaining()<<2 : size, data, data != null ? data.position()<<2 : 0, usage); } private static native void nglBufferDataARB(int target, int size, Buffer data, int data_offset, int usage); public static void glBufferSubDataARB(int target, int offset, ByteBuffer data) { + BufferChecks.checkDirect(data); nglBufferSubDataARB(target, offset, data.remaining(), data, data.position()); } public static void glBufferSubDataARB(int target, int offset, ShortBuffer data) { + BufferChecks.checkDirect(data); nglBufferSubDataARB(target, offset, data.remaining()<<1, data, data.position()<<1); } public static void glBufferSubDataARB(int target, int offset, FloatBuffer data) { + BufferChecks.checkDirect(data); nglBufferSubDataARB(target, offset, data.remaining()<<2, data, data.position()<<2); } public static void glBufferSubDataARB(int target, int offset, IntBuffer data) { + BufferChecks.checkDirect(data); nglBufferSubDataARB(target, offset, data.remaining()<<2, data, data.position()<<2); } private static native void nglBufferSubDataARB(int target, int offset, int size, Buffer data, int data_offset); public static void glGetBufferSubDataARB(int target, int offset, ByteBuffer data) { + BufferChecks.checkDirect(data); nglGetBufferSubDataARB(target, offset, data.remaining(), data, data.position()); } public static void glGetBufferSubDataARB(int target, int offset, ShortBuffer data) { + BufferChecks.checkDirect(data); nglGetBufferSubDataARB(target, offset, data.remaining()<<1, data, data.position()<<1); } public static void glGetBufferSubDataARB(int target, int offset, IntBuffer data) { + BufferChecks.checkDirect(data); nglGetBufferSubDataARB(target, offset, data.remaining()<<2, data, data.position()<<2); } public static void glGetBufferSubDataARB(int target, int offset, FloatBuffer data) { + BufferChecks.checkDirect(data); nglGetBufferSubDataARB(target, offset, data.remaining()<<2, data, data.position()<<2); } private static native void nglGetBufferSubDataARB(int target, int offset, int size, Buffer data, int data_offset); Index: NVFence.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVFence.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NVFence.java 4 Jul 2004 13:14:05 -0000 1.6 +++ NVFence.java 26 Jul 2004 13:36:03 -0000 1.7 @@ -43,10 +43,12 @@ static native void initNativeStubs() throws LWJGLException; public static void glGenFencesNV(IntBuffer piFences) { + BufferChecks.checkDirect(piFences); nglGenFencesNV(piFences.remaining(), piFences, piFences.position()); } private static native void nglGenFencesNV(int n, IntBuffer piFences, int piFences_offset); public static void glDeleteFencesNV(IntBuffer piFences) { + BufferChecks.checkDirect(piFences); nglDeleteFencesNV(piFences.remaining(), piFences, piFences.position()); } private static native void nglDeleteFencesNV(int n, IntBuffer piFences, int piFences_offset); Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Pbuffer.java 25 Jul 2004 14:28:49 -0000 1.26 +++ Pbuffer.java 26 Jul 2004 13:36:04 -0000 1.27 @@ -175,7 +175,7 @@ } /** - * Create an instance of a Pbuffer using the Display context. The buffer is double-buffered, like the Display. + * Create an instance of a Pbuffer using the Display context. The buffer is single-buffered, unlike the Display. * <p/> * NOTE: The Pbuffer will use the same context as the Display and requires that the Display has been created. Therefore, * no separate pixel format can be specified. All OpenGL state, Index: NVVertexArrayRange.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVVertexArrayRange.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- NVVertexArrayRange.java 4 Jul 2004 13:14:05 -0000 1.5 +++ NVVertexArrayRange.java 26 Jul 2004 13:36:04 -0000 1.6 @@ -46,6 +46,7 @@ static native void initNativeStubs() throws LWJGLException; public static void glVertexArrayRangeNV(ByteBuffer pPointer) { + BufferChecks.checkDirect(pPointer); nglVertexArrayRangeNV(pPointer.remaining(), pPointer, pPointer.position()); } private static native void nglVertexArrayRangeNV(int size, Buffer pPointer, int pPointer_offset); Index: ATIDrawBuffers.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ATIDrawBuffers.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ATIDrawBuffers.java 4 Jul 2004 13:14:05 -0000 1.7 +++ ATIDrawBuffers.java 26 Jul 2004 13:36:02 -0000 1.8 @@ -64,9 +64,7 @@ // --------------------------- public static void glDrawBuffersATI(IntBuffer buffers) { - if (buffers.remaining() == 0) { - throw new IllegalArgumentException("<buffers> must have at least 1 integer available."); - } + BufferChecks.checkBuffer(buffers, 1); nglDrawBuffersATI(buffers.remaining(), buffers, buffers.position()); } Index: EXTVertexWeighting.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/EXTVertexWeighting.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- EXTVertexWeighting.java 4 Jul 2004 13:14:05 -0000 1.7 +++ EXTVertexWeighting.java 26 Jul 2004 13:36:03 -0000 1.8 @@ -56,6 +56,7 @@ public static native void glVertexWeightfEXT(float weight); public static void glVertexWeightPointerEXT(int size, int stride, FloatBuffer pPointer) { + BufferChecks.checkDirect(pPointer); BufferChecks.ensureArrayVBOdisabled(); nglVertexWeightPointerEXT(size, GL11.GL_FLOAT, stride, pPointer, pPointer.position()<<2); } Index: GL13.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GL13.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- GL13.java 4 Jul 2004 13:14:05 -0000 1.9 +++ GL13.java 26 Jul 2004 13:36:03 -0000 1.10 @@ -155,92 +155,119 @@ public static native void glActiveTexture(int texture); public static native void glClientActiveTexture(int texture); public static void glCompressedTexImage1D(int target, int level, int internalformat, int width, int border, int imageSize, ByteBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage1D(target, level, internalformat, width, border, imageSize, data, data.position()); } public static void glCompressedTexImage1D(int target, int level, int internalformat, int width, int border, int imageSize, ShortBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage1D(target, level, internalformat, width, border, imageSize, data, data.position() << 1); } public static void glCompressedTexImage1D(int target, int level, int internalformat, int width, int border, int imageSize, IntBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage1D(target, level, internalformat, width, border, imageSize, data, data.position() << 2); } public static void glCompressedTexImage1D(int target, int level, int internalformat, int width, int border, int imageSize, FloatBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage1D(target, level, internalformat, width, border, imageSize, data, data.position() << 2); } private static native void nglCompressedTexImage1D(int target, int level, int internalformat, int width, int border, int imageSize, Buffer data, int data_offset); public static void glCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, ByteBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data, data.position()); } public static void glCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, ShortBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data, data.position() << 1); } public static void glCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, IntBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data, data.position() << 2); } public static void glCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, FloatBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data, data.position() << 2); } private static native void nglCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, Buffer data, int data_offset); public static void glCompressedTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int imageSize, ByteBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data, data.position()); } public static void glCompressedTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int imageSize, ShortBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data, data.position() << 1); } public static void glCompressedTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int imageSize, IntBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data, data.position() << 2); } public static void glCompressedTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int imageSize, FloatBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data, data.position() << 2); } private static native void nglCompressedTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int imageSize, Buffer data, int data_offset); public static void glCompressedTexSubImage1D(int target, int level, int xoffset, int width, int format, int imageSize, ByteBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, data, data.position()); } public static void glCompressedTexSubImage1D(int target, int level, int xoffset, int width, int format, int imageSize, ShortBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, data, data.position() << 1); } public static void glCompressedTexSubImage1D(int target, int level, int xoffset, int width, int format, int imageSize, IntBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, data, data.position() << 2); } public static void glCompressedTexSubImage1D(int target, int level, int xoffset, int width, int format, int imageSize, FloatBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, data, data.position() << 2); } private static native void nglCompressedTexSubImage1D(int target, int level, int xoffset, int width, int format, int imageSize, Buffer data, int data_offset); public static void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, ByteBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data, data.position()); } public static void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, ShortBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data, data.position() << 1); } public static void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, IntBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data, data.position() << 2); } public static void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, FloatBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data, data.position() << 2); } private static native void nglCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, Buffer data, int data_offset); public static void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int imageSize, ByteBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data, data.position()); } public static void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int imageSize, ShortBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data, data.position() << 1); } public static void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int imageSize, IntBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data, data.position() << 2); } public static void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int imageSize, FloatBuffer data) { + BufferChecks.checkDirect(data); nglCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data, data.position() << 2); } private static native void nglCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int imageSize, Buffer data, int data_offset); public static void glGetCompressedTexImage(int target, int lod, ByteBuffer img) { + BufferChecks.checkDirect(img); // TODO: check buffer size valid nglGetCompressedTexImage(target, lod, img, img.position()); } public static void glGetCompressedTexImage(int target, int lod, ShortBuffer img) { + BufferChecks.checkDirect(img); // TODO: check buffer size valid nglGetCompressedTexImage(target, lod, img, img.position() << 1); } public static void glGetCompressedTexImage(int target, int lod, IntBuffer img) { + BufferChecks.checkDirect(img); // TODO: check buffer size valid nglGetCompressedTexImage(target, lod, img, img.position() << 2); } @@ -262,4 +289,3 @@ public static native void glSampleCoverage(float value, boolean invert); } - Index: ARBMatrixPalette.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBMatrixPalette.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ARBMatrixPalette.java 4 Jul 2004 13:14:05 -0000 1.8 +++ ARBMatrixPalette.java 26 Jul 2004 13:35:59 -0000 1.9 @@ -54,14 +54,17 @@ public static native void glCurrentPaletteMatrixARB(int index); public static void glMatrixIndexPointerARB(int size, int stride, ByteBuffer pPointer) { + BufferChecks.checkDirect(pPointer); BufferChecks.ensureArrayVBOdisabled(); nglMatrixIndexPointerARB(size, GL11.GL_UNSIGNED_BYTE, stride, pPointer, pPointer.position()); } public static void glMatrixIndexPointerARB(int size, int stride, ShortBuffer pPointer) { + BufferChecks.checkDirect(pPointer); BufferChecks.ensureArrayVBOdisabled(); nglMatrixIndexPointerARB(size, GL11.GL_UNSIGNED_SHORT, stride, pPointer, pPointer.position()<<1); } public static void glMatrixIndexPointerARB(int size, int stride, IntBuffer pPointer) { + BufferChecks.checkDirect(pPointer); BufferChecks.ensureArrayVBOdisabled(); nglMatrixIndexPointerARB(size, GL11.GL_UNSIGNED_INT, stride, pPointer, pPointer.position()<<2); } @@ -73,16 +76,19 @@ private static native void nglMatrixIndexPointerARBVBO(int size, int type, int stride, int buffer_offset); public static void glMatrixIndexuARB(ByteBuffer pIndices) { + BufferChecks.checkDirect(pIndices); nglMatrixIndexubvARB(pIndices.remaining(), pIndices, pIndices.position()); } private static native void nglMatrixIndexubvARB(int size, ByteBuffer pIndices, int pIndices_offset); public static void glMatrixIndexuARB(IntBuffer piIndices) { + BufferChecks.checkDirect(piIndices); nglMatrixIndexuivARB(piIndices.remaining(), piIndices, piIndices.position()); } private static native void nglMatrixIndexuivARB(int size, IntBuffer piIndices, int piIndices_offset); public static void glMatrixIndexuARB(ShortBuffer psIndices) { + BufferChecks.checkDirect(psIndices); nglMatrixIndexusvARB(psIndices.remaining(), psIndices, psIndices.position()); } private static native void nglMatrixIndexusvARB(int size, ShortBuffer psIndices, int psIndices_offset); Index: NVVertexProgram.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVVertexProgram.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- NVVertexProgram.java 4 Jul 2004 13:14:05 -0000 1.10 +++ NVVertexProgram.java 26 Jul 2004 13:36:04 -0000 1.11 @@ -49,7 +49,6 @@ ExecuteProgramNV, GetProgramParameter[df]vNV, GetTrackMatrixivNV, LoadProgramNV, ProgramParameter[s]4[df][v]NV, and TrackMatrixNV: */ - public static final int GL_VERTEX_PROGRAM_NV = 0x8620; /* @@ -57,103 +56,74 @@ and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: */ - public static final int GL_VERTEX_PROGRAM_POINT_SIZE_NV = 0x8642; - public static final int GL_VERTEX_PROGRAM_TWO_SIDE_NV = 0x8643; /* Accepted by the <target> parameter of ExecuteProgramNV and LoadProgramNV: */ - public static final int GL_VERTEX_STATE_PROGRAM_NV = 0x8621; /* Accepted by the <pname> parameter of GetVertexAttrib[dfi]vNV: */ - public static final int GL_ATTRIB_ARRAY_SIZE_NV = 0x8623; - public static final int GL_ATTRIB_ARRAY_STRIDE_NV = 0x8624; - public static final int GL_ATTRIB_ARRAY_TYPE_NV = 0x8625; - public static final int GL_CURRENT_ATTRIB_NV = 0x8626; /* Accepted by the <pname> parameter of GetProgramParameterfvNV and GetProgramParameterdvNV: */ - public static final int GL_PROGRAM_PARAMETER_NV = 0x8644; /* Accepted by the <pname> parameter of GetVertexAttribPointervNV: */ - public static final int GL_ATTRIB_ARRAY_POINTER_NV = 0x8645; /* Accepted by the <pname> parameter of GetTrackMatrixivNV: */ - public static final int GL_TRACK_MATRIX_NV = 0x8648; - public static final int GL_TRACK_MATRIX_TRANSFORM_NV = 0x8649; /* Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: */ - public static final int GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV = 0x862E; - public static final int GL_MAX_TRACK_MATRICES_NV = 0x862F; - public static final int GL_CURRENT_MATRIX_STACK_DEPTH_NV = 0x8640; - public static final int GL_CURRENT_MATRIX_NV = 0x8641; - public static final int GL_VERTEX_PROGRAM_BINDING_NV = 0x864A; /* Accepted by the <matrix> parameter of TrackMatrixNV: */ - public static final int GL_MODELVIEW_PROJECTION_NV = 0x8629; /* Accepted by the <matrix> parameter of TrackMatrixNV and by the <mode> parameter of MatrixMode: */ - public static final int GL_MATRIX0_NV = 0x8630; - public static final int GL_MATRIX1_NV = 0x8631; - public static final int GL_MATRIX2_NV = 0x8632; - public static final int GL_MATRIX3_NV = 0x8633; - public static final int GL_MATRIX4_NV = 0x8634; - public static final int GL_MATRIX5_NV = 0x8635; - public static final int GL_MATRIX6_NV = 0x8636; - public static final int GL_MATRIX7_NV = 0x8637; /* Accepted by the <transform> parameter of TrackMatrixNV: */ - public static final int GL_IDENTITY_NV = 0x862A; - public static final int GL_INVERSE_NV = 0x862B; - public static final int GL_TRANSPOSE_NV = 0x862C; - public static final int GL_INVERSE_TRANSPOSE_NV = 0x862D; /* @@ -162,37 +132,21 @@ the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: */ - public static final int GL_VERTEX_ATTRIB_ARRAY0_NV = 0x8650; - public static final int GL_VERTEX_ATTRIB_ARRAY1_NV = 0x8651; - public static final int GL_VERTEX_ATTRIB_ARRAY2_NV = 0x8652; - public static final int GL_VERTEX_ATTRIB_ARRAY3_NV = 0x8653; - public static final int GL_VERTEX_ATTRIB_ARRAY4_NV = 0x8654; - public static final int GL_VERTEX_ATTRIB_ARRAY5_NV = 0x8655; - public static final int GL_VERTEX_ATTRIB_ARRAY6_NV = 0x8656; - public static final int GL_VERTEX_ATTRIB_ARRAY7_NV = 0x8657; - public static final int GL_VERTEX_ATTRIB_ARRAY8_NV = 0x8658; - public static final int GL_VERTEX_ATTRIB_ARRAY9_NV = 0x8659; - public static final int GL_VERTEX_ATTRIB_ARRAY10_NV = 0x865A; - public static final int GL_VERTEX_ATTRIB_ARRAY11_NV = 0x865B; - public static final int GL_VERTEX_ATTRIB_ARRAY12_NV = 0x865C; - public static final int GL_VERTEX_ATTRIB_ARRAY13_NV = 0x865D; - public static final int GL_VERTEX_ATTRIB_ARRAY14_NV = 0x865E; - public static final int GL_VERTEX_ATTRIB_ARRAY15_NV = 0x865F; /* @@ -201,37 +155,21 @@ IsEnabled, and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: */ - public static final int GL_MAP1_VERTEX_ATTRIB0_4_NV = 0x8660; - public static final int GL_MAP1_VERTEX_ATTRIB1_4_NV = 0x8661; - public static final int GL_MAP1_VERTEX_ATTRIB2_4_NV = 0x8662; - public static final int GL_MAP1_VERTEX_ATTRIB3_4_NV = 0x8663; - public static final int GL_MAP1_VERTEX_ATTRIB4_4_NV = 0x8664; - public static final int GL_MAP1_VERTEX_ATTRIB5_4_NV = 0x8665; - public static final int GL_MAP1_VERTEX_ATTRIB6_4_NV = 0x8666; - public static final int GL_MAP1_VERTEX_ATTRIB7_4_NV = 0x8667; - public static final int GL_MAP1_VERTEX_ATTRIB8_4_NV = 0x8668; - public static final int GL_MAP1_VERTEX_ATTRIB9_4_NV = 0x8669; - public static final int GL_MAP1_VERTEX_ATTRIB10_4_NV = 0x866A; - public static final int GL_MAP1_VERTEX_ATTRIB11_4_NV = 0x866B; - public static final int GL_MAP1_VERTEX_ATTRIB12_4_NV = 0x866C; - public static final int GL_MAP1_VERTEX_ATTRIB13_4_NV = 0x866D; - public static final int GL_MAP1_VERTEX_ATTRIB14_4_NV = 0x866E; - public static final int GL_MAP1_VERTEX_ATTRIB15_4_NV = 0x866F; /* @@ -240,37 +178,21 @@ IsEnabled, and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: */ - public static final int GL_MAP2_VERTEX_ATTRIB0_4_NV = 0x8670; - public static final int GL_MAP2_VERTEX_ATTRIB1_4_NV = 0x8671; - public static final int GL_MAP2_VERTEX_ATTRIB2_4_NV = 0x8672; - public static final int GL_MAP2_VERTEX_ATTRIB3_4_NV = 0x8673; - public static final int GL_MAP2_VERTEX_ATTRIB4_4_NV = 0x8674; - public static final int GL_MAP2_VERTEX_ATTRIB5_4_NV = 0x8675; - public static final int GL_MAP2_VERTEX_ATTRIB6_4_NV = 0x8676; - public static final int GL_MAP2_VERTEX_ATTRIB7_4_NV = 0x8677; - public static final int GL_MAP2_VERTEX_ATTRIB8_4_NV = 0x8678; - public static final int GL_MAP2_VERTEX_ATTRIB9_4_NV = 0x8679; - public static final int GL_MAP2_VERTEX_ATTRIB10_4_NV = 0x867A; - public static final int GL_MAP2_VERTEX_ATTRIB11_4_NV = 0x867B; - public static final int GL_MAP2_VERTEX_ATTRIB12_4_NV = 0x867C; - public static final int GL_MAP2_VERTEX_ATTRIB13_4_NV = 0x867D; - public static final int GL_MAP2_VERTEX_ATTRIB14_4_NV = 0x867E; - public static final int GL_MAP2_VERTEX_ATTRIB15_4_NV = 0x867F; static native void initNativeStubs() throws LWJGLException; @@ -280,7 +202,6 @@ public static void glExecuteProgramNV(int target, int id, FloatBuffer params) { BufferChecks.checkBuffer(params); nglExecuteProgramNV(target, id, params, params.position()); - } private static native void nglExecuteProgramNV(int target, int id, FloatBuffer params, int paramsOffset); @@ -292,7 +213,6 @@ public static void glGetProgramParameterNV(int target, int index, int parameterName, FloatBuffer params) { BufferChecks.checkBuffer(params); nglGetProgramParameterfvNV(target, index, parameterName, params, params.position()); - } private static native void nglGetProgramParameterfvNV( @@ -326,7 +246,6 @@ public static void glGetVertexAttribNV(int index, int parameterName, FloatBuffer params) { BufferChecks.checkBuffer(params); nglGetVertexAttribfvNV(index, parameterName, params, params.position()); - } private static native void nglGetVertexAttribfvNV(int index, int parameterName, FloatBuffer params, int paramsOffset); @@ -338,7 +257,6 @@ public static void glGetVertexAttribNV(int index, int parameterName, IntBuffer params) { BufferChecks.checkBuffer(params); nglGetVertexAttribivNV(index, parameterName, params, params.position()); - } private static native void nglGetVertexAttribivNV(int index, int parameterName, IntBuffer params, int paramsOffset); @@ -352,12 +270,11 @@ // --------------------------- public static void glProgramParameters4NV(int target, int index, int count, FloatBuffer params) { - + BufferChecks.checkDirect(params); // Special case buffer check if (params.remaining() < count * 4) { throw new BufferOverflowException(); } - nglProgramParameters4fvNV(target, index, count, params, params.position()); } @@ -374,9 +291,8 @@ public static native void glTrackMatrixNV(int target, int address, int matrix, int transform); public static void glVertexAttribPointerNV(int index, int size, boolean unsigned, int stride, ByteBuffer buffer) { - + BufferChecks.checkDirect(buffer); BufferChecks.ensureArrayVBOdisabled(); - nglVertexAttribPointerNV( index, size, @@ -384,13 +300,11 @@ stride, buffer, buffer.position()); - } public static void glVertexAttribPointerNV(int index, int size, boolean unsigned, int stride, ShortBuffer buffer) { - + BufferChecks.checkDirect(buffer); BufferChecks.ensureArrayVBOdisabled(); - nglVertexAttribPointerNV( index, size, @@ -398,21 +312,17 @@ stride, buffer, buffer.position() << 1); - } public static void glVertexAttribPointerNV(int index, int size, int stride, FloatBuffer buffer) { - + BufferChecks.checkDirect(buffer); BufferChecks.ensureArrayVBOdisabled(); - nglVertexAttribPointerNV(index, size, GL11.GL_FLOAT, stride, buffer, buffer.position() << 2); - } public static void glVertexAttribPointerNV(int index, int size, boolean unsigned, int stride, IntBuffer buffer) { - + BufferChecks.checkDirect(buffer); BufferChecks.ensureArrayVBOdisabled(); - nglVertexAttribPointerNV( index, size, @@ -420,7 +330,6 @@ stride, buffer, buffer.position() << 2); - } private static native void nglVertexAttribPointerNV( @@ -434,11 +343,8 @@ // --------------------------- public static void glVertexAttribPointerNV(int index, int size, int type, int stride, int bufferOffset) { - BufferChecks.ensureArrayVBOenabled(); - nglVertexAttribPointerNVVBO(index, size, type, stride, bufferOffset); - } private static native void nglVertexAttribPointerNVVBO(int index, int size, int type, int stride, int bufferOffset); @@ -463,48 +369,57 @@ public static native void glVertexAttrib4ubNV(int index, byte x, byte y, byte z, byte w); - public static void glVertexAttribs1NV(int index, int n, ShortBuffer v) { - nglVertexAttribs1svNV(index, n, v, v.position()); + public static void glVertexAttribs1NV(int index, ShortBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs1svNV(index, v.remaining(), v, v.position()<<1); } private static native void nglVertexAttribs1svNV(int index, int n, ShortBuffer v, int v_offset); - public static void glVertexAttribs1NV(int index, int n, FloatBuffer v) { - nglVertexAttribs1fvNV(index, n, v, v.position()); + public static void glVertexAttribs1NV(int index, FloatBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs1fvNV(index, v.remaining(), v, v.position()<<2); } private static native void nglVertexAttribs1fvNV(int index, int n, FloatBuffer v, int v_offset); - public static void glVertexAttribs2NV(int index, int n, ShortBuffer v) { - nglVertexAttribs2svNV(index, n, v, v.position()); + public static void glVertexAttribs2NV(int index, ShortBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs2svNV(index, v.remaining()>>1, v, v.position()<<1); } private static native void nglVertexAttribs2svNV(int index, int n, ShortBuffer v, int v_offset); - public static void glVertexAttribs2NV(int index, int n, FloatBuffer v) { - nglVertexAttribs2fvNV(index, n, v, v.position()); + public static void glVertexAttribs2NV(int index, FloatBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs2fvNV(index, v.remaining()>>1, v, v.position()<<2); } private static native void nglVertexAttribs2fvNV(int index, int n, FloatBuffer v, int v_offset); - public static void glVertexAttribs3NV(int index, int n, ShortBuffer v) { - nglVertexAttribs3svNV(index, n, v, v.position()); + public static void glVertexAttribs3NV(int index, ShortBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs3svNV(index, v.remaining()/3, v, v.position()<<1); } private static native void nglVertexAttribs3svNV(int index, int n, ShortBuffer v, int v_offset); - public static void glVertexAttribs3NV(int index, int n, FloatBuffer v) { - nglVertexAttribs3fvNV(index, n, v, v.position()); + public static void glVertexAttribs3NV(int index, FloatBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs3fvNV(index, v.remaining()/3, v, v.position()<<2); } private static native void nglVertexAttribs3fvNV(int index, int n, FloatBuffer v, int v_offset); - public static void glVertexAttribs4NV(int index, int n, ShortBuffer v) { - nglVertexAttribs4svNV(index, n, v, v.position()); + public static void glVertexAttribs4NV(int index, ShortBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs4svNV(index, v.remaining()>>2, v, v.position()<<1); } private static native void nglVertexAttribs4svNV(int index, int n, ShortBuffer v, int v_offset); - public static void glVertexAttribs4NV(int index, int n, FloatBuffer v) { - nglVertexAttribs4fvNV(index, n, v, v.position()); + public static void glVertexAttribs4NV(int index, FloatBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs4fvNV(index, v.remaining()>>2, v, v.position()<<2); } private static native void nglVertexAttribs4fvNV(int index, int n, FloatBuffer v, int v_offset); - public static void glVertexAttribs4uNV(int index, int n, ByteBuffer v) { - nglVertexAttribs4ubvNV(index, n, v, v.position()); + public static void glVertexAttribs4uNV(int index, ByteBuffer v) { + BufferChecks.checkDirect(v); + nglVertexAttribs4ubvNV(index, v.remaining()>>2, v, v.position()); } private static native void nglVertexAttribs4ubvNV(int index, int n, ByteBuffer v, int v_offset); } Index: NVProgram.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVProgram.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- NVProgram.java 4 Jul 2004 13:14:05 -0000 1.7 +++ NVProgram.java 26 Jul 2004 13:36:04 -0000 1.8 @@ -66,6 +66,7 @@ // --------------------------- public static void glLoadProgramNV(int target, int programID, ByteBuffer string) { + BufferChecks.checkDirect(string); nglLoadProgramNV(target, programID, string.remaining(), string, string.position()); } @@ -76,6 +77,7 @@ // --------------------------- public static void glDeleteProgramsNV(IntBuffer programs) { + BufferChecks.checkDirect(programs); nglDeleteProgramsNV(programs.remaining(), programs, programs.position()); } @@ -85,6 +87,7 @@ // --------------------------- public static void glGenProgramsNV(IntBuffer programs) { + BufferChecks.checkDirect(programs); nglGenProgramsNV(programs.remaining(), programs, programs.position()); } @@ -94,6 +97,7 @@ // --------------------------- public static void glGetProgramNV(int programID, int parameterName, IntBuffer params) { + BufferChecks.checkDirect(params); nglGetProgramivNV(programID, parameterName, params, params.position()); } @@ -102,6 +106,7 @@ // --------------------------- public static void glGetProgramStringNV(int programID, int parameterName, ByteBuffer paramString) { + BufferChecks.checkDirect(paramString); nglGetProgramStringNV(programID, parameterName, paramString, paramString.position()); } @@ -112,6 +117,8 @@ // --------------------------- public static boolean glAreProgramsResidentNV(IntBuffer programIDs, ByteBuffer programResidences) { + BufferChecks.checkDirect(programIDs); + BufferChecks.checkDirect(programResidences); if ( programIDs.remaining() != programResidences.remaining() ) throw new IllegalArgumentException("programIDs.remaining() != programResidences.remaining()"); return nglAreProgramsResidentNV(programIDs.remaining(), @@ -130,6 +137,7 @@ // --------------------------- public static void glRequestResidentProgramsNV(IntBuffer programIDs) { + BufferChecks.checkDirect(programIDs); nglRequestResidentProgramsNV(programIDs.remaining(), programIDs, programIDs.position()); } Index: ARBVertexShader.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBVertexShader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ARBVertexShader.java 4 Jul 2004 13:14:05 -0000 1.9 +++ ARBVertexShader.java 26 Jul 2004 13:36:01 -0000 1.10 @@ -100,6 +100,7 @@ // --------------------------- public static void glBindAttribLocationARB(int programObj, int index, ByteBuffer name) { + BufferChecks.checkDirect(name); if ( name.get(name.limit() - 1) != 0 ) { throw new IllegalArgumentException("<name> must be a null-terminated string."); } @@ -112,12 +113,15 @@ // --------------------------- public static void glGetActiveAttribARB(int programObj, int index, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) { - BufferChecks.checkBuffer(name); + BufferChecks.checkDirect(name); + BufferChecks.checkDirect(size); + BufferChecks.checkDirect(type); - if ( length == null ) + if ( length == null ) { nglGetActiveAttribARB(programObj, index, name.remaining(), null, -1, size, size.position(), type, type.position(), name, name.position()); - else { + } else { + BufferChecks.checkDirect(length); nglGetActiveAttribARB(programObj, index, name.remaining(), length, length.position(), size, size.position(), type, type.position(), name, name.position()); } @@ -132,6 +136,7 @@ // --------------------------- public static int glGetAttribLocationARB(int programObj, ByteBuffer name) { + BufferChecks.checkDirect(name); if ( name.get(name.limit() - 1) != 0 ) { throw new IllegalArgumentException("<name> must be a null-terminated string."); } Index: NVHalfFloat.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/NVHalfFloat.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- NVHalfFloat.java 4 Jul 2004 13:14:05 -0000 1.6 +++ NVHalfFloat.java 26 Jul 2004 13:36:04 -0000 1.7 @@ -90,6 +90,7 @@ // --------------------------- public static void glVertexAttribs1hNV(int index, ShortBuffer attribs) { + BufferChecks.checkDirect(attribs); nglVertexAttribs1hvNV(index, attribs.remaining(), attribs, attribs.position()); } @@ -99,6 +100,7 @@ // --------------------------- public static void glVertexAttribs2hNV(int index, ShortBuffer attribs) { + BufferChecks.checkDirect(attribs); nglVertexAttribs2hvNV(index, attribs.remaining() >> 1, attribs, attribs.position()); } @@ -108,6 +110,7 @@ // --------------------------- public static void glVertexAttribs3hNV(int index, ShortBuffer attribs) { + BufferChecks.checkDirect(attribs); nglVertexAttribs3hvNV(index, attribs.remaining() / 3, attribs, attribs.position()); } @@ -117,6 +120,7 @@ // --------------------------- public static void glVertexAttribs4hNV(int index, ShortBuffer attribs) { + BufferChecks.checkDirect(attribs); nglVertexAttribs4hvNV(index, attribs.remaining() >> 2, attribs, attribs.position()); } Index: BufferChecks.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/BufferChecks.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- BufferChecks.java 12 Jun 2004 20:28:23 -0000 1.10 +++ BufferChecks.java 26 Jul 2004 13:36:02 -0000 1.11 @@ -30,7 +30,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.opengl; + import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ShortBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.DoubleBuffer; /** * $Id$ A class to @@ -59,6 +65,87 @@ private static final int DEFAULT_BUFFER_SIZE = 4; /** + * Helper methods to ensure a buffer is direct or null. + */ + static void checkDirectOrNull(ByteBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + static void checkDirectOrNull(FloatBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + static void checkDirectOrNull(ShortBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + static void checkDirectOrNull(IntBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + static void checkDirectOrNull(DoubleBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + /** + * Helper methods to ensure a buffer is direct (and, implicitly, non-null). + */ + static void checkDirectBuffer(Buffer buf) { + if (buf instanceof ByteBuffer) + checkDirect((ByteBuffer)buf); + else if (buf instanceof ShortBuffer) + checkDirect((ShortBuffer)buf); + else if (buf instanceof IntBuffer) + checkDirect((IntBuffer)buf); + else if (buf instanceof FloatBuffer) + checkDirect((FloatBuffer)buf); + else if (buf instanceof DoubleBuffer) + checkDirect((DoubleBuffer)buf); + else + throw new IllegalStateException("Unsupported buffer type"); + } + + static void checkDirect(ByteBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("ByteBuffer is not direct"); + } + } + + static void checkDirect(FloatBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("FloatBuffer is not direct"); + } + } + + static void checkDirect(ShortBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("ShortBuffer is not direct"); + } + } + + static void checkDirect(IntBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("IntBuffer is not direct"); + } + } + + static void checkDirect(DoubleBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("IntBuffer is not direct"); + } + } + + /** * Helper method to ensure a buffer is big enough to receive data from a * glGet* operation. * @@ -68,13 +155,39 @@ * The minimum buffer size * @throws BufferOverflowException */ - static void checkBuffer(Buffer buf, int size) { + private static void checkBufferSize(Buffer buf, int size) { if (buf.remaining() < size) { throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size); } } + + static void checkBuffer(ByteBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + static void checkBuffer(IntBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + static void checkBuffer(ShortBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + static void checkBuffer(FloatBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + static void checkBuffer(DoubleBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + /** - * Helper method to ensure a buffer is big enough to receive data from a + * Helper methods to ensure a buffer is big enough to receive data from a * glGet* operation. To avoid unnecessarily complex buffer size checking * we've just set the bar artificially high and insist that any receiving * buffer has at least 4 remaining(). @@ -83,7 +196,23 @@ * The buffer to check * @throws BufferOverflowException */ - static void checkBuffer(Buffer buf) { + static void checkBuffer(ByteBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + static void checkBuffer(ShortBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + static void checkBuffer(FloatBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + static void checkBuffer(In... [truncated message content] |
|
From: Elias N. <eli...@us...> - 2004-07-26 13:36:13
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6148/src/native/linux Modified Files: org_lwjgl_opengl_Pbuffer.cpp Log Message: Make Pbuffers that share the display context be single-buffered (linux part) Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_opengl_Pbuffer.cpp 25 Jul 2004 14:28:50 -0000 1.23 +++ org_lwjgl_opengl_Pbuffer.cpp 26 Jul 2004 13:36:04 -0000 1.24 @@ -128,6 +128,50 @@ return true; } +static bool configMatches(const GLXFBConfig config1, const GLXFBConfig config2, int glx_val) { + int config_val1; + int config_val2; + if (glXGetFBConfigAttrib(getDisplay(), config1, glx_val, &config_val1) != Success) + return false; + if (glXGetFBConfigAttrib(getDisplay(), config2, glx_val, &config_val2) != Success) + return false; + return config_val1 == config_val2; +} + +static GLXFBConfig chooseSingleBufferedConfigFromConfig(const GLXFBConfig orig_config) { + int num_elements; + GLXFBConfig *configs = glXGetFBConfigs(getDisplay(), getCurrentScreen(), &num_elements); + for (int i = 0; i < num_elements; i++) { + GLXFBConfig config = configs[i]; + int double_buffer; + int drawable_type; + if (glXGetFBConfigAttrib(getDisplay(), config, GLX_DOUBLEBUFFER, &double_buffer) != Success) + return NULL; + if (glXGetFBConfigAttrib(getDisplay(), config, GLX_DRAWABLE_TYPE, &drawable_type) != Success) + return NULL; + if (double_buffer != False || (drawable_type & GLX_PBUFFER_BIT == 0)) + continue; + if (configMatches(config, orig_config, GLX_RED_SIZE) && + configMatches(config, orig_config, GLX_GREEN_SIZE) && + configMatches(config, orig_config, GLX_BLUE_SIZE) && + configMatches(config, orig_config, GLX_ALPHA_SIZE) && + configMatches(config, orig_config, GLX_DEPTH_SIZE) && + configMatches(config, orig_config, GLX_STENCIL_SIZE) && + configMatches(config, orig_config, GLX_STEREO) && + configMatches(config, orig_config, GLX_AUX_BUFFERS) && + configMatches(config, orig_config, GLX_ACCUM_RED_SIZE) && + configMatches(config, orig_config, GLX_ACCUM_GREEN_SIZE) && + configMatches(config, orig_config, GLX_ACCUM_BLUE_SIZE) && + configMatches(config, orig_config, GLX_ACCUM_ALPHA_SIZE) && + configMatches(config, orig_config, GLX_RENDER_TYPE) && + (!extgl_Extensions.GLX_ARB_multisample || (configMatches(config, orig_config, GLX_SAMPLE_BUFFERS_ARB) && + configMatches(config, orig_config, GLX_SAMPLES_ARB)))) { + return config; + } + } + return NULL; +} + static bool createPbufferUsingDisplayContext(JNIEnv *env, PbufferInfo *buffer_info, int width, int height, const int *buffer_attribs) { if (!checkPbufferCaps(env, getCurrentGLXFBConfig(), width, height)) { return false; @@ -141,7 +185,12 @@ throwException(env, "Display context does not support Pbuffers"); return false; } - GLXPbuffer buffer = glXCreatePbuffer(getDisplay(), getCurrentGLXFBConfig(), buffer_attribs); + GLXFBConfig config = chooseSingleBufferedConfigFromConfig(getCurrentGLXFBConfig()); + if (config == NULL) { + throwException(env, "Could not find a suitable GLXFBConfig"); + return false; + } + GLXPbuffer buffer = glXCreatePbuffer(getDisplay(), config, buffer_attribs); buffer_info->buffer = buffer; buffer_info->context = getCurrentGLXContext(); return true; @@ -153,7 +202,7 @@ if (disp == NULL) { return; } - int current_screen = XDefaultScreen(disp); + int current_screen = getCurrentScreen(); if (!extgl_InitGLX(env, disp, current_screen)) { decDisplay(); throwException(env, "Could not init GLX"); |
|
From: Elias N. <eli...@us...> - 2004-07-25 14:51:37
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26316/src/native/win32 Modified Files: org_lwjgl_input_Cursor.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: Win32 part of ByteBuffer handles for Pbuffer and Cursor Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- org_lwjgl_input_Mouse.cpp 15 Jul 2004 16:07:13 -0000 1.57 +++ org_lwjgl_input_Mouse.cpp 25 Jul 2004 14:51:28 -0000 1.58 @@ -223,12 +223,14 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor - (JNIEnv *env, jclass clazz, jlong cursor_handle) + (JNIEnv *env, jclass clazz, jobject handle_buffer) { if (mDIDevice == NULL) throwException(env, "null device!"); - if (cursor_handle != 0) { - HCURSOR cursor = (HCURSOR)cursor_handle; + if (handle_buffer != NULL) { + HCURSOR *cursor_handle = (HCURSOR *)env->GetDirectBufferAddress(handle_buffer); + HCURSOR cursor = *cursor_handle; +// HCURSOR cursor = (HCURSOR)cursor_handle; SetClassLong(display_hwnd, GCL_HCURSOR, (LONG)cursor); SetCursor(cursor); } else { Index: org_lwjgl_input_Cursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Cursor.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_input_Cursor.cpp 6 Jul 2004 07:50:32 -0000 1.12 +++ org_lwjgl_input_Cursor.cpp 25 Jul 2004 14:51:28 -0000 1.13 @@ -44,14 +44,13 @@ #include "Window.h" #include "common_tools.h" -/* - * Class: org_lwjgl_input_Cursor - * Method: nCreateCursor - * Signature: (IIIIIIIII)I - */ -JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor - (JNIEnv *env, jclass clazz, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) +JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor + (JNIEnv *env, jclass clazz, jobject handle_buffer, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { + if (env->GetDirectBufferCapacity(handle_buffer) < sizeof(HCURSOR)) { + throwException(env, "Handle buffer not large enough"); + return; + } int *pixels = (int *)env->GetDirectBufferAddress(image_buffer) + images_offset; BITMAPINFO bitmapInfo; @@ -78,7 +77,7 @@ char *dstPtr = ptrCursorImage; if (!dstPtr) { throwException(env, "Could not allocate DIB section."); - return 0; + return; } for (y = 0; y < height; y++ ) { for (x = 0; x < width; x++ ) { @@ -137,7 +136,8 @@ DeleteObject(cursorMask); delete[] maskPixels; - return (jint)cursor; + HCURSOR *cursor_handle = (HCURSOR *)env->GetDirectBufferAddress(handle_buffer); + *cursor_handle = cursor; } /* @@ -146,8 +146,9 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *env, jclass clazz, jlong cursor_handle) + (JNIEnv *env, jclass clazz, jobject handle_buffer) { - HCURSOR cursor = (HCURSOR)cursor_handle; - DestroyCursor(cursor); +// HCURSOR cursor = (HCURSOR)cursor_handle; + HCURSOR *cursor_handle = (HCURSOR *)env->GetDirectBufferAddress(handle_buffer); + DestroyCursor(*cursor_handle); } Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 22:06:43 -0000 1.15 +++ org_lwjgl_opengl_Pbuffer.cpp 25 Jul 2004 14:51:28 -0000 1.16 @@ -137,11 +137,15 @@ return Pbuffer_context; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *env, jclass clazz, jboolean use_display_context, +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate + (JNIEnv *env, jclass clazz, jobject buffer_handle, jboolean use_display_context, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs) { + if (env->GetDirectBufferCapacity(buffer_handle) < sizeof(PbufferInfo)) { + throwException(env, "Buffer handle not large enough"); + return; + } HPBUFFERARB Pbuffer; const int *pBufferAttribs_ptr; if ( pBufferAttribs != NULL ) { @@ -158,14 +162,14 @@ if (Pbuffer == NULL) { throwException(env, "Could not create Pbuffer."); - return (jint)NULL; + return; } HDC Pbuffer_dc = wglGetPbufferDCARB(Pbuffer); if (Pbuffer_dc == NULL) { wglDestroyPbufferARB(Pbuffer); throwException(env, "Could not get Pbuffer dc."); - return (jint)NULL; + return; } HGLRC Pbuffer_context; if (use_display_context) { @@ -175,50 +179,54 @@ if (Pbuffer_context == NULL) { wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc); wglDestroyPbufferARB(Pbuffer); - return (jint)NULL; + return; } } - PbufferInfo *Pbuffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo)); + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle); +// PbufferInfo *Pbuffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo)); Pbuffer_info->Pbuffer = Pbuffer; Pbuffer_info->Pbuffer_context = Pbuffer_context; Pbuffer_info->Pbuffer_dc = Pbuffer_dc; Pbuffer_info->use_display_context = use_display_context == JNI_TRUE; - return (jint)Pbuffer_info; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost - (JNIEnv *env, jclass clazz, jint handle) + (JNIEnv *env, jclass clazz, jobject buffer_handle) { - PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle); +// PbufferInfo *Pbuffer_info = (PbufferInfo *)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_Pbuffer_nMakeCurrent - (JNIEnv *env, jclass clazz, jint handle) + (JNIEnv *env, jclass clazz, jobject buffer_handle) { - PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(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_Pbuffer_nDestroy - (JNIEnv *env, jclass clazz, jint handle) + (JNIEnv *env, jclass clazz, jobject buffer_handle) { - PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle); +// PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; if (!Pbuffer_info->use_display_context) wglDeleteContext(Pbuffer_info->Pbuffer_context); wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc); wglDestroyPbufferARB(Pbuffer_info->Pbuffer); - free(Pbuffer_info); +// free(Pbuffer_info); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib - (JNIEnv *env, jclass clazz, jint handle, jint attrib, jint value) + (JNIEnv *env, jclass clazz, jobject buffer_handle, jint attrib, jint value) { - PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle); +// PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; int attribs[3]; @@ -230,15 +238,17 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage - (JNIEnv *env, jclass clazz, jint handle, jint buffer) + (JNIEnv *env, jclass clazz, jobject buffer_handle, jint buffer) { - PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle); +// PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; wglBindTexImageARB(Pbuffer_info->Pbuffer, buffer); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage - (JNIEnv *env, jclass clazz, jint handle, jint buffer) + (JNIEnv *env, jclass clazz, jobject buffer_handle, jint buffer) { - PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; + PbufferInfo *Pbuffer_info = (PbufferInfo *)env->GetDirectBufferAddress(buffer_handle); +// PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; wglReleaseTexImageARB(Pbuffer_info->Pbuffer, buffer); } |
|
From: Elias N. <eli...@us...> - 2004-07-25 14:29:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23226/src/native/common Modified Files: org_lwjgl_input_Cursor.h org_lwjgl_input_Mouse.h org_lwjgl_opengl_Pbuffer.h Log Message: Converted Cursor and Pbuffer handles to ByteBuffers Index: org_lwjgl_opengl_Pbuffer.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Pbuffer.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_opengl_Pbuffer.h 24 Jul 2004 19:44:40 -0000 1.9 +++ org_lwjgl_opengl_Pbuffer.h 25 Jul 2004 14:28:50 -0000 1.10 @@ -41,21 +41,23 @@ #define org_lwjgl_opengl_Pbuffer_BACK_RIGHT_BUFFER 8326L #undef org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER #define org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER 8359L +#undef org_lwjgl_opengl_Pbuffer_HANDLE_SIZE +#define org_lwjgl_opengl_Pbuffer_HANDLE_SIZE 24L /* * Class: org_lwjgl_opengl_Pbuffer * Method: nIsBufferLost - * Signature: (I)Z + * Signature: (Ljava/nio/ByteBuffer;)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost - (JNIEnv *, jclass, jint); + (JNIEnv *, jclass, jobject); /* * Class: org_lwjgl_opengl_Pbuffer * Method: nMakeCurrent - * Signature: (I)V + * Signature: (Ljava/nio/ByteBuffer;)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent - (JNIEnv *, jclass, jint); + (JNIEnv *, jclass, jobject); /* * Class: org_lwjgl_opengl_Pbuffer @@ -68,42 +70,42 @@ /* * Class: org_lwjgl_opengl_Pbuffer * Method: nCreate - * Signature: (ZIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)I + * Signature: (Ljava/nio/ByteBuffer;ZIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)V */ -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *, jclass, jboolean, jint, jint, jobject, jobject, jobject); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate + (JNIEnv *, jclass, jobject, jboolean, jint, jint, jobject, jobject, jobject); /* * Class: org_lwjgl_opengl_Pbuffer * Method: nDestroy - * Signature: (I)V + * Signature: (Ljava/nio/ByteBuffer;)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy - (JNIEnv *, jclass, jint); + (JNIEnv *, jclass, jobject); /* * Class: org_lwjgl_opengl_Pbuffer * Method: nSetAttrib - * Signature: (III)V + * Signature: (Ljava/nio/ByteBuffer;II)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib - (JNIEnv *, jclass, jint, jint, jint); + (JNIEnv *, jclass, jobject, jint, jint); /* * Class: org_lwjgl_opengl_Pbuffer * Method: nBindTexImage - * Signature: (II)V + * Signature: (Ljava/nio/ByteBuffer;I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage - (JNIEnv *, jclass, jint, jint); + (JNIEnv *, jclass, jobject, jint); /* * Class: org_lwjgl_opengl_Pbuffer * Method: nReleaseTexImage - * Signature: (II)V + * Signature: (Ljava/nio/ByteBuffer;I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage - (JNIEnv *, jclass, jint, jint); + (JNIEnv *, jclass, jobject, jint); #ifdef __cplusplus } Index: org_lwjgl_input_Mouse.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Mouse.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- org_lwjgl_input_Mouse.h 23 May 2004 14:46:07 -0000 1.16 +++ org_lwjgl_input_Mouse.h 25 Jul 2004 14:28:50 -0000 1.17 @@ -13,10 +13,19 @@ #define org_lwjgl_input_Mouse_CURSOR_8_BIT_ALPHA 2L #undef org_lwjgl_input_Mouse_CURSOR_ANIMATION #define org_lwjgl_input_Mouse_CURSOR_ANIMATION 4L +#undef org_lwjgl_input_Mouse_MAX_SENSITIVITY +#define org_lwjgl_input_Mouse_MAX_SENSITIVITY 8L +#undef org_lwjgl_input_Mouse_MIN_SENSITIVITY +#define org_lwjgl_input_Mouse_MIN_SENSITIVITY 1L +/* Inaccessible static: sensitivity */ +/* Inaccessible static: width */ +/* Inaccessible static: height */ /* Inaccessible static: created */ /* Inaccessible static: buttons */ /* Inaccessible static: x */ /* Inaccessible static: y */ +/* Inaccessible static: scrollX */ +/* Inaccessible static: scrollY */ /* Inaccessible static: coord_buffer */ /* Inaccessible static: dx */ /* Inaccessible static: dy */ @@ -33,6 +42,7 @@ #undef org_lwjgl_input_Mouse_BUFFER_SIZE #define org_lwjgl_input_Mouse_BUFFER_SIZE 50L /* Inaccessible static: isGrabbed */ +/* Inaccessible static: trackingEnabled */ /* * Class: org_lwjgl_input_Mouse * Method: nGetNativeCursorCaps @@ -44,10 +54,10 @@ /* * Class: org_lwjgl_input_Mouse * Method: nSetNativeCursor - * Signature: (J)V + * Signature: (Ljava/nio/ByteBuffer;)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobject); /* * Class: org_lwjgl_input_Mouse Index: org_lwjgl_input_Cursor.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_input_Cursor.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_input_Cursor.h 23 May 2004 14:46:07 -0000 1.9 +++ org_lwjgl_input_Cursor.h 25 Jul 2004 14:28:50 -0000 1.10 @@ -7,21 +7,23 @@ #ifdef __cplusplus extern "C" { #endif +#undef org_lwjgl_input_Cursor_HANDLE_SIZE +#define org_lwjgl_input_Cursor_HANDLE_SIZE 8L /* * Class: org_lwjgl_input_Cursor * Method: nCreateCursor - * Signature: (IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)J + * Signature: (Ljava/nio/ByteBuffer;IIIIILjava/nio/IntBuffer;ILjava/nio/IntBuffer;I)V */ -JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor - (JNIEnv *, jclass, jint, jint, jint, jint, jint, jobject, jint, jobject, jint); +JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor + (JNIEnv *, jclass, jobject, jint, jint, jint, jint, jint, jobject, jint, jobject, jint); /* * Class: org_lwjgl_input_Cursor * Method: nDestroyCursor - * Signature: (J)V + * Signature: (Ljava/nio/ByteBuffer;)V */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *, jclass, jlong); + (JNIEnv *, jclass, jobject); #ifdef __cplusplus } |
|
From: Elias N. <eli...@us...> - 2004-07-25 14:29:00
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23226/src/native/linux Modified Files: org_lwjgl_input_Cursor.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: Converted Cursor and Pbuffer handles to ByteBuffers Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- org_lwjgl_input_Mouse.cpp 24 Jul 2004 19:44:41 -0000 1.57 +++ org_lwjgl_input_Mouse.cpp 25 Jul 2004 14:28:50 -0000 1.58 @@ -202,10 +202,11 @@ return caps; } -JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor (JNIEnv *env, jclass clazz, jlong cursor_handle) { - if (cursor_handle != 0) { - Cursor cursor = (Cursor)cursor_handle; - current_cursor = cursor; +JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jobject cursor_handle) { + if (cursor_handle != NULL) { + Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(cursor_handle); +// Cursor cursor = (Cursor)cursor_handle; + current_cursor = *cursor; } else current_cursor = None; updateCursor(); Index: org_lwjgl_input_Cursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Cursor.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_input_Cursor.cpp 7 Jul 2004 10:31:26 -0000 1.13 +++ org_lwjgl_input_Cursor.cpp 25 Jul 2004 14:28:50 -0000 1.14 @@ -44,17 +44,16 @@ #include "Window.h" #include "common_tools.h" -/* - * Class: org_lwjgl_input_Cursor - * Method: nCreateCursor - * Signature: (IIIIIII)I - */ -JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor - (JNIEnv *env, jclass clazz, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) +JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor + (JNIEnv *env, jclass clazz, jobject handle_buffer, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { + if (env->GetDirectBufferCapacity(handle_buffer) < sizeof(Cursor)) { + throwException(env, "Handle buffer not large enough"); + return; + } Display *disp = incDisplay(env); if (disp == NULL) - return 0; + return; const int *delays = NULL; if (delay_buffer != NULL) delays = (const int *)env->GetDirectBufferAddress(delay_buffer) + delays_offset; @@ -74,20 +73,16 @@ cursor_image->delay = delays[i]; cursor_images->images[i] = cursor_image; } - Cursor cursor = XcursorImagesLoadCursor(disp, cursor_images); + Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(handle_buffer); + *cursor = XcursorImagesLoadCursor(disp, cursor_images); XcursorImagesDestroy(cursor_images); - return (jlong)cursor; } -/* - * Class: org_lwjgl_input_Cursor - * Method: nDestroyCursor - * Signature: (I)V - */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor - (JNIEnv *env, jclass clazz, jlong cursor_handle) + (JNIEnv *env, jclass clazz, jobject cursor_handle_buffer) { - Cursor cursor = (Cursor)cursor_handle; - XFreeCursor(getDisplay(), cursor); + Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(cursor_handle_buffer); +// Cursor cursor = (Cursor)cursor_handle; + XFreeCursor(getDisplay(), *cursor); decDisplay(); } Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 21:19:08 -0000 1.22 +++ org_lwjgl_opengl_Pbuffer.cpp 25 Jul 2004 14:28:50 -0000 1.23 @@ -52,7 +52,7 @@ } PbufferInfo; JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost - (JNIEnv *env, jclass clazz, jint handle) + (JNIEnv *env, jclass clazz, jobject handle_buffer) { // The buffer is never lost, because of the GLX_PRESERVED_CONTENTS flag return JNI_FALSE; @@ -71,7 +71,7 @@ glXDestroyPbuffer(getDisplay(), buffer); if (!buffer_info->use_display_context) glXDestroyContext(getDisplay(), context); - free(buffer_info); +// free(buffer_info); decDisplay(); } @@ -147,17 +147,17 @@ return true; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jboolean use_display_context, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs) +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jobject handle_buffer, jboolean use_display_context, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs) { Display *disp = incDisplay(env); if (disp == NULL) { - return -1; + return; } int current_screen = XDefaultScreen(disp); if (!extgl_InitGLX(env, disp, current_screen)) { decDisplay(); throwException(env, "Could not init GLX"); - return -1; + return; } const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width, @@ -166,7 +166,12 @@ GLX_LARGEST_PBUFFER, False, None, None}; - PbufferInfo *buffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo)); + if (env->GetDirectBufferCapacity(handle_buffer) < sizeof(PbufferInfo)) { + throwException(env, "Handle buffer not large enough"); + return; + } + PbufferInfo *buffer_info = (PbufferInfo *)env->GetDirectBufferAddress(handle_buffer); +// PbufferInfo *buffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo)); buffer_info->use_display_context = use_display_context; bool result; if (use_display_context) { @@ -175,18 +180,18 @@ result = createPbufferUsingUniqueContext(env, buffer_info, pixel_format, width, height, buffer_attribs); } if (!result) - return -1; + return; if (!checkXError(env)) { destroyPbuffer(buffer_info); - return -1; + return; } - return (jint)buffer_info; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nMakeCurrent - (JNIEnv *env, jclass clazz, jint handle) + (JNIEnv *env, jclass clazz, jobject handle_buffer) { - PbufferInfo *buffer_info = (PbufferInfo *)handle; + PbufferInfo *buffer_info = (PbufferInfo *)env->GetDirectBufferAddress(handle_buffer); + //PbufferInfo *buffer_info = (PbufferInfo *)handle; GLXPbuffer buffer = buffer_info->buffer; GLXContext context = buffer_info->context; if (glXMakeContextCurrent(getDisplay(), buffer, buffer, context) == False) { @@ -200,26 +205,27 @@ * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nDestroy - (JNIEnv *env, jclass clazz, jint handle) + (JNIEnv *env, jclass clazz, jobject handle_buffer) { - PbufferInfo *buffer_info = (PbufferInfo *)handle; + PbufferInfo *buffer_info = (PbufferInfo *)env->GetDirectBufferAddress(handle_buffer); + //PbufferInfo *buffer_info = (PbufferInfo *)handle; destroyPbuffer(buffer_info); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nSetAttrib - (JNIEnv *env, jclass clazz, jint handle, jint attrib, jint value) + (JNIEnv *env, jclass clazz, jobject handle_buffer, jint attrib, jint value) { throwException(env, "The render-to-texture extension is not supported."); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nBindTexImage - (JNIEnv *env, jclass clazz, jint handle, jint buffer) + (JNIEnv *env, jclass clazz, jobject handle_buffer, jint buffer) { throwException(env, "The render-to-texture extension is not supported."); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseTexImage - (JNIEnv *env, jclass clazz, jint handle, jint buffer) + (JNIEnv *env, jclass clazz, jobject handle_buffer, jint buffer) { throwException(env, "The render-to-texture extension is not supported."); } |
|
From: Elias N. <eli...@us...> - 2004-07-25 14:28:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23226/src/java/org/lwjgl/opengl Modified Files: Pbuffer.java Log Message: Converted Cursor and Pbuffer handles to ByteBuffers Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Pbuffer.java 25 Jul 2004 07:00:55 -0000 1.25 +++ Pbuffer.java 25 Jul 2004 14:28:49 -0000 1.26 @@ -32,9 +32,11 @@ package org.lwjgl.opengl; import org.lwjgl.Sys; +import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import java.nio.IntBuffer; +import java.nio.ByteBuffer; /** * $Id$ @@ -135,9 +137,14 @@ public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV; /** + * The maximum number of bytes in the native handle + */ + private final static int HANDLE_SIZE = 24; + + /** * Handle to the native GL rendering context */ - private final int handle; + private final ByteBuffer handle; /** * Width @@ -183,7 +190,7 @@ public static Pbuffer createPbufferUsingDisplayContext(int width, int height, RenderTexture renderTexture) throws LWJGLException { if (!Display.isCreated()) throw new IllegalStateException("The Display must be created before a shared Pbuffer can be created that use the Display context"); - int handle = createPbuffer(true, width, height, null, renderTexture); + ByteBuffer handle = createPbuffer(true, width, height, null, renderTexture); return new Pbuffer(width, height, Display.getContext(), handle); } @@ -206,26 +213,28 @@ * @param renderTexture */ public static Pbuffer createPbufferUsingUniqueContext(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { - int handle = createPbuffer(false, width, height, pixel_format, renderTexture); + ByteBuffer handle = createPbuffer(false, width, height, pixel_format, renderTexture); return new Pbuffer(width, height, null, handle); } - private Pbuffer(int width, int height, Object display_context, int handle) { + private Pbuffer(int width, int height, Object display_context, ByteBuffer handle) { this.width = width; this.height = height; this.display_context = display_context; this.handle = handle; } - private static int createPbuffer(boolean use_display_context, int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { + private static ByteBuffer createPbuffer(boolean use_display_context, int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { GLContext.loadOpenGLLibrary(); try { + ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE); if ( renderTexture == null ) - return nCreate(use_display_context, width, height, pixel_format, null, null); + nCreate(handle, use_display_context, width, height, pixel_format, null, null); else - return nCreate(use_display_context, width, height, pixel_format, + nCreate(handle, use_display_context, width, height, pixel_format, renderTexture.pixelFormatCaps, renderTexture.pBufferAttribs); + return handle; } catch (LWJGLException e) { GLContext.unloadOpenGLLibrary(); throw e; @@ -246,7 +255,7 @@ /** * Native method to test for buffer integrity */ - private static native boolean nIsBufferLost(int handle); + private static native boolean nIsBufferLost(ByteBuffer handle); /** * Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer. @@ -263,7 +272,7 @@ /** * Native method to make a pbuffer current. */ - private static native void nMakeCurrent(int handle) throws LWJGLException; + private static native void nMakeCurrent(ByteBuffer handle) throws LWJGLException; /** * Gets the Pbuffer capabilities. @@ -275,7 +284,7 @@ /** * Native method to create a Pbuffer */ - private static native int nCreate(boolean shared, int width, int height, PixelFormat pixel_format, + private static native void nCreate(ByteBuffer handle, boolean shared, int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException; @@ -300,7 +309,7 @@ /** * Natively destroy any GL-related stuff */ - private static native void nDestroy(int handle); + private static native void nDestroy(ByteBuffer handle); // ----------------------------------------------------------------------------------------- // ------------------------------- Render-to-Texture Methods ------------------------------- @@ -322,7 +331,7 @@ nSetAttrib(handle, attrib, value); } - private static native void nSetAttrib(int handle, int attrib, int value); + private static native void nSetAttrib(ByteBuffer handle, int attrib, int value); /** * Binds the currently bound texture to the buffer specified. The buffer can be one of the following: @@ -335,7 +344,7 @@ nBindTexImage(handle, buffer); } - private static native void nBindTexImage(int handle, int buffer); + private static native void nBindTexImage(ByteBuffer handle, int buffer); /** * Releases the currently bound texture from the buffer specified. @@ -346,7 +355,7 @@ nReleaseTexImage(handle, buffer); } - private static native void nReleaseTexImage(int handle, int buffer); + private static native void nReleaseTexImage(ByteBuffer handle, int buffer); /** * @return Returns the height. |
|
From: Elias N. <eli...@us...> - 2004-07-25 14:28:58
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23226/src/java/org/lwjgl/input Modified Files: Cursor.java Mouse.java Log Message: Converted Cursor and Pbuffer handles to ByteBuffers Index: Cursor.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Cursor.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Cursor.java 5 Jul 2004 14:06:39 -0000 1.27 +++ Cursor.java 25 Jul 2004 14:28:49 -0000 1.28 @@ -32,10 +32,10 @@ package org.lwjgl.input; import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferUtils; import org.lwjgl.Sys; /** @@ -49,8 +49,9 @@ */ public class Cursor { + private final static int HANDLE_SIZE = 8; /** First element to display */ - private CursorElement[] cursors = null; + private final CursorElement[] cursors; /** Index into list of cursors */ private int index = 0; @@ -88,15 +89,15 @@ yHotspot = height - 1 - yHotspot; // create cursor (or cursors if multiple images supplied) - createCursors(width, height, xHotspot, yHotspot, numImages, images, delays); + cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays); } /** * Creates the actual cursor, using a platform specific class */ - private void createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + private static CursorElement[] createCursors(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { // create copy and flip images to match ogl - IntBuffer images_copy = ByteBuffer.allocateDirect(images.remaining()*4).order(ByteOrder.nativeOrder()).asIntBuffer(); + IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining()); flipImages(width, height, numImages, images, images_copy); // Win32 doesn't (afaik) allow for animation based cursors, except when they're @@ -107,25 +108,30 @@ // might want to split it into a X/Win/Mac cursor if it gets too cluttered String osName = System.getProperty("os.name", ""); + CursorElement[] cursors; if (osName.startsWith("Win")) { // create our cursor elements cursors = new CursorElement[numImages]; for(int i=0; i<numImages; i++) { - cursors[i] = new CursorElement(); - cursors[i].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, 1, images_copy, images_copy.position(), null, 0); - cursors[i].delay = (delays != null) ? delays.get(i) : 0; - cursors[i].timeout = System.currentTimeMillis(); + ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE); + nCreateCursor(handle, width, height, xHotspot, yHotspot, 1, images_copy, images_copy.position(), null, 0); + long delay = (delays != null) ? delays.get(i) : 0; + long timeout = System.currentTimeMillis(); + cursors[i] = new CursorElement(handle, delay, timeout); // offset to next image images_copy.position(width*height*(i+1)); } } else if (osName.startsWith("Lin")) { // create our cursor elements - cursors = new CursorElement[1]; - cursors[0] = new CursorElement(); - cursors[0].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, numImages, images_copy, images_copy.position(), delays, delays != null ? delays.position() : -1); + ByteBuffer handle = BufferUtils.createByteBuffer(HANDLE_SIZE); + nCreateCursor(handle, width, height, xHotspot, yHotspot, numImages, images_copy, images_copy.position(), delays, delays != null ? delays.position() : -1); + CursorElement cursor_element = new CursorElement(handle, -1, -1); + cursors = new CursorElement[]{cursor_element}; } else { + throw new RuntimeException("Unknown OS"); } + return cursors; } /** @@ -168,7 +174,7 @@ /** * Gets the native handle associated with the cursor object. */ - public long getHandle() { + ByteBuffer getHandle() { return cursors[index].cursorHandle; } @@ -215,24 +221,30 @@ /** * Native method to create a native cursor */ - private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset); + private static native void nCreateCursor(ByteBuffer handle, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException; /** * Native method to destroy a native cursor */ - private static native void nDestroyCursor(long cursorHandle); + private static native void nDestroyCursor(ByteBuffer cursorHandle); /** * A single cursor element, used when animating */ - protected class CursorElement { + private static class CursorElement { /** Handle to cursor */ - long cursorHandle; + final ByteBuffer cursorHandle; /** How long a delay this element should have */ - long delay; + final long delay; /** Absolute time this element times out */ long timeout; + + CursorElement(ByteBuffer cursorHandle, long delay, long timeout) { + this.cursorHandle = cursorHandle; + this.delay = delay; + this.timeout = timeout; + } } } Index: Mouse.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/input/Mouse.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- Mouse.java 17 Jul 2004 09:38:20 -0000 1.63 +++ Mouse.java 25 Jul 2004 14:28:49 -0000 1.64 @@ -200,14 +200,14 @@ nSetNativeCursor(currentCursor.getHandle()); currentCursor.setTimeout(); } else { - nSetNativeCursor(0); + nSetNativeCursor(null); } } return oldCursor; } /** Native method to set the native cursor */ - private static native void nSetNativeCursor(long handle) throws LWJGLException; + private static native void nSetNativeCursor(ByteBuffer handle) throws LWJGLException; /** * Gets the minimum size of a native cursor. Can only be called if |
|
From: Elias N. <eli...@us...> - 2004-07-25 07:01:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26242/src/java/org/lwjgl/opengl Modified Files: Pbuffer.java Log Message: Make Pbuffer.createPbufferUsingDisplayContext take a RenderTexture parameter Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- Pbuffer.java 24 Jul 2004 20:05:51 -0000 1.24 +++ Pbuffer.java 25 Jul 2004 07:00:55 -0000 1.25 @@ -171,7 +171,7 @@ * Create an instance of a Pbuffer using the Display context. The buffer is double-buffered, like the Display. * <p/> * NOTE: The Pbuffer will use the same context as the Display and requires that the Display has been created. Therefore, - * no pixel format or render to texture parameters can be specified. All OpenGL state, + * no separate pixel format can be specified. All OpenGL state, * including display lists, textures etc. is shared between the Pbuffer and the Display. If the Display is destroyed, * the Pbuffer will not be usable, even if the Display is created again. * <p/> @@ -180,10 +180,10 @@ * @param width Pbuffer width * @param height Pbuffer height */ - public static Pbuffer createPbufferUsingDisplayContext(int width, int height) throws LWJGLException { + public static Pbuffer createPbufferUsingDisplayContext(int width, int height, RenderTexture renderTexture) throws LWJGLException { if (!Display.isCreated()) throw new IllegalStateException("The Display must be created before a shared Pbuffer can be created that use the Display context"); - int handle = createPbuffer(true, width, height, null, null); + int handle = createPbuffer(true, width, height, null, renderTexture); return new Pbuffer(width, height, Display.getContext(), handle); } |
|
From: Elias N. <eli...@us...> - 2004-07-24 22:17:12
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2459/linux Modified Files: org_lwjgl_opengl_Display.cpp Log Message: Make setting keyboard rate use own X connection Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_opengl_Display.cpp 24 Jul 2004 19:44:41 -0000 1.12 +++ org_lwjgl_opengl_Display.cpp 24 Jul 2004 22:17:03 -0000 1.13 @@ -166,7 +166,13 @@ static void setRepeatMode(int mode) { XKeyboardControl repeat_mode; repeat_mode.auto_repeat_mode = mode; - XChangeKeyboardControl(getDisplay(), KBAutoRepeatMode, &repeat_mode); + Display *disp = XOpenDisplay(NULL); + if (disp == NULL) { + printfDebug("Could not open display to set repeat mode\n"); + return; + } + XChangeKeyboardControl(disp, KBAutoRepeatMode, &repeat_mode); + XCloseDisplay(disp); } bool releaseInput(void) { @@ -281,11 +287,11 @@ } static void destroyWindow(void) { - setRepeatMode(AutoRepeatModeDefault); if (USEGLX13) glXDestroyWindow(getDisplay(), glx_window); XDestroyWindow(getDisplay(), current_win); XFreeColormap(getDisplay(), cmap); + setRepeatMode(AutoRepeatModeDefault); } static bool createWindow(JNIEnv* env, int width, int height) { |
|
From: Elias N. <eli...@us...> - 2004-07-24 22:06:52
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv825/src/native/win32 Modified Files: Window.h org_lwjgl_opengl_Display.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: Avoid ARB_pixel_format in Display whereever possible. Must try the path once though, to increase the chance of getting a pbuffer compatible context. If it fails, the normal path context is kept, in hope that it will support pbuffers. If not, only unique context pbuffers will be available. Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- org_lwjgl_opengl_Display.cpp 24 Jul 2004 21:19:08 -0000 1.16 +++ org_lwjgl_opengl_Display.cpp 24 Jul 2004 22:06:43 -0000 1.17 @@ -65,16 +65,14 @@ #define WINDOWCLASSNAME "LWJGL" -bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat) { +bool applyPixelFormat(HDC hdc, int iPixelFormat) { PIXELFORMATDESCRIPTOR desc; if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) { - throwException(env, "Could not describe pixel format"); return false; } // make that the pixel format of the device context if (SetPixelFormat(hdc, iPixelFormat, &desc) == FALSE) { - throwException(env, "Failed to set pixel format"); return false; } return true; @@ -420,13 +418,12 @@ * * Returns true for success, or false for failure */ -HWND createWindow(JNIEnv *env, int width, int height, bool fullscreen, bool undecorated) +HWND createWindow(int width, int height, bool fullscreen, bool undecorated) { int exstyle, windowflags; // 1. Register window class if necessary if (!registerWindow()) { - throwException(env, "Could not register window class"); return NULL; } @@ -467,11 +464,6 @@ dll_handle, NULL); - if (new_hwnd == NULL) { - throwException(env, "Failed to create the window."); - return NULL; - } - return new_hwnd; } @@ -635,13 +627,15 @@ int width = env->GetIntField(mode, fid_width); int height = env->GetIntField(mode, fid_height); - display_hwnd = createWindow(env, width, height, isFullScreen, isUndecorated); + display_hwnd = createWindow(width, height, isFullScreen, isUndecorated); if (display_hwnd == NULL) { + throwException(env, "Failed to create the window."); return; } display_hdc = GetDC(display_hwnd); - if (!applyPixelFormat(env, display_hdc, pixel_format_index)) { + if (!applyPixelFormat(display_hdc, pixel_format_index)) { closeWindow(display_hwnd, display_hdc); + throwException(env, "Could not apply pixel format to window"); return; } @@ -690,9 +684,37 @@ return initDisplay(env); } +static bool createARBContextAndPixelFormat(JNIEnv *env, HDC hdc, jobject pixel_format, int *pixel_format_index_return, HGLRC *context_return) { + // 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 (!extgl_Extensions.WGL_ARB_pixel_format) + return false; + int 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; + } + HWND arb_hwnd = createWindow(1, 1, false, false); + if (arb_hwnd == NULL) + return false; + HDC arb_hdc = GetDC(arb_hwnd); + if (!applyPixelFormat(arb_hdc, pixel_format_index)) { + closeWindow(arb_hwnd, arb_hdc); + return false; + } + HGLRC arb_context = wglCreateContext(arb_hdc); + 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_Display_createContext(JNIEnv *env, jclass clazz, jobject pixel_format) { - HWND dummy_hwnd = createWindow(env, 1, 1, false, false); + HWND dummy_hwnd = createWindow(1, 1, false, false); if (dummy_hwnd == NULL) { + throwException(env, "Failed to create the window."); return; } HDC dummy_hdc = GetDC(dummy_hwnd); @@ -700,11 +722,11 @@ if (pixel_format_index == -1) { return; } - if (!applyPixelFormat(env, dummy_hdc, pixel_format_index)) { + 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); @@ -719,40 +741,19 @@ return; } extgl_InitWGL(env); - // 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 (extgl_Extensions.WGL_ARB_pixel_format) { - pixel_format_index = findPixelFormatARB(env, dummy_hdc, pixel_format, NULL, true, true, true, true); - if (pixel_format_index == -1) { - pixel_format_index = findPixelFormatARB(env, dummy_hdc, pixel_format, NULL, true, true, false, true); - } - closeWindow(dummy_hwnd, dummy_hdc); - if (pixel_format_index == -1) { - jclass cls_pixel_format = env->GetObjectClass(pixel_format); - int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I")); - if (samples > 0) - throwException(env, "Could not find suitable pixel format"); - return; - } + 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); + int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I")); + if (arb_success) { wglDeleteContext(display_hglrc); - dummy_hwnd = createWindow(env, 1, 1, false, false); - if (dummy_hwnd == NULL) { - return; - } - dummy_hdc = GetDC(dummy_hwnd); - if (!applyPixelFormat(env, dummy_hdc, pixel_format_index)) { - closeWindow(dummy_hwnd, dummy_hdc); - return; - } - display_hglrc = wglCreateContext(dummy_hdc); - closeWindow(dummy_hwnd, dummy_hdc); - if (display_hglrc == NULL) { - throwException(env, "Failed to create OpenGL rendering context (ARB)"); - return; - } - } else { - closeWindow(dummy_hwnd, dummy_hdc); + display_hglrc = context_arb; + pixel_format_index = pixel_format_index_arb; + } else if (samples > 0) { + wglDeleteContext(display_hglrc); + throwException(env, "Samples > 0 but could not finc a suitable ARB pixel format"); } } Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Window.h 24 Jul 2004 21:19:08 -0000 1.14 +++ Window.h 24 Jul 2004 22:06:43 -0000 1.15 @@ -68,7 +68,7 @@ WINDOW_H_API int getCurrentPixelFormat(); - WINDOW_H_API bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat); + WINDOW_H_API bool applyPixelFormat(HDC hdc, int iPixelFormat); WINDOW_H_API void closeWindow(HWND hwnd, HDC hdc); @@ -89,7 +89,7 @@ * * Returns true for success, or false for failure */ - WINDOW_H_API HWND createWindow(JNIEnv *env, int width, int height, bool fullscreen, bool undecorated); + WINDOW_H_API HWND createWindow(int width, int height, bool fullscreen, bool undecorated); /* Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 21:19:08 -0000 1.14 +++ org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 22:06:43 -0000 1.15 @@ -80,8 +80,9 @@ } static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pixel_format, jobject pixelFormatCaps, const int *pBufferAttribs_ptr) { - HWND dummy_hwnd = createWindow(env, 1, 1, false, false); + HWND dummy_hwnd = createWindow(1, 1, false, false); if (dummy_hwnd == NULL) { + throwException(env, "Could not create dummy window"); return NULL; } HDC dummy_hdc = GetDC(dummy_hwnd); @@ -89,8 +90,9 @@ if (iPixelFormat == -1) { return NULL; } - if (!applyPixelFormat(env, dummy_hdc, iPixelFormat)) { + if (!applyPixelFormat(dummy_hdc, iPixelFormat)) { closeWindow(dummy_hwnd, dummy_hdc); + throwException(env, "Could not apply pixel format to window"); return NULL; } |
|
From: Elias N. <eli...@us...> - 2004-07-24 21:19:18
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27483/src/native/win32 Modified Files: Window.h org_lwjgl_opengl_Display.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: Win32 part of fast Pbuffer Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- org_lwjgl_opengl_Display.cpp 7 Jul 2004 09:40:48 -0000 1.15 +++ org_lwjgl_opengl_Display.cpp 24 Jul 2004 21:19:08 -0000 1.16 @@ -50,8 +50,8 @@ static bool oneShotInitialised = false; // Registers the LWJGL window class HWND display_hwnd = NULL; // Handle to the window -HDC display_hdc = NULL; // Device context -HGLRC display_hglrc = NULL; // OpenGL context +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 @@ -80,7 +80,19 @@ return true; } -static int findPixelFormatARBFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, int bpp, bool window, bool double_buffer) { +HGLRC getCurrentContext() { + 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) { jclass cls_pixel_format = env->GetObjectClass(pixel_format); int alpha = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "alpha", "I")); int depth = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "depth", "I")); @@ -96,7 +108,8 @@ initAttribList(&attrib_list); if (window) { putAttrib(&attrib_list, WGL_DRAW_TO_WINDOW_ARB); putAttrib(&attrib_list, TRUE); - } else { + } + 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); @@ -117,7 +130,6 @@ putAttrib(&attrib_list, WGL_AUX_BUFFERS_ARB); putAttrib(&attrib_list, num_aux_buffers); if ( pixelFormatCaps != NULL ) { if ( !extgl_Extensions.WGL_ARB_render_texture ) { - throwException(env, "The render-to-texture extension is not supported."); return -1; } @@ -131,25 +143,24 @@ BOOL result = wglChoosePixelFormatARB(hdc, attrib_list.attribs, NULL, 1, &iPixelFormat, &num_formats_returned); if (result == FALSE || num_formats_returned < 1) { - throwException(env, "Could not choose ARB pixel formats."); return -1; } return iPixelFormat; } -int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool double_buffer) { +int findPixelFormatARB(JNIEnv *env, HDC hdc, jobject pixel_format, jobject pixelFormatCaps, bool use_hdc_bpp, bool window, bool pbuffer, bool double_buffer) { int bpp; jclass cls_pixel_format = env->GetObjectClass(pixel_format); if (use_hdc_bpp) { bpp = GetDeviceCaps(hdc, BITSPIXEL); - int iPixelFormat = findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, double_buffer); + int 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(pixel_format, env->GetFieldID(cls_pixel_format, "bpp", "I")); - return findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, double_buffer); + return findPixelFormatARBFromBPP(env, hdc, pixel_format, pixelFormatCaps, bpp, window, pbuffer, double_buffer); } /* @@ -708,19 +719,23 @@ return; } extgl_InitWGL(env); - jclass cls_pixel_format = env->GetObjectClass(pixel_format); - int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I")); // 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 (samples > 0 && extgl_Extensions.WGL_ARB_pixel_format) { - pixel_format_index = findPixelFormatARB(env, dummy_hdc, pixel_format, NULL, true, true, true); - wglMakeCurrent(NULL, NULL); - wglDeleteContext(display_hglrc); + if (extgl_Extensions.WGL_ARB_pixel_format) { + pixel_format_index = findPixelFormatARB(env, dummy_hdc, pixel_format, NULL, true, true, true, true); + if (pixel_format_index == -1) { + pixel_format_index = findPixelFormatARB(env, dummy_hdc, pixel_format, NULL, true, true, false, true); + } closeWindow(dummy_hwnd, dummy_hdc); if (pixel_format_index == -1) { + jclass cls_pixel_format = env->GetObjectClass(pixel_format); + int samples = (int)env->GetIntField(pixel_format, env->GetFieldID(cls_pixel_format, "samples", "I")); + if (samples > 0) + throwException(env, "Could not find suitable pixel format"); return; } + wglDeleteContext(display_hglrc); dummy_hwnd = createWindow(env, 1, 1, false, false); if (dummy_hwnd == NULL) { return; @@ -736,8 +751,9 @@ throwException(env, "Failed to create OpenGL rendering context (ARB)"); return; } - } else + } else { closeWindow(dummy_hwnd, dummy_hdc); + } } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_destroyContext(JNIEnv *env, jclass clazz) { Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/Window.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Window.h 6 Jul 2004 07:50:32 -0000 1.13 +++ Window.h 24 Jul 2004 21:19:08 -0000 1.14 @@ -53,14 +53,20 @@ #define WINDOW_H_API extern extern HWND display_hwnd; // Handle to the window - extern HDC display_hdc; // Device context +// extern HDC display_hdc; // Device context extern bool isFullScreen; // Whether we're fullscreen or not extern bool isMinimized; // Whether we're minimized or not extern bool isFocused; // Whether we're focused or not extern bool isDirty; // Whether we're dirty or not extern RECT clientSize; - extern HGLRC display_hglrc; - #endif /* _PRIVATE_WINDOW_H_ */ +// extern HGLRC display_hglrc; + #endif /* _PRIVATE_WINDOW_H_ */ + + WINDOW_H_API HDC getCurrentWindowDC(); + + WINDOW_H_API HGLRC getCurrentContext(); + + WINDOW_H_API int getCurrentPixelFormat(); WINDOW_H_API bool applyPixelFormat(JNIEnv *env, HDC hdc, int iPixelFormat); @@ -74,7 +80,7 @@ /* * 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 double_buffer); + 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); /* * Create a window with the specified title, position, size, and Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_opengl_Pbuffer.cpp 6 Jul 2004 07:50:33 -0000 1.13 +++ org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 21:19:08 -0000 1.14 @@ -49,13 +49,10 @@ #include "common_tools.h" typedef struct _PbufferInfo { - HGLRC Pbuffer_context; - HPBUFFERARB Pbuffer; - HDC Pbuffer_dc; - + bool use_display_context; } PbufferInfo; /* @@ -82,72 +79,80 @@ return caps; } -/* - * Class: org_lwjgl_opengl_Pbuffer - * Method: nCreate - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *env, jclass clazz, - jint width, jint height, jobject pixel_format, - jobject pixelFormatCaps, jobject pBufferAttribs) -{ +static HPBUFFERARB createPbuffer(JNIEnv *env, int width, int height, jobject pixel_format, jobject pixelFormatCaps, const int *pBufferAttribs_ptr) { HWND dummy_hwnd = createWindow(env, 1, 1, false, false); if (dummy_hwnd == NULL) { - return (jint)NULL; + return NULL; } HDC dummy_hdc = GetDC(dummy_hwnd); int iPixelFormat = findPixelFormat(env, dummy_hdc, pixel_format); if (iPixelFormat == -1) { - return (jint)NULL; + return NULL; } if (!applyPixelFormat(env, dummy_hdc, iPixelFormat)) { closeWindow(dummy_hwnd, dummy_hdc); - return (jint)NULL; + return NULL; } HGLRC dummy_hglrc = wglCreateContext(dummy_hdc); if (dummy_hglrc == NULL) { closeWindow(dummy_hwnd, dummy_hdc); throwException(env, "Failed to create OpenGL rendering context"); - return (jint)NULL; + return NULL; } BOOL 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 (jint)NULL; + return NULL; } extgl_InitWGL(env); - iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, false); + iPixelFormat = findPixelFormatARB(env, dummy_hdc, pixel_format, pixelFormatCaps, false, false, true, false); + wglDeleteContext(dummy_hglrc); if (iPixelFormat == -1) { - wglDeleteContext(dummy_hglrc); closeWindow(dummy_hwnd, dummy_hdc); - throwException(env, "Could not choose pixel formats."); - return (jint)NULL; + throwException(env, "Could not find suitable pixel format."); + return NULL; } + HPBUFFERARB Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribs_ptr); + closeWindow(dummy_hwnd, dummy_hdc); + return Pbuffer; +} - HPBUFFERARB Pbuffer; +static HGLRC createPbufferContext(JNIEnv *env, HDC Pbuffer_dc) { + HGLRC Pbuffer_context = wglCreateContext(Pbuffer_dc); + if (Pbuffer_context == NULL) { + throwException(env, "Failed to create Pbuffer rendering context"); + return NULL; + } + if (getCurrentContext() != NULL && !wglShareLists(getCurrentContext(), Pbuffer_context)) { + wglDeleteContext(Pbuffer_context); + throwException(env, "Could not share buffer context."); + return NULL; + } + return Pbuffer_context; +} +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate + (JNIEnv *env, jclass clazz, jboolean use_display_context, + jint width, jint height, jobject pixel_format, + jobject pixelFormatCaps, jobject pBufferAttribs) +{ + HPBUFFERARB Pbuffer; + const int *pBufferAttribs_ptr; if ( pBufferAttribs != NULL ) { - GLuint *pBufferAttribs_ptr = (GLuint *)env->GetDirectBufferAddress(pBufferAttribs); - jlong pBufferAttribsSize = env->GetDirectBufferCapacity(pBufferAttribs); - - int pBufferAttribList[9]; - - jlong i; - for ( i = 0; i < pBufferAttribsSize; ) - pBufferAttribList[i++] = pBufferAttribs_ptr[i]; - - pBufferAttribList[i] = 0; - - Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, pBufferAttribList); + pBufferAttribs_ptr = (const int *)env->GetDirectBufferAddress(pBufferAttribs); } else { - Pbuffer = wglCreatePbufferARB(dummy_hdc, iPixelFormat, width, height, NULL); + pBufferAttribs_ptr = NULL; + } + if (use_display_context) { + int iPixelFormat = getCurrentPixelFormat(); + Pbuffer = wglCreatePbufferARB(getCurrentWindowDC(), iPixelFormat, width, height, pBufferAttribs_ptr); + } else { + Pbuffer = createPbuffer(env, width, height, pixel_format, pixelFormatCaps, pBufferAttribs_ptr); } - wglDeleteContext(dummy_hglrc); - closeWindow(dummy_hwnd, dummy_hdc); if (Pbuffer == NULL) { throwException(env, "Could not create Pbuffer."); @@ -160,38 +165,26 @@ throwException(env, "Could not get Pbuffer dc."); return (jint)NULL; } - - // Create a rendering context - HGLRC Pbuffer_context = wglCreateContext(Pbuffer_dc); - if (Pbuffer_context == NULL) { - wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc); - wglDestroyPbufferARB(Pbuffer); - throwException(env, "Failed to create Pbuffer rendering context"); - return (jint)NULL; - } - - if (display_hglrc != NULL && !wglShareLists(display_hglrc, Pbuffer_context)) { - wglDeleteContext(Pbuffer_context); - wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc); - wglDestroyPbufferARB(Pbuffer); - throwException(env, "Could not share buffer context."); - return (jint)NULL; + HGLRC Pbuffer_context; + if (use_display_context) { + Pbuffer_context = getCurrentContext(); + } else { + Pbuffer_context = createPbufferContext(env, Pbuffer_dc); + if (Pbuffer_context == NULL) { + wglReleasePbufferDCARB(Pbuffer, Pbuffer_dc); + wglDestroyPbufferARB(Pbuffer); + return (jint)NULL; + } } PbufferInfo *Pbuffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo)); Pbuffer_info->Pbuffer = Pbuffer; Pbuffer_info->Pbuffer_context = Pbuffer_context; Pbuffer_info->Pbuffer_dc = Pbuffer_dc; - + Pbuffer_info->use_display_context = use_display_context == JNI_TRUE; return (jint)Pbuffer_info; } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Pbuffer_nReleaseContext - (JNIEnv *env, jclass clazz) -{ - wglMakeCurrent(display_hdc, display_hglrc); -} - JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost (JNIEnv *env, jclass clazz, jint handle) { @@ -213,7 +206,8 @@ (JNIEnv *env, jclass clazz, jint handle) { PbufferInfo *Pbuffer_info = (PbufferInfo *)handle; - wglDeleteContext(Pbuffer_info->Pbuffer_context); + if (!Pbuffer_info->use_display_context) + wglDeleteContext(Pbuffer_info->Pbuffer_context); wglReleasePbufferDCARB(Pbuffer_info->Pbuffer, Pbuffer_info->Pbuffer_dc); wglDestroyPbufferARB(Pbuffer_info->Pbuffer); free(Pbuffer_info); |
|
From: Elias N. <eli...@us...> - 2004-07-24 21:19:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27483/src/native/linux Modified Files: Window.h org_lwjgl_opengl_Pbuffer.cpp Log Message: Win32 part of fast Pbuffer Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Window.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Window.h 24 Jul 2004 19:44:41 -0000 1.17 +++ Window.h 24 Jul 2004 21:19:08 -0000 1.18 @@ -130,10 +130,4 @@ * convert bit-per-pixel to bits-per-element */ extern int convertToBPE(int bpp); - - /* - * Return the current OpenGL window context - */ - GLXContext getCurrentContext(void); - #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 19:44:41 -0000 1.21 +++ org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 21:19:08 -0000 1.22 @@ -108,7 +108,7 @@ XFree(configs); return false; } - GLXContext context = glXCreateNewContext(getDisplay(), configs[0], GLX_RGBA_TYPE, getCurrentContext(), True); + GLXContext context = glXCreateNewContext(getDisplay(), configs[0], GLX_RGBA_TYPE, getCurrentGLXContext(), True); if (context == NULL) { XFree(configs); throwException(env, "Could not create a GLX context"); |
|
From: Elias N. <eli...@us...> - 2004-07-24 20:06:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17472 Modified Files: Pbuffer.java Log Message: Fixed typo Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Pbuffer.java 24 Jul 2004 19:50:50 -0000 1.23 +++ Pbuffer.java 24 Jul 2004 20:05:51 -0000 1.24 @@ -254,7 +254,7 @@ */ public synchronized void makeCurrent() throws LWJGLException { if (display_context != null && display_context != Display.getContext()) - throw new IllegalStateException("Cannot make a Pbuffer invalid after the Display has been destroyed"); + throw new IllegalStateException("Cannot make a Pbuffer current after the Display has been destroyed"); nMakeCurrent(handle); if (display_context == null) GLContext.useContext(this); |
|
From: Elias N. <eli...@us...> - 2004-07-24 19:51:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15352/src/java/org/lwjgl/opengl Modified Files: Pbuffer.java Log Message: Added Pbuffer.isUsingDisplayContext() Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Pbuffer.java 24 Jul 2004 19:44:40 -0000 1.22 +++ Pbuffer.java 24 Jul 2004 19:50:50 -0000 1.23 @@ -159,6 +159,15 @@ } /** + * Determine whether the Pbuffer is using the Display context. + * + * @return true of the Pbuffer is using the Display context, false if not. + */ + public boolean isUsingDisplayContext() { + return display_context != null; + } + + /** * Create an instance of a Pbuffer using the Display context. The buffer is double-buffered, like the Display. * <p/> * NOTE: The Pbuffer will use the same context as the Display and requires that the Display has been created. Therefore, |
|
From: Elias N. <eli...@us...> - 2004-07-24 19:44:51
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14409/src/native/linux Modified Files: Window.h org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Display.cpp org_lwjgl_opengl_Pbuffer.cpp Log Message: Implemented new type of Pbuffer that use the Display context, which is faster than a separate context (Linux) Index: org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- org_lwjgl_input_Mouse.cpp 15 Jul 2004 15:53:16 -0000 1.56 +++ org_lwjgl_input_Mouse.cpp 24 Jul 2004 19:44:41 -0000 1.57 @@ -139,7 +139,8 @@ if (result == GrabSuccess) { pointer_grabbed = true; // make sure we have a centered window - XF86VidModeSetViewPort(getDisplay(), getCurrentScreen(), 0, 0); + if (isFullscreen()) + XF86VidModeSetViewPort(getDisplay(), getCurrentScreen(), 0, 0); XFlush(getDisplay()); } } Index: org_lwjgl_opengl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_opengl_Display.cpp 22 Jul 2004 08:52:25 -0000 1.11 +++ org_lwjgl_opengl_Display.cpp 24 Jul 2004 19:44:41 -0000 1.12 @@ -57,9 +57,9 @@ #define ERR_MSG_SIZE 1024 static GLXContext context = NULL; // OpenGL rendering context +static GLXFBConfig *configs = NULL; static GLXWindow glx_window; static XVisualInfo *vis_info = NULL; -static GLXFBConfig *configs = NULL; static Atom delete_atom; static Colormap cmap; @@ -85,6 +85,14 @@ static char error_message[ERR_MSG_SIZE]; static Atom warp_atom; +GLXFBConfig getCurrentGLXFBConfig(void) { + return configs[0]; +} + +GLXContext getCurrentGLXContext(void) { + return context; +} + Atom getWarpAtom(void) { return warp_atom; } @@ -274,6 +282,8 @@ static void destroyWindow(void) { setRepeatMode(AutoRepeatModeDefault); + if (USEGLX13) + glXDestroyWindow(getDisplay(), glx_window); XDestroyWindow(getDisplay(), current_win); XFreeColormap(getDisplay(), cmap); } @@ -371,13 +381,13 @@ throwException(env, "Could not make display context current"); } -static void releaseContext(void) { +/*static void releaseContext(void) { if (USEGLX13) glXMakeContextCurrent(getDisplay(), None, None, NULL); else glXMakeCurrent(getDisplay(), None, NULL); } - +*/ int convertToBPE(int bpp) { int bpe; switch (bpp) { @@ -515,9 +525,8 @@ } static void destroyContext(void) { - releaseContext(); +// releaseContext(); if (USEGLX13) { - glXDestroyWindow(getDisplay(), glx_window); XFree(configs); configs = NULL; } @@ -528,10 +537,13 @@ } static bool initWindowGLX13(JNIEnv *env, jobject pixel_format) { - configs = chooseVisualGLX13(env, pixel_format, true, GLX_WINDOW_BIT, true); + configs = chooseVisualGLX13(env, pixel_format, true, GLX_WINDOW_BIT | GLX_PBUFFER_BIT, true); if (configs == NULL) { - throwException(env, "Could not find a matching pixel format"); - return false; + configs = chooseVisualGLX13(env, pixel_format, true, GLX_WINDOW_BIT, true); + if (configs == NULL) { + throwException(env, "Could not find a matching pixel format"); + return false; + } } context = glXCreateNewContext(getDisplay(), configs[0], GLX_RGBA_TYPE, NULL, True); if (context == NULL) { @@ -556,6 +568,7 @@ if (!checkXError(env)) { glXDestroyContext(getDisplay(), context); XFree(configs); + XFree(vis_info); return false; } return true; @@ -584,6 +597,7 @@ } if (!checkXError(env)) { glXDestroyContext(getDisplay(), context); + XFree(vis_info); return false; } return true; Index: Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Window.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Window.h 22 Jul 2004 07:56:36 -0000 1.16 +++ Window.h 24 Jul 2004 19:44:41 -0000 1.17 @@ -112,6 +112,16 @@ extern Window getCurrentWindow(void); /* + * get the current context + */ + extern GLXContext getCurrentGLXContext(void); + + /* + * get the current GLXFBConfig for the current context + */ + extern GLXFBConfig getCurrentGLXFBConfig(void); + + /* * Return true if we are in fullscreen mode */ extern bool isFullscreen(void); Index: org_lwjgl_opengl_Pbuffer.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- org_lwjgl_opengl_Pbuffer.cpp 6 Jul 2004 08:06:15 -0000 1.20 +++ org_lwjgl_opengl_Pbuffer.cpp 24 Jul 2004 19:44:41 -0000 1.21 @@ -48,6 +48,7 @@ typedef struct _PbufferInfo { GLXPbuffer buffer; GLXContext context; + bool use_display_context; } PbufferInfo; JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Pbuffer_nIsBufferLost @@ -60,7 +61,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps (JNIEnv *env, jclass clazz) { - // Only support thw GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension + // Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension return extgl_Extensions.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0; } @@ -68,13 +69,85 @@ GLXPbuffer buffer = buffer_info->buffer; GLXContext context = buffer_info->context; glXDestroyPbuffer(getDisplay(), buffer); - glXDestroyContext(getDisplay(), context); + if (!buffer_info->use_display_context) + glXDestroyContext(getDisplay(), context); free(buffer_info); decDisplay(); } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jint width, jint height, jobject pixel_format, - jobject pixelFormatCaps, jobject pBufferAttribs) +static bool checkPbufferCaps(JNIEnv *env, GLXFBConfig config, int width, int height) { + int max; + int result = glXGetFBConfigAttrib(getDisplay(), config, GLX_MAX_PBUFFER_WIDTH, &max); + if (result != Success) { + throwException(env, "Could not get GLX_MAX_PBUFFER_WIDTH from configuration"); + return false; + } + if (max < width) { + throwException(env, "Width too large"); + return false; + } + result = glXGetFBConfigAttrib(getDisplay(), config, GLX_MAX_PBUFFER_HEIGHT, &max); + if (result != Success) { + throwException(env, "Could not get GLX_MAX_PBUFFER_WIDTH from configuration"); + return false; + } + if (max < height) { + throwException(env, "Height too large"); + return false; + } + return true; +} + +static bool createPbufferUsingUniqueContext(JNIEnv *env, PbufferInfo *pbuffer_info, jobject pixel_format, int width, int height, const int *buffer_attribs) { + GLXFBConfig *configs = chooseVisualGLX13(env, pixel_format, false, GLX_PBUFFER_BIT, false); + if (configs == NULL) { + throwException(env, "No matching pixel format"); + return false; + } + if (!checkPbufferCaps(env, configs[0], width, height)) { + XFree(configs); + return false; + } + GLXContext context = glXCreateNewContext(getDisplay(), configs[0], GLX_RGBA_TYPE, getCurrentContext(), True); + if (context == NULL) { + XFree(configs); + throwException(env, "Could not create a GLX context"); + return false; + } + jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Window.allowSoftwareOpenGL"); + if (!allow_software_acceleration && glXIsDirect(getDisplay(), context) == False) { + glXDestroyContext(getDisplay(), context); + XFree(configs); + throwException(env, "Could not create a direct GLX context"); + return false; + } + GLXPbuffer buffer = glXCreatePbuffer(getDisplay(), configs[0], buffer_attribs); + XFree(configs); + pbuffer_info->context = context; + pbuffer_info->buffer = buffer; + return true; +} + +static bool createPbufferUsingDisplayContext(JNIEnv *env, PbufferInfo *buffer_info, int width, int height, const int *buffer_attribs) { + if (!checkPbufferCaps(env, getCurrentGLXFBConfig(), width, height)) { + return false; + } + int drawable_type; + if (glXGetFBConfigAttrib(getDisplay(), getCurrentGLXFBConfig(), GLX_DRAWABLE_TYPE, &drawable_type) != Success) { + throwException(env, "Could not get GLX_DRAWABLE_TYPE attribute from Display context"); + return false; + } + if (drawable_type & GLX_PBUFFER_BIT == 0) { + throwException(env, "Display context does not support Pbuffers"); + return false; + } + GLXPbuffer buffer = glXCreatePbuffer(getDisplay(), getCurrentGLXFBConfig(), buffer_attribs); + buffer_info->buffer = buffer; + buffer_info->context = getCurrentGLXContext(); + return true; +} + +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jboolean use_display_context, jint width, jint height, jobject pixel_format, jobject pixelFormatCaps, jobject pBufferAttribs) { Display *disp = incDisplay(env); if (disp == NULL) { @@ -87,48 +160,22 @@ return -1; } - GLXFBConfig *configs = chooseVisualGLX13(env, pixel_format, false, GLX_PBUFFER_BIT, false); - if (configs == 0) { - XFree(configs); - throwException(env, "No matching pixel format"); - return -1; - } - int max; - glXGetFBConfigAttrib(disp, configs[0], GLX_MAX_PBUFFER_WIDTH, &max); - if (max < width) { - XFree(configs); - throwException(env, "Width too large"); - return -1; - } - glXGetFBConfigAttrib(disp, configs[0], GLX_MAX_PBUFFER_HEIGHT, &max); - if (max < height) { - XFree(configs); - throwException(env, "Height too large"); - return -1; - } - GLXContext context = glXCreateNewContext(disp, configs[0], GLX_RGBA_TYPE, getCurrentContext(), True); - if (context == NULL) { - XFree(configs); - throwException(env, "Could not create a GLX context"); - return -1; - } - jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Window.allowSoftwareOpenGL"); - if (!allow_software_acceleration && glXIsDirect(disp, context) == False) { - glXDestroyContext(disp, context); - XFree(configs); - throwException(env, "Could not create a direct GLX context"); - return -1; - } const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height, GLX_PRESERVED_CONTENTS, True, - GLX_LARGEST_PBUFFER, False}; + GLX_LARGEST_PBUFFER, False, + None, None}; - GLXPbuffer buffer = glXCreatePbuffer(disp, configs[0], buffer_attribs); - XFree(configs); PbufferInfo *buffer_info = (PbufferInfo *)malloc(sizeof(PbufferInfo)); - buffer_info->buffer = buffer; - buffer_info->context = context; + buffer_info->use_display_context = use_display_context; + bool result; + if (use_display_context) { + result = createPbufferUsingDisplayContext(env, buffer_info, width, height, buffer_attribs); + } else { + result = createPbufferUsingUniqueContext(env, buffer_info, pixel_format, width, height, buffer_attribs); + } + if (!result) + return -1; if (!checkXError(env)) { destroyPbuffer(buffer_info); return -1; |
|
From: Elias N. <eli...@us...> - 2004-07-24 19:44:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14409/src/native/common Modified Files: org_lwjgl_opengl_Display.h org_lwjgl_opengl_Pbuffer.h Log Message: Implemented new type of Pbuffer that use the Display context, which is faster than a separate context (Linux) Index: org_lwjgl_opengl_Pbuffer.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Pbuffer.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- org_lwjgl_opengl_Pbuffer.h 3 Jul 2004 10:16:27 -0000 1.8 +++ org_lwjgl_opengl_Pbuffer.h 24 Jul 2004 19:44:40 -0000 1.9 @@ -41,7 +41,6 @@ #define org_lwjgl_opengl_Pbuffer_BACK_RIGHT_BUFFER 8326L #undef org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER #define org_lwjgl_opengl_Pbuffer_DEPTH_BUFFER 8359L -/* Inaccessible static: currentBuffer */ /* * Class: org_lwjgl_opengl_Pbuffer * Method: nIsBufferLost @@ -69,10 +68,10 @@ /* * Class: org_lwjgl_opengl_Pbuffer * Method: nCreate - * Signature: (IILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)I + * Signature: (ZIILorg/lwjgl/opengl/PixelFormat;Ljava/nio/IntBuffer;Ljava/nio/IntBuffer;)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *, jclass, jint, jint, jobject, jobject, jobject); + (JNIEnv *, jclass, jboolean, jint, jint, jobject, jobject, jobject); /* * Class: org_lwjgl_opengl_Pbuffer Index: org_lwjgl_opengl_Display.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Display.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- org_lwjgl_opengl_Display.h 3 Jul 2004 10:16:27 -0000 1.2 +++ org_lwjgl_opengl_Display.h 24 Jul 2004 19:44:40 -0000 1.3 @@ -8,15 +8,15 @@ extern "C" { #endif /* Inaccessible static: current_mode */ +/* Inaccessible static: initial_mode */ /* Inaccessible static: timeNow */ /* Inaccessible static: timeThen */ /* Inaccessible static: title */ /* Inaccessible static: fullscreen */ +/* Inaccessible static: vsync */ /* Inaccessible static: vbo_tracker */ /* Inaccessible static: context */ -/* Inaccessible static: createdMouse */ -/* Inaccessible static: createdKeyboard */ -/* Inaccessible static: createdController */ +/* Inaccessible static: timeLate */ /* * Class: org_lwjgl_opengl_Display * Method: nGetAvailableDisplayModes |
|
From: Elias N. <eli...@us...> - 2004-07-24 19:44:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14409/src/java/org/lwjgl/test/opengl Modified Files: PbufferTest.java Log Message: Implemented new type of Pbuffer that use the Display context, which is faster than a separate context (Linux) Index: PbufferTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- PbufferTest.java 6 Jul 2004 16:08:08 -0000 1.37 +++ PbufferTest.java 24 Jul 2004 19:44:40 -0000 1.38 @@ -96,7 +96,7 @@ private void initialize() { try { //find displaymode - pbuffer = new Pbuffer(512, 512, new PixelFormat(), null); + pbuffer = Pbuffer.createPbufferUsingUniqueContext(512, 512, new PixelFormat(), null); mode = findDisplayMode(800, 600, 16); Display.setDisplayMode(mode); // start of in windowed mode @@ -176,7 +176,7 @@ System.out.println("Buffer contents lost - will recreate the buffer"); pbuffer.destroy(); try { - pbuffer = new Pbuffer(512, 512, new PixelFormat(), null); + pbuffer = Pbuffer.createPbufferUsingUniqueContext(512, 512, new PixelFormat(), null); initPbuffer(); } catch (LWJGLException e) { e.printStackTrace(); |
|
From: Elias N. <eli...@us...> - 2004-07-24 19:44:50
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14409/src/java/org/lwjgl/opengl Modified Files: Pbuffer.java Log Message: Implemented new type of Pbuffer that use the Display context, which is faster than a separate context (Linux) Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Pbuffer.java 24 Jul 2004 16:29:15 -0000 1.21 +++ Pbuffer.java 24 Jul 2004 19:44:40 -0000 1.22 @@ -135,11 +135,6 @@ public static final int DEPTH_BUFFER = RenderTexture.WGL_DEPTH_COMPONENT_NV; /** - * Current Pbuffer - */ - private static Pbuffer currentBuffer; - - /** * Handle to the native GL rendering context */ private final int handle; @@ -154,18 +149,43 @@ */ private final int height; + /* + * The Display context that this buffer shares or null + */ + private final Object display_context; + static { Sys.initialize(); } /** - * Construct an instance of a Pbuffer. If this fails then an LWJGLException will be thrown. The buffer is single-buffered. + * Create an instance of a Pbuffer using the Display context. The buffer is double-buffered, like the Display. + * <p/> + * NOTE: The Pbuffer will use the same context as the Display and requires that the Display has been created. Therefore, + * no pixel format or render to texture parameters can be specified. All OpenGL state, + * including display lists, textures etc. is shared between the Pbuffer and the Display. If the Display is destroyed, + * the Pbuffer will not be usable, even if the Display is created again. + * <p/> + * This kind of Pbuffer is the fastest, because the context switch overhead is minimum. + * + * @param width Pbuffer width + * @param height Pbuffer height + */ + public static Pbuffer createPbufferUsingDisplayContext(int width, int height) throws LWJGLException { + if (!Display.isCreated()) + throw new IllegalStateException("The Display must be created before a shared Pbuffer can be created that use the Display context"); + int handle = createPbuffer(true, width, height, null, null); + return new Pbuffer(width, height, Display.getContext(), handle); + } + + /** + * Create an instance of a Pbuffer with a unique OpenGL context. The buffer is single-buffered. * <p/> * NOTE: The Pbuffer will have its own context that shares display lists and textures with the Display context (if it is created), * but it will have its own OpenGL state. Therefore, state changes to a pbuffer will not be seen in the window context and vice versa. * <p/> - * NOTE: Some OpenGL implementations requires the shared contexts to use the same pixel format. So if possible, use the same - * bpp, alpha, depth and stencil values used to create the main window. + * This kind of Pbuffer is primarily intended for non interactive use, since the makeCurrent context switch will be more expensive + * than a Pbuffer using the Display context. * <p/> * The renderTexture parameter defines the necessary state for enabling render-to-texture. When this parameter is null, * render-to-texture is not available. Before using render-to-texture, the Pbuffer capabilities must be queried to ensure that @@ -176,18 +196,27 @@ * @param pixel_format Minimum Pbuffer context properties * @param renderTexture */ - public Pbuffer(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { + public static Pbuffer createPbufferUsingUniqueContext(int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { + int handle = createPbuffer(false, width, height, pixel_format, renderTexture); + return new Pbuffer(width, height, null, handle); + } + + private Pbuffer(int width, int height, Object display_context, int handle) { this.width = width; this.height = height; + this.display_context = display_context; + this.handle = handle; + } + private static int createPbuffer(boolean use_display_context, int width, int height, PixelFormat pixel_format, RenderTexture renderTexture) throws LWJGLException { GLContext.loadOpenGLLibrary(); try { if ( renderTexture == null ) - handle = nCreate(width, height, pixel_format, null, null); + return nCreate(use_display_context, width, height, pixel_format, null, null); else - handle = nCreate(width, height, pixel_format, - renderTexture.pixelFormatCaps, - renderTexture.pBufferAttribs); + return nCreate(use_display_context, width, height, pixel_format, + renderTexture.pixelFormatCaps, + renderTexture.pBufferAttribs); } catch (LWJGLException e) { GLContext.unloadOpenGLLibrary(); throw e; @@ -212,12 +241,14 @@ /** * Method to make the Pbuffer context current. All subsequent OpenGL calls will go to this buffer. - * @throws LWJGLException of the context could not be made current + * @throws LWJGLException if the context could not be made current */ public synchronized void makeCurrent() throws LWJGLException { - currentBuffer = this; + if (display_context != null && display_context != Display.getContext()) + throw new IllegalStateException("Cannot make a Pbuffer invalid after the Display has been destroyed"); nMakeCurrent(handle); - GLContext.useContext(this); + if (display_context == null) + GLContext.useContext(this); } /** @@ -235,7 +266,7 @@ /** * Native method to create a Pbuffer */ - private static native int nCreate(int width, int height, PixelFormat pixel_format, + private static native int nCreate(boolean shared, int width, int height, PixelFormat pixel_format, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs) throws LWJGLException; @@ -321,6 +352,4 @@ public int getWidth() { return width; } - - } |
|
From: Elias N. <eli...@us...> - 2004-07-24 16:34:16
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20656/src/java/org/lwjgl/opengl Modified Files: GLContext.java VBOTracker.java Log Message: Make sure VBOTracker reset the current tracker when GLContext.useContext(null) is called Index: VBOTracker.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/VBOTracker.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- VBOTracker.java 24 Jul 2004 16:29:15 -0000 1.14 +++ VBOTracker.java 24 Jul 2004 16:34:07 -0000 1.15 @@ -71,7 +71,11 @@ * @param context */ static synchronized void setCurrent(Object context) { - current_tracker = (VBOTracker) contextToTracker.get(context); + if (context == null) { + current_tracker = null; + return; + } + current_tracker = (VBOTracker)contextToTracker.get(context); if (current_tracker == null) { current_tracker = new VBOTracker(); contextToTracker.put(context, current_tracker); Index: GLContext.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLContext.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- GLContext.java 24 Jul 2004 16:29:15 -0000 1.24 +++ GLContext.java 24 Jul 2004 16:34:07 -0000 1.25 @@ -234,6 +234,7 @@ if (did_auto_load) unloadOpenGLLibrary(); currentContext = null; + VBOTracker.setCurrent(null); return; } // Is this the same as last time? |
|
From: Elias N. <eli...@us...> - 2004-07-24 16:29:26
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20028/src/java/org/lwjgl/opengl Modified Files: GLContext.java Pbuffer.java VBOTracker.java Log Message: Use WeakHashMap in the static mapping from contexts to vbo trackers in VBOTracker.java. Index: Pbuffer.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- Pbuffer.java 5 Jul 2004 14:56:51 -0000 1.20 +++ Pbuffer.java 24 Jul 2004 16:29:15 -0000 1.21 @@ -244,7 +244,6 @@ * the current rendering context or not. */ public synchronized void destroy() { - VBOTracker.remove(this); try { makeCurrent(); int error = GL11.glGetError(); Index: VBOTracker.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/VBOTracker.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- VBOTracker.java 12 Jun 2004 20:28:24 -0000 1.13 +++ VBOTracker.java 24 Jul 2004 16:29:15 -0000 1.14 @@ -31,7 +31,7 @@ */ package org.lwjgl.opengl; -import java.util.HashMap; +import java.util.WeakHashMap; import java.util.Map; /** @@ -40,7 +40,7 @@ class VBOTracker { private static VBOTracker current_tracker = null; - private static final Map contextToTracker = new HashMap(3, 1.0f); + private static final Map contextToTracker = new WeakHashMap(3, 1.0f); private final StateStack vbo_array_stack; private final StateStack vbo_element_stack; @@ -77,15 +77,4 @@ contextToTracker.put(context, current_tracker); } } - - /** - * Remove a context when it is about to be destroyed. - * @param context - */ - static synchronized void remove(Object context) { - contextToTracker.remove(context); - if (current_tracker == context) { - current_tracker = null; - } - } } Index: GLContext.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLContext.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- GLContext.java 23 Jul 2004 18:10:51 -0000 1.23 +++ GLContext.java 24 Jul 2004 16:29:15 -0000 1.24 @@ -252,7 +252,7 @@ GL11.initNativeStubs(); loadStubs(); currentContext = new WeakReference(context); - VBOTracker.setCurrent(currentContext); + VBOTracker.setCurrent(context); } catch (LWJGLException e) { if (did_auto_load) unloadOpenGLLibrary(); |