diff options
author | Kenneth Russel <[email protected]> | 2004-08-03 17:50:18 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2004-08-03 17:50:18 +0000 |
commit | 05ad8604b58f355890f0e3804906c7e8d598edfa (patch) | |
tree | 946bfc071f06e4b537afa052232d7ea5463ca669 /make/wgl-CustomCCode.c | |
parent | d803c81ff894edcb3569f22c2e2822e1237b7456 (diff) |
Bug fix from user GKW on the JOGL forums for problems reported by
users in JOGL 1.1 betas where the code path for
wglChoosePixelFormatARB (supporting full-scene antialiasing) was
failing on older cards. The old drivers expect an OpenGL context to be
current while the wglChoosePixelFormatARB and associated calls are
being made, even though the documentation explicitly states that this
is not necessary. GKW's fix creates a native window synchronously
(independent of the AWT) and associates an OpenGL context with it
which is used to choose pixel formats for other windows on the same
GraphicsDevice. Upon VM shutdown, a native message pump is started
which causes proper disposal of the native window and its OpenGL
contexts.
There is currently no bug ID associated with this fix, although it may
be a component of completely addressing several open bugs.
Also includes a bug fix from GKW and kbr for:
Issue 98: Just 1st frame rendering on ATI Radeon
This was a race condition between JOGL's automatic discovery that the
ATI_WORKAROUND was needed and the creation of the first GLCanvas and
associated Animator. The need for disabling the setRenderingThread
optimization was computed too late, incorrectly locking out other
threads (in particular, the AWT event queue thread) from performing
rendering of the component.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@144 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'make/wgl-CustomCCode.c')
-rwxr-xr-x | make/wgl-CustomCCode.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/make/wgl-CustomCCode.c b/make/wgl-CustomCCode.c new file mode 100755 index 000000000..be233fd9a --- /dev/null +++ b/make/wgl-CustomCCode.c @@ -0,0 +1,99 @@ +#include <stdio.h> + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +ATOM oglClass = 0; + +HWND CreateDummyWindow( int x, int y, int width, int height ) { + RECT rect; + HINSTANCE hInstance; + DWORD dwExStyle; + DWORD dwStyle; + HWND hWnd; + ZeroMemory( &rect, sizeof( rect ) ); + // I don't know if we need this but it can't hurt + if( width < 0 ) { + rect.left = x + width; + rect.right = x; + } else { + rect.left = x; + rect.right = x + width; + } + if( height < 0 ) { + rect.top = y + height; + rect.bottom = y; + } else { + rect.top = y; + rect.bottom = y + height; + } + hInstance = GetModuleHandle(NULL); + + if( !oglClass ) { + WNDCLASS wc; + ZeroMemory( &wc, sizeof( wc ) ); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC) WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = NULL; + wc.hCursor = NULL; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "OpenGL"; + if( !(oglClass = RegisterClass( &wc )) ) { + printf( "RegisterClass Failed: %d\n", GetLastError() ); + return( 0 ); + } + } + + dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + dwStyle = WS_OVERLAPPEDWINDOW; + if( !(hWnd=CreateWindowEx( dwExStyle, "OpenGL", "OpenGL", + dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, + NULL, NULL, hInstance, NULL ) ) ) { + return( 0 ); + } + return( hWnd ); +} + +void NativeEventLoop() { + MSG msg; + BOOL ret; + // Grab windows system messages from queue + while( ( ret = GetMessage( &msg, NULL, 0, 0 ) ) != 0 ) { + if( ret == -1 ) { + printf( "Error GetMessage: %d", GetLastError() ); + } else { + DispatchMessage( &msg ); + } + } +} + +void DestroyDummyWindow(HWND handle, HDC hdc) { + // Post a close window message from shutdown hook thread to + // window message pump thread + if( !PostMessage( handle, WM_CLOSE, 0, (LPARAM) hdc ) ) { + printf( "PostMessage Failed: %d\n", GetLastError() ); + } +} + +LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + switch( uMsg ) { + case WM_CLOSE: + // Destroy HDC + if( ReleaseDC( hWnd, (HDC) lParam ) != 1 ) { + printf( "Error Releasing DC: %d\n", GetLastError() ); + } + // Destroy HWND + if( DestroyWindow( hWnd ) == 0 ) { + printf( "Error Destroying Window: %d\n", GetLastError() ); + } + break; + case WM_DESTROY: + // Terminate Dummy Window + PostQuitMessage(0); + return(0); + } + return DefWindowProc(hWnd,uMsg,wParam,lParam); +} |