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 | |
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')
-rw-r--r-- | make/build.xml | 4 | ||||
-rw-r--r-- | make/stub_includes/win32/wingdi.h | 40 | ||||
-rwxr-xr-x | make/wgl-CustomCCode.c | 99 | ||||
-rw-r--r-- | make/wingdi-win32.cfg | 2 |
4 files changed, 143 insertions, 2 deletions
diff --git a/make/build.xml b/make/build.xml index 41536e8b4..80adba7f0 100644 --- a/make/build.xml +++ b/make/build.xml @@ -265,7 +265,7 @@ <property name="c.compiler.includes" value="/I"make/stub_includes/opengl" /I"${c.compiler.include.root}/PlatformSDK/Include" /I"${c.compiler.include.root}/include" /I"${java.includes.dir}" /I"${java.includes.dir.platform}" /I"make/stub_includes/cg"" /> <property name="c.linker" value="link.exe" /> <property name="c.linker.flags" value="/DLL /LIBPATH:"${c.linker.lib.root}/PlatformSDK/lib" /LIBPATH:"${c.linker.lib.root}/lib" /LIBPATH:"${java.lib.dir.platform}" /INCREMENTAL:NO /NOLOGO /MACHINE:IX86 /OPT:REF /OPT:ICF /SUBSYSTEM:WINDOWS" /> - <property name="c.linker.jogl.libs" value="opengl32.lib glu32.lib jawt.lib gdi32.lib kernel32.lib" /> + <property name="c.linker.jogl.libs" value="opengl32.lib glu32.lib jawt.lib gdi32.lib user32.lib kernel32.lib" /> <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/jogl.dll" /> <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" /> <property name="c.linker.jogl.flags" value="/OUT:"${c.linker.jogl.dso}"" /> @@ -315,7 +315,7 @@ <property name="c.compiler.includes" value="-I"make/stub_includes/opengl" -I"${java.includes.dir}" -I"${java.includes.dir.platform}" -I"make/stub_includes/cg"" /> <property name="c.linker" value="gcc.exe" /> <property name="c.linker.flags" value="-shared" /> - <property name="c.linker.jogl.libs" value="-Wl,--kill-at -L"${java.lib.dir.platform}" -lopengl32 -lglu32 -ljawt -lgdi32" /> + <property name="c.linker.jogl.libs" value="-Wl,--kill-at -L"${java.lib.dir.platform}" -lopengl32 -lglu32 -ljawt -lgdi32 -luser32" /> <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/jogl.dll" /> <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" /> <property name="c.linker.jogl.flags" value="-o ${c.linker.jogl.dso}" /> diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h index 3cb6f8568..2141135e7 100644 --- a/make/stub_includes/win32/wingdi.h +++ b/make/stub_includes/win32/wingdi.h @@ -83,6 +83,37 @@ typedef struct tagPIXELFORMATDESCRIPTOR #define PFD_MAIN_PLANE 0 #define PFD_OVERLAY_PLANE 1 #define PFD_UNDERLAY_PLANE (-1) +#define WGL_SWAP_MAIN_PLANE 1 +#define WGL_SWAP_OVERLAY1 2 +#define WGL_SWAP_OVERLAY2 4 +#define WGL_SWAP_OVERLAY3 8 +#define WGL_SWAP_OVERLAY4 16 +#define WGL_SWAP_OVERLAY5 32 +#define WGL_SWAP_OVERLAY6 64 +#define WGL_SWAP_OVERLAY7 128 +#define WGL_SWAP_OVERLAY8 256 +#define WGL_SWAP_OVERLAY9 512 +#define WGL_SWAP_OVERLAY10 1024 +#define WGL_SWAP_OVERLAY11 2048 +#define WGL_SWAP_OVERLAY12 4096 +#define WGL_SWAP_OVERLAY13 8192 +#define WGL_SWAP_OVERLAY14 16384 +#define WGL_SWAP_OVERLAY15 32768 +#define WGL_SWAP_UNDERLAY1 65536 +#define WGL_SWAP_UNDERLAY2 0x20000 +#define WGL_SWAP_UNDERLAY3 0x40000 +#define WGL_SWAP_UNDERLAY4 0x80000 +#define WGL_SWAP_UNDERLAY5 0x100000 +#define WGL_SWAP_UNDERLAY6 0x200000 +#define WGL_SWAP_UNDERLAY7 0x400000 +#define WGL_SWAP_UNDERLAY8 0x800000 +#define WGL_SWAP_UNDERLAY9 0x1000000 +#define WGL_SWAP_UNDERLAY10 0x2000000 +#define WGL_SWAP_UNDERLAY11 0x4000000 +#define WGL_SWAP_UNDERLAY12 0x8000000 +#define WGL_SWAP_UNDERLAY13 0x10000000 +#define WGL_SWAP_UNDERLAY14 0x20000000 +#define WGL_SWAP_UNDERLAY15 0x40000000 /* PIXELFORMATDESCRIPTOR flags */ #define PFD_DOUBLEBUFFER 0x00000001 @@ -132,6 +163,7 @@ WINGDIAPI BOOL WINAPI wglMakeCurrent(HDC, HGLRC); WINGDIAPI BOOL WINAPI wglShareLists(HGLRC, HGLRC); WINGDIAPI BOOL WINAPI SwapBuffers(HDC); WINGDIAPI PROC WINAPI wglGetProcAddress(LPCSTR); +WINGDIAPI BOOL WINAPI wglSwapLayerBuffers(HDC,UINT); /* --- FIXME: need to handle these entry points! WINGDIAPI HGLRC WINAPI wglCreateLayerContext(HDC, int); @@ -150,3 +182,11 @@ WINGDIAPI HBITMAP WINAPI CreateDIBSection(HDC, CONST BITMAPINFO *, UINT, VOID ** WINGDIAPI BOOL WINAPI DeleteDC(HDC); WINGDIAPI BOOL WINAPI DeleteObject(HGDIOBJ); WINGDIAPI HGDIOBJ WINAPI SelectObject(HDC, HGDIOBJ); + +// Routines for creation of a dummy device context and OpenGL context +// for the purposes of getting wglChoosePixelFormatARB and associated +// routines +WINGDIAPI HDC WINAPI GetDC(HDC); +WINGDIAPI HDC WINAPI CreateDummyWindow(int,int,int,int); +WINGDIAPI VOID WINAPI DestroyDummyWindow(HWND,HDC); +WINGDIAPI VOID WINAPI NativeEventLoop(); 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); +} diff --git a/make/wingdi-win32.cfg b/make/wingdi-win32.cfg index 622cef25d..a3c5a5ebb 100644 --- a/make/wingdi-win32.cfg +++ b/make/wingdi-win32.cfg @@ -24,3 +24,5 @@ CustomCCode /* This typedef is only needed for VC6 */ CustomCCode #if _MSC_VER <= 1200 CustomCCode typedef int intptr_t; CustomCCode #endif + +IncludeAs CustomCCode wgl-CustomCCode.c |