aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/ogl
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2004-10-15 23:33:45 +0000
committerChien Yang <[email protected]>2004-10-15 23:33:45 +0000
commit14b52db7ab4c4be2bd39ff944cec056c291f999a (patch)
tree3bf6c274a97828b9ca4cd28de6ed602dfeac9af3 /src/native/ogl
parentcdf24368541b18e5ffc56f5c9449310e874f4a2f (diff)
Issue number: 4, 28, 71 and 76
Windows OpenGL only : This fix will use hardware Pbuffer for offScreenBuffer rendering if the graphics hardware support it, else BitMap is use as a fallback. 1) Fixed issue 4 - Speed of OffScreen Canvas3D 2) Fixed issue 28 - Combine Mode & Missing Texture in OffScreen snapshot on Win/XP 3) Fixed issue 71 - OGL: OffScreen canvas ignore GraphicsConfigTemplate under windows. 4) Fixed issue 76 - OffScreen rendering should use Pbuffer on Windows / OpenGL 5) Cleanup native ChoosePixelFormat code. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@56 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/native/ogl')
-rw-r--r--src/native/ogl/Canvas3D.c418
-rw-r--r--src/native/ogl/NativeConfigTemplate3D.c1075
-rw-r--r--src/native/ogl/NativeScreenInfo.c107
-rw-r--r--src/native/ogl/gl_1_2.h78
-rw-r--r--src/native/ogl/gldefs.h67
-rw-r--r--src/native/ogl/wglext.h619
6 files changed, 1692 insertions, 672 deletions
diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c
index ab8f1db..4ce2b9f 100644
--- a/src/native/ogl/Canvas3D.c
+++ b/src/native/ogl/Canvas3D.c
@@ -63,7 +63,10 @@ int getTextureColorTableSize(
#ifdef WIN32
- extern HDC getMonitorDC(int screen);
+extern void printErrorMessage(char *message);
+extern PIXELFORMATDESCRIPTOR getDummyPFD();
+extern HDC getMonitorDC(int screen);
+HWND createDummyWindow(const char* szAppName);
#endif
/*
@@ -422,7 +425,6 @@ BOOL getPropertiesFromCurrentContext(
GraphicsContextPropertiesInfo *ctxInfo,
jlong hdc,
int pixelFormat,
- long display,
int stencilSize)
{
JNIEnv table = *env;
@@ -672,7 +674,7 @@ BOOL getPropertiesFromCurrentContext(
}
#endif
-#ifdef WIN32
+#ifdef WIN32 /* This is fine, but might need cleanup. -- Chien */
wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)
wglGetProcAddress("wglGetPixelFormatAttribivARB");
@@ -1052,7 +1054,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyContext(
#if defined(SOLARIS) || defined(__linux__)
/*
- glXMakeCurrent((Display *)display, (GLXDrawable)window, NULL);
+ glXMakeCurrent((Display *)display, None, NULL);
*/
glXDestroyContext((Display *)display, (GLXContext)context);
#endif /* SOLARIS */
@@ -1178,69 +1180,56 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext(
jboolean rescale = JNI_FALSE;
JNIEnv table = *env;
DWORD err;
- LPTSTR errString;
-
-
- static PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR),
- 1, /* Version number */
- PFD_DRAW_TO_WINDOW |
- PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER,
- PFD_TYPE_RGBA,
- 24, /* 24 bit color depth */
- 0, 0, 0, /* RGB bits and pixel sizes */
- 0, 0, 0, /* Do not care about them */
- 0, 0, /* no alpha buffer info */
- 0, 0, 0, 0, 0, /* no accumulation buffer */
- 32, /* 16 bit depth buffer */
- 0, /* no stencil buffer */
- 0, /* no auxiliary buffers */
- PFD_MAIN_PLANE, /* layer type */
- 0, /* reserved, must be 0 */
- 0, /* no layer mask */
- 0, /* no visible mask */
- 0 /* no damage mask */
- };
-
+ LPTSTR errString;
jboolean result;
+
+ /* Fix for issue 76 */
- /* hWnd = (HWND) window; */
- /* or could use: hDC = GetDC(hWnd); */
+ /*
+ fprintf(stderr, "Canvas3D_createNewContext: \n");
+ fprintf(stderr, "vid %d window 0x%x\n", vid, window);
+ */
if(sharedCtxInfo == 0)
sharedCtx = 0;
else {
sharedCtxStructure = (GraphicsContextPropertiesInfo *)sharedCtxInfo;
sharedCtx = sharedCtxStructure->context;
}
-
hdc = (HDC) window;
-
- if (offScreen) {
- pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL |
- PFD_SUPPORT_GDI;
- vid = -1;
- sharedCtx = 0;
- }
- /* vid of -1 means no vid was specified - do the old way */
- if (vid == -1) {
- /* choose the "pixel format", terminology is equivalent */
- /* to UNIX "visual" */
- PixelFormatID = ChoosePixelFormat(hdc, &pfd);
+ /* Need to handle onScreen and offScreen differently */
+ /* vid is for onScreen and fbConfigListPtr is for offScreen */
+ /*
+ * vid must be a PixelFormat returned
+ * by wglChoosePixelFormat() or wglChoosePixelFormatARB.
+ */
- if(PixelFormatID == 0) {
- fprintf(stderr,"\nERROR: pixel format ID = 0");
+ if(!offScreen) {
+ /* fprintf(stderr, "Canvas3D_createNewContext: onScreen PixelFormat is %d\n", vid); */
+
+ if (vid <= 0) {
+ printErrorMessage("Canvas3D_createNewContext: onScreen PixelFormat is invalid");
return 0;
}
+ else {
+ PixelFormatID = vid;
+ }
}
- else {
- PixelFormatID = vid;
+ else { /* offScreen case */
+ PixelFormatInfo *PixelFormatInfoPtr = (PixelFormatInfo *)fbConfigListPtr;
+
+ if ((PixelFormatInfoPtr == NULL) || (PixelFormatInfoPtr->offScreenPFormat <= 0)) {
+ printErrorMessage("Canvas3D_createNewContext: offScreen PixelFormat is invalid");
+ return 0;
+ }
+ else {
+ PixelFormatID = PixelFormatInfoPtr->offScreenPFormat;
+ }
}
-
- SetPixelFormat(hdc, PixelFormatID, &pfd);
+
+ SetPixelFormat(hdc, PixelFormatID, NULL);
hrc = wglCreateContext( hdc );
@@ -1280,7 +1269,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext(
ctxInfo->context = gctx;
if (!getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID,
- display, stencilSize)) {
+ stencilSize)) {
return 0;
}
@@ -2620,7 +2609,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer(
jobject obj,
jlong ctxInfo,
jlong display,
- jint window,
+ jint vid,
jlong fbConfigListPtr,
jint width,
jint height)
@@ -2656,8 +2645,6 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer(
/* fprintf(stderr, "GLX_DRAWABLE_TYPE returns %d\n", val); */
if ((val & GLX_PBUFFER_BIT) != 0) {
-
-
/* fprintf(stderr, "Using pbuffer %d\n", val); */
/* Initialize the attribute list to be used for choosing FBConfig */
@@ -2737,62 +2724,165 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer(
#endif /* SOLARIS */
-#ifdef WIN32
- int PixelFormatID=0;
- int dpy = (int)display;
- HDC hdc; /* HW Device Context */
- jboolean rescale = JNI_FALSE;
+#ifdef WIN32
+ /* Fix for issue 76 */
+ int dpy = (int)display;
+ static char szAppName[] = "CreateOffScreen";
+ HWND hwnd;
+ HGLRC hrc;
+ HDC hdc;
+ int pixelFormat;
+ PixelFormatInfo *pFormatInfoPtr = (PixelFormatInfo *)fbConfigListPtr;
+ int piAttrs[2];
+
+ HPBUFFERARB hpbuf = NULL; /* Handle to the Pbuffer */
+ HDC hpbufdc = NULL; /* Handle to the Pbuffer's device context */
+
+ HDC bitmapHdc;
+ HBITMAP hbitmap;
+
+ BITMAPINFOHEADER bih;
+ void *ppvBits;
+ int err;
+ LPTSTR errString;
+ OffScreenBufferInfo *offScreenBufferInfo = NULL;
+
+ PIXELFORMATDESCRIPTOR dummy_pfd = getDummyPFD();
+ jclass cv_class;
+ jfieldID offScreenBuffer_field;
JNIEnv table = *env;
+
+ /*
+ fprintf(stderr, "****** CreateOffScreenBuffer ******\n");
+ fprintf(stderr, "display 0x%x, pFormat %d, width %d, height %d\n",
+ (int) display, pFormatInfoPtr->offScreenPFormat, width, height);
+ */
+ cv_class = (jclass) (*(table->GetObjectClass))(env, obj);
+ offScreenBuffer_field =
+ (jfieldID) (*(table->GetFieldID))(env, cv_class, "offScreenBufferInfo", "J");
- HBITMAP hbitmap, oldhbitmap;
-
- BITMAPINFOHEADER bih;
- void *ppvBits;
- int err;
- LPTSTR errString;
- HDC hdcMonitor;
-
- /* create a DIB */
- memset(&bih, 0, sizeof(BITMAPINFOHEADER));
-
- bih.biSize = sizeof(BITMAPINFOHEADER);
- bih.biWidth = width;
- bih.biHeight = height;
- bih.biPlanes = 1;
- bih.biBitCount = 24;
- bih.biCompression = BI_RGB;
-
- /* create a new device context */
-
- if (dpy == 0) {
- hdc = CreateCompatibleDC(0);
- } else {
- /*
- * Should be getMonitorDC(screen)
- * but display and screen are the same under windows
- * They are return from NativeScreenInfo
- */
- hdcMonitor = getMonitorDC((int) display);
- hdc = CreateCompatibleDC(hdcMonitor);
- DeleteDC(hdcMonitor);
-
- }
- hbitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bih,
- DIB_PAL_COLORS, &ppvBits, NULL, 0);
+ /*
+ * Select any pixel format and bound current context to
+ * it so that we can get the wglChoosePixelFormatARB entry point.
+ * Otherwise wglxxx entry point will always return null.
+ * That's why we need to create a dummy window also.
+ */
+ hwnd = createDummyWindow((const char *)szAppName);
+
+ if (!hwnd) {
+ return 0;
+ }
+ hdc = GetDC(hwnd);
+
+ pixelFormat = ChoosePixelFormat(hdc, &dummy_pfd);
+
+ if (pixelFormat<1) {
+ printErrorMessage("In Canvas3D : Failed in ChoosePixelFormat");
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return 0;
+ }
+
+ SetPixelFormat(hdc, pixelFormat, NULL);
+
+ hrc = wglCreateContext(hdc);
+ if (!hrc) {
+ printErrorMessage("In Canvas3D : Failed in wglCreateContext");
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return 0;
+ }
+
+ if (!wglMakeCurrent(hdc, hrc)) {
+ printErrorMessage("In Canvas3D : Failed in wglMakeCurrent");
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return 0;
+ }
+
+ if (pFormatInfoPtr->supportPbuffer) {
+
+ /* fprintf(stderr, "***** Use PBuffer for offscreen ******\n"); */
+
+ piAttrs[0] = 0;
+ piAttrs[1] = 0;
+
+ hpbuf = pFormatInfoPtr->wglCreatePbufferARB( hdc, pFormatInfoPtr->offScreenPFormat,
+ width, height, piAttrs);
+
+ if(hpbuf == NULL) {
+ printErrorMessage("In Canvas3D : wglCreatePbufferARB FAIL.");
+ return 0;
+ }
+
+ hpbufdc = pFormatInfoPtr->wglGetPbufferDCARB(hpbuf);
+
+ if(hpbufdc == NULL) {
+ printErrorMessage("In Canvas3D : Can't get pbuffer's device context.");
+ return 0;
+ }
+
+ /* Destroy all dummy objects */
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+
+ offScreenBufferInfo =
+ (OffScreenBufferInfo *) malloc(sizeof(OffScreenBufferInfo));
+ offScreenBufferInfo->isPbuffer = GL_TRUE;
+ offScreenBufferInfo->hpbuf = hpbuf;
- if (!hbitmap) {
+ (*(table->SetLongField))(env, obj, offScreenBuffer_field, (jlong)offScreenBufferInfo);
+
+ return (jint) hpbufdc;
+ }
+
+ /* create a DIB */
+ memset(&bih, 0, sizeof(BITMAPINFOHEADER));
+
+ bih.biSize = sizeof(BITMAPINFOHEADER);
+ bih.biWidth = width;
+ bih.biHeight = height;
+ bih.biPlanes = 1;
+ bih.biBitCount = 24;
+ bih.biCompression = BI_RGB;
+
+ bitmapHdc = CreateCompatibleDC(hdc);
+
+ hbitmap = CreateDIBSection(bitmapHdc, (BITMAPINFO *)&bih,
+ DIB_PAL_COLORS, &ppvBits, NULL, 0);
+
+
+ if (!hbitmap) {
err = GetLastError();
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, err, 0, (LPTSTR)&errString, 0, NULL);
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, err, 0, (LPTSTR)&errString, 0, NULL);
fprintf(stderr, "CreateDIBSection failed: %s\n", errString);
- }
-
- oldhbitmap = SelectObject(hdc, hbitmap);
+ }
+
+ SelectObject(bitmapHdc, hbitmap);
+
+ /* Choosing and setting of pixel format is done in createContext */
+
+ /* Destroy all dummy objects and fall BitMap */
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
- /* Choosing and setting of pixel format is done in createContext */
+ offScreenBufferInfo =
+ (OffScreenBufferInfo *) malloc(sizeof(OffScreenBufferInfo));
+ offScreenBufferInfo->isPbuffer = GL_FALSE;
+ offScreenBufferInfo->hpbuf = 0;
+
+ (*(table->SetLongField))(env, obj, offScreenBuffer_field, (jlong)offScreenBufferInfo);
- return ((jint)hdc);
+ return ((jint)bitmapHdc);
+
#endif /* WIN32 */
}
@@ -2805,6 +2895,10 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer(
jlong fbConfigListPtr,
jint window)
{
+ jclass cv_class;
+ jfieldID offScreenBuffer_field;
+ JNIEnv table = *env;
+
#if defined(SOLARIS) || defined(__linux__)
/* Fix for Issue 20 */
GLXFBConfig *fbConfigList = (GLXFBConfig *)fbConfigListPtr;
@@ -2824,12 +2918,44 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer(
#endif /* SOLARIS */
#ifdef WIN32
- HBITMAP oldhbitmap;
- HDC hdc = (HDC) window;
+ /* Fix for issue 76 */
+ PixelFormatInfo *pFormatInfoPtr = (PixelFormatInfo *)fbConfigListPtr;
+ OffScreenBufferInfo *offScreenBufferInfo = NULL;
+ HDC hpbufdc = (HDC) window;
+
+ cv_class = (jclass) (*(table->GetObjectClass))(env, obj);
+ offScreenBuffer_field =
+ (jfieldID) (*(table->GetFieldID))(env, cv_class, "offScreenBufferInfo", "J");
+
+ offScreenBufferInfo =
+ (OffScreenBufferInfo *) (*(table->GetLongField))(env, obj, offScreenBuffer_field);
+
+ /* fprintf(stderr,"Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0x%x\n",
+ offScreenBufferInfo);
+ */
+ if(offScreenBufferInfo == NULL) {
+ return;
+ }
+
+ if(offScreenBufferInfo->isPbuffer) {
+ /* fprintf(stderr,"Canvas3D_destroyOffScreenBuffer : Pbuffer\n"); */
+
+ pFormatInfoPtr->wglReleasePbufferDCARB(offScreenBufferInfo->hpbuf, hpbufdc);
+ pFormatInfoPtr->wglDestroyPbufferARB(offScreenBufferInfo->hpbuf);
+ }
+ else {
+ HBITMAP oldhbitmap;
+ HDC hdc = (HDC) window;
+
+ /* fprintf(stderr,"Canvas3D_destroyOffScreenBuffer : BitMap\n"); */
+ oldhbitmap = SelectObject(hdc, NULL);
+ DeleteObject(oldhbitmap);
+ DeleteDC(hdc);
+ }
+
+ free(offScreenBufferInfo);
+ (*(table->SetLongField))(env, obj, offScreenBuffer_field, (jlong)0);
- oldhbitmap = SelectObject(hdc, NULL);
- DeleteObject(oldhbitmap);
- DeleteDC(hdc);
#endif /* WIN32 */
}
@@ -3130,7 +3256,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext(
}
- /* create window if window == 0 and offscreen == true */
+ /* onscreen rendering and window is 0 now */
if(window == 0 && !offScreen) {
vinfo = glXGetVisualFromFBConfig((Display*)display, fbConfigList[0]);
@@ -3186,74 +3312,48 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext(
HWND hWnd;
static char szAppName[] = "OpenGL";
jlong vinfo = 0;
-
- static PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR),
- 1, /* Version number */
- PFD_DRAW_TO_WINDOW |
- PFD_SUPPORT_OPENGL|
- PFD_DOUBLEBUFFER,
- PFD_TYPE_RGBA,
- 24, /* 24 bit color depth */
- 0, 0, 0, /* RGB bits and pixel sizes */
- 0, 0, 0, /* Donnot care about them */
- 0, 0, /* no alpha buffer info */
- 0, 0, 0, 0, 0, /* no accumulation buffer */
- 32, /* 16 bit depth buffer */
- 0, /* no stencil buffer */
- 0, /* no auxiliary buffers */
- PFD_MAIN_PLANE, /* layer type */
- 0, /* reserved, must be 0 */
- 0, /* no layer mask */
- 0, /* no visible mask */
- 0 /* no damage mask */
- };
-
jboolean result;
+ /* Fix for issue 76 */
+
+ /*
+ fprintf(stderr, "Canvas3D_createQueryContext:\n");
+ fprintf(stderr, "window is 0x%x, offScreen %d\n", window, offScreen);
+ */
+
/* onscreen rendering and window is 0 now */
if(window == 0 && !offScreen){
+ /* fprintf(stderr, "CreateQueryContext : window == 0 && !offScreen\n"); */
hWnd = createDummyWindow((const char *)szAppName);
if (!hWnd)
return;
hdc = GetDC(hWnd);
}
else if(window == 0 && offScreen){
+ /* fprintf(stderr, "CreateQueryContext : window == 0 && offScreen\n"); */
hdc = (HDC)Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( env, obj, 0, display,
- window, vid, width, height);
- pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL |
- PFD_SUPPORT_GDI;
- vid = -1;
- }
- else if(window != 0 && offScreen){
- pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL |
- PFD_SUPPORT_GDI;
- vid = -1;
- hdc = (HDC) window;
+ vid, fbConfigListPtr,
+ width, height);
}
- else if(window !=0 && !offScreen){
+ else if(window != 0){
+ /* fprintf(stderr, "CreateQueryContext : window != 0 0x%x\n", window); */
hdc = (HDC) window;
}
newWin = (int)hdc;
- /* vid of -1 means no vid was specified - do the old way */
- if (vid == -1) {
- /*
- * choose the "pixel format", terminology is equivalent
- * to UNIX "visual"
- */
- PixelFormatID = ChoosePixelFormat(hdc, &pfd);
-
- if(PixelFormatID == 0) {
- fprintf(stderr,"\nERROR: pixel format ID = 0");
- return;
- }
+ /*
+ * vid must be a PixelFormat returned
+ * by wglChoosePixelFormat() or wglChoosePixelFormatARB.
+ */
+ if (vid <= 0) {
+ printErrorMessage("Canvas3D_createQueryContext: PixelFormat is invalid");
+ return;
}
- else
+ else {
PixelFormatID = vid;
-
- SetPixelFormat(hdc, PixelFormatID, &pfd);
+ }
+ SetPixelFormat(hdc, PixelFormatID, NULL);
hrc = wglCreateContext( hdc );
@@ -3285,7 +3385,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext(
ctxInfo->context = gctx;
/* get current context properties */
- if (getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID, display,
+ if (getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID,
stencilSize)) {
/* put the properties to the Java side */
setupCanvasProperties(env, obj, ctxInfo);
diff --git a/src/native/ogl/NativeConfigTemplate3D.c b/src/native/ogl/NativeConfigTemplate3D.c
index 4dbbfaa..11c3b6e 100644
--- a/src/native/ogl/NativeConfigTemplate3D.c
+++ b/src/native/ogl/NativeConfigTemplate3D.c
@@ -132,7 +132,7 @@ GLXFBConfig *find_AA_S_FBConfigs(jlong display,
glxAttrs[index++] = GLX_SAMPLE_BUFFERS_ARB;
glxAttrs[index++] = 1;
glxAttrs[index++] = GLX_SAMPLES_ARB;
- glxAttrs[index++] = 1;
+ glxAttrs[index++] = 2;
glxAttrs[index] = None;
fbConfigList = find_S_FBConfigs(display, screen,
@@ -272,7 +272,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual(
Display *dpy = (Display *) display;
fbConfigListPtr = (*env)->GetLongArrayElements(env, fbConfigArray, NULL);
- mx_ptr = (jint *)(*env)->GetPrimitiveArrayCritical(env, attrList, NULL);
+ mx_ptr = (*env)->GetIntArrayElements(env, attrList, NULL);
/*
* convert Java 3D values to GLX
@@ -307,8 +307,7 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_chooseOglVisual(
sVal = mx_ptr[STEREO];
antialiasVal = mx_ptr[ANTIALIASING];
-
- (*env)->ReleasePrimitiveArrayCritical(env, attrList, mx_ptr, 0);
+ (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT);
fbConfigList = find_DB_AA_S_FBConfigs(display, screen, glxAttrs, sVal,
dbVal, antialiasVal, index);
@@ -522,6 +521,34 @@ jboolean JNICALL Java_javax_media_j3d_J3dGraphicsConfig_isValidVisualID(
extern HWND createDummyWindow(const char* szAppName);
+
+PIXELFORMATDESCRIPTOR getDummyPFD() {
+
+ /* Dummy pixel format. -- Chien */
+ static PIXELFORMATDESCRIPTOR dummy_pfd = {
+ sizeof(PIXELFORMATDESCRIPTOR),
+ 1, /* Version number */
+ PFD_DRAW_TO_WINDOW |
+ PFD_SUPPORT_OPENGL,
+ PFD_TYPE_RGBA,
+ 16, /* 16 bit color depth */
+ 0, 0, 0, /* RGB bits and pixel sizes */
+ 0, 0, 0, /* Do not care about them */
+ 0, 0, /* no alpha buffer info */
+ 0, 0, 0, 0, 0, /* no accumulation buffer */
+ 8, /* 8 bit depth buffer */
+ 0, /* no stencil buffer */
+ 0, /* no auxiliary buffers */
+ PFD_MAIN_PLANE, /* layer type */
+ 0, /* reserved, must be 0 */
+ 0, /* no layer mask */
+ 0, /* no visible mask */
+ 0 /* no damage mask */
+ };
+
+ return dummy_pfd;
+}
+
/*
void printPixelDescriptor(PIXELFORMATDESCRIPTOR *pfd)
{
@@ -570,10 +597,9 @@ void printPixelDescriptor(PIXELFORMATDESCRIPTOR *pfd)
printf("\n");
}
-
*/
-BOOL isSupportedWGL(const char * extensions, const char *extension_string) {
+BOOL isSupportedWGL(const char *extensions, const char *extension_string) {
/* get the list of supported extensions */
const char *p = extensions;
@@ -597,33 +623,39 @@ HDC getMonitorDC(int screen)
return CreateDC("DISPLAY", NULL, NULL, NULL);
}
-int findPixelFormatSwitchDoubleBufferAndStereo (PIXELFORMATDESCRIPTOR* pfd, HDC hdc, int *mx_ptr)
+int find_DB_S_STDPixelFormat(PIXELFORMATDESCRIPTOR* pfd, HDC hdc,
+ int *mx_ptr, GLboolean offScreen)
{
int pf;
+ PIXELFORMATDESCRIPTOR newpfd;
pf = ChoosePixelFormat(hdc, pfd);
-
- /* Check if pixel format support min. requirement */
- DescribePixelFormat(hdc, pf, sizeof(*pfd), pfd);
-
- if ((pfd->cRedBits < (unsigned char) mx_ptr[RED_SIZE]) ||
- (pfd->cGreenBits < (unsigned char) mx_ptr[GREEN_SIZE]) ||
- (pfd->cBlueBits < (unsigned char) mx_ptr[BLUE_SIZE]) ||
- (pfd->cDepthBits < (unsigned char) mx_ptr[DEPTH_SIZE]) ||
- ((mx_ptr[DOUBLEBUFFER] == REQUIRED) && ((pfd->dwFlags & PFD_DOUBLEBUFFER) == 0)) ||
- ((mx_ptr[STEREO] == REQUIRED) && ((pfd->dwFlags & PFD_STEREO) == 0)))
- {
- return -1;
- }
- if ((mx_ptr[ANTIALIASING] == REQUIRED) &&
- ((pfd->cAccumRedBits <= 0) ||
- (pfd->cAccumGreenBits <= 0) ||
- (pfd->cAccumBlueBits <= 0)))
- {
- return -1;
- }
+ if(!offScreen) {
+ /* onScreen : Check if pixel format support min. requirement */
+ DescribePixelFormat(hdc, pf, sizeof(newpfd), &newpfd);
+
+ if ((newpfd.cRedBits < (unsigned char) mx_ptr[RED_SIZE]) ||
+ (newpfd.cGreenBits < (unsigned char) mx_ptr[GREEN_SIZE]) ||
+ (newpfd.cBlueBits < (unsigned char) mx_ptr[BLUE_SIZE]) ||
+ (newpfd.cDepthBits < (unsigned char) mx_ptr[DEPTH_SIZE]) ||
+ ((mx_ptr[DOUBLEBUFFER] == REQUIRED) &&
+ ((newpfd.dwFlags & PFD_DOUBLEBUFFER) == 0)) ||
+ ((mx_ptr[STEREO] == REQUIRED) && ((newpfd.dwFlags & PFD_STEREO) == 0)))
+ {
+ return -1;
+ }
+
+ if ((mx_ptr[ANTIALIASING] == REQUIRED) &&
+ ((newpfd.cAccumRedBits <= 0) ||
+ (newpfd.cAccumGreenBits <= 0) ||
+ (newpfd.cAccumBlueBits <= 0)))
+ {
+ return -1;
+ }
+ }
+
return pf;
}
@@ -637,393 +669,480 @@ void printErrorMessage(char *message)
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPTSTR)&errString, 0, NULL);
- fprintf(stderr, "%s - %s\n", message, errString);
+ fprintf(stderr, "Java 3D ERROR : %s - %s\n", message, errString);
LocalFree(errString);
}
-/* Prefer multiSample in following order
- 4, 5, 6, 3, 7, 8, 2, 9, 10, 11, ...
-*/
-int getMultiSampleScore(int s)
-{
- static int multiSampleScore[9] = {9999, 9999, 6, 3, 0, 1, 2, 4, 5};
-
- if (s < 9) {
- return multiSampleScore[s];
- }
- return s-2;
-}
-
-
-/* Max no of format wglChoosePixelFormatEXT can return */
-#define NFORMAT 100
+/* Fix for issue 76 */
+#define MAX_WGL_ATTRS_LENGTH 30
-int getExtPixelFormat(int *nativeConfigAttrs)
-{
- static const BOOL debug = FALSE;
- static char szAppName[] = "Choose Pixel Format";
-
- static PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR),
- 1, /* Version number */
- PFD_DRAW_TO_WINDOW |
- PFD_SUPPORT_OPENGL,
- PFD_TYPE_RGBA,
- 16, /* 16 bit color depth */
- 0, 0, 0, /* RGB bits and pixel sizes */
- 0, 0, 0, /* Do not care about them */
- 0, 0, /* no alpha buffer info */
- 0, 0, 0, 0, 0, /* no accumulation buffer */
- 8, /* 8 bit depth buffer */
- 0, /* no stencil buffer */
- 0, /* no auxiliary buffers */
- PFD_MAIN_PLANE, /* layer type */
- 0, /* reserved, must be 0 */
- 0, /* no layer mask */
- 0, /* no visible mask */
- 0 /* no damage mask */
- };
- HWND hwnd;
- HGLRC hrc;
- HDC hdc;
- int attr[22];
- int piValues[12];
- int i, idx;
- int pNumFormats[NFORMAT], nAvailableFormat;
- const char* supportedExtensions;
- int score;
- int highestScore, highestScorePF;
- int highestScoreAlpha, lowestScoreMultiSample;
-
- /* declare function pointers for WGL functions */
- PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = NULL;
- PFNWGLCHOOSEPIXELFORMATEXTPROC wglChoosePixelFormatEXT = NULL;
- PFNWGLGETPIXELFORMATATTRIBIVEXTPROC wglGetPixelFormatAttribivEXT = NULL;
+int find_Stencil_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo,
+ int* wglAttrs, int sIndex) {
+
+ int pFormat, availableFormats, index;
+
+ J3D_ASSERT((sIndex+4) < MAX_WGL_ATTRS_LENGTH);
+
+ index = sIndex;
+ wglAttrs[index++] = WGL_STENCIL_BITS_ARB;
+ wglAttrs[index++] = 1;
/*
- * Select any pixel format and bound current context to
- * it so that we can get the wglChoosePixelFormatARB entry point.
- * Otherwise wglxxx entry point will always return null.
- * That's why we need to create a dummy window also.
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
*/
- hwnd = createDummyWindow((const char *)szAppName);
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
- if (!hwnd) {
- return -1;
+ pFormat = -1;
+
+ if ((pFormatInfo->wglChoosePixelFormatARB(hdc, wglAttrs, NULL, 1,
+ &pFormat, &availableFormats)) && (availableFormats > 0)) {
+
+ /* fprintf(stderr, "wglChoosePixelFormatARB : pFormat %d availableFormats %d\n",
+ pFormat, availableFormats); */
+ return pFormat;
}
- hdc = GetDC(hwnd);
+
+ /* fprintf(stderr, "wglChoosePixelFormatARB (TRY 1): FAIL\n"); */
+
+ index = sIndex;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = -1;
- pNumFormats[0] = ChoosePixelFormat(hdc, &pfd);
- if (!pNumFormats[0]) {
- printErrorMessage("Failed in ChoosePixelFormat");
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
+ if ((pFormatInfo->wglChoosePixelFormatARB(hdc, wglAttrs, NULL, 1,
+ &pFormat, &availableFormats)) && (availableFormats > 0)) {
+
+ /* fprintf(stderr, "wglChoosePixelFormatARB : pFormat %d availableFormats %d\n",
+ pFormat, availableFormats); */
+
+ return pFormat;
}
+
+ /* fprintf(stderr, "wglChoosePixelFormatARB (TRY 2): FAIL\n"); */
+ return -1;
+}
- SetPixelFormat(hdc, pNumFormats[0], &pfd);
+int find_S_PixelFormat(HDC hdc, PixelFormatInfo * pFormatInfo,
+ int* wglAttrs, int sVal, int sIndex) {
- hrc = wglCreateContext(hdc);
- if (!hrc) {
- printErrorMessage("Failed in wglCreateContext");
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
+ int pFormat, index;
+
+ J3D_ASSERT((sIndex+4) < MAX_WGL_ATTRS_LENGTH);
+
+ if (sVal == REQUIRED || sVal== PREFERRED) {
+
+ index = sIndex;
+ wglAttrs[index++] = WGL_STEREO_ARB;
+ wglAttrs[index++] = TRUE;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_Stencil_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, index);
+ /* fprintf(stderr,"STEREO REQUIRED or PREFERRED ***pFormat %d\n", pFormat); */
+
+ if(pFormat >= 0) {
+ return pFormat;
+ }
}
- if (!wglMakeCurrent(hdc, hrc)) {
- printErrorMessage("Failed in wglMakeCurrent");
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
+ if (sVal == UNNECESSARY || sVal== PREFERRED) {
+
+ index = sIndex;
+ wglAttrs[index++] = WGL_STEREO_ARB;
+ wglAttrs[index++] = FALSE;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_Stencil_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, index);
+
+ /* fprintf(stderr,"STEREO UNNECC. or PREFERRED ***pFormat %d\n", pFormat); */
+
+ if(pFormat >= 0) {
+ return pFormat;
+ }
}
- wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
- wglGetProcAddress("wglGetExtensionsStringARB");
+ if (sVal == UNNECESSARY) {
+ index = sIndex;
+ wglAttrs[index++] = WGL_STEREO_ARB;
+ wglAttrs[index++] = TRUE;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_Stencil_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, index);
- if (wglGetExtensionsStringEXT == NULL) {
- wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
- wglGetProcAddress("wglGetExtensionsStringEXT");
- if (wglGetExtensionsStringEXT == NULL) {
- if (debug) {
- printf("wglGetExtensionsStringEXT/ARB not support !\n");
- }
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
- }
- if (debug) {
- printf("Support wglGetExtensionsStringEXT\n");
- }
- } else {
- if (debug) {
- printf("Support wglGetExtensionsStringARB\n");
+ /* fprintf(stderr,"STEREO UNNECC. ***pFormat %d\n", pFormat); */
+
+ if(pFormat >= 0) {
+ return pFormat;
}
}
- /* get the list of supported extensions */
- supportedExtensions = (const char *)wglGetExtensionsStringEXT(hdc);
+ return -1;
+}
- if (debug) {
- fprintf(stderr, "WGL Supported extensions: %s.\n", supportedExtensions);
- }
+
+int find_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo,
+ int* wglAttrs, int sVal,
+ int antialiasVal, int antialiasIndex) {
+
+ int index;
+ int pFormat;
+ GLboolean supportMS = GL_FALSE;
- if (!isSupportedWGL(supportedExtensions, "WGL_ARB_multisample") &&
- !isSupportedWGL(supportedExtensions, "WGL_EXT_multisample") &&
- !isSupportedWGL(supportedExtensions, "WGL_SGIS_multisample")) {
+ J3D_ASSERT((antialiasIndex+8) < MAX_WGL_ATTRS_LENGTH);
- /* Under Wildcat III it doesn't use wglGetExtensionString */
- supportedExtensions = (char *) glGetString(GL_EXTENSIONS);
+ if(antialiasVal == REQUIRED || antialiasVal== PREFERRED) {
- if (debug) {
- fprintf(stderr, "GL Supported extensions: %s.\n", supportedExtensions);
+ if(isSupportedWGL(pFormatInfo->supportedExtensions, "WGL_ARB_multisample")) {
+ supportMS = GL_TRUE;
}
-
- if (!isSupportedWGL(supportedExtensions, "GL_ARB_multisample") &&
- !isSupportedWGL(supportedExtensions, "GL_EXT_multisample") &&
- !isSupportedWGL(supportedExtensions, "GL_SGIS_multisample")) {
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
+ else {
+ /* Under Wildcat III it doesn't use wglGetExtensionString */
+ char *supportedExtensions = (char *) glGetString(GL_EXTENSIONS);
+
+ /* fprintf(stderr, "GL Supported extensions: %s.\n", supportedExtensions); */
+
+ if (isSupportedWGL(supportedExtensions, "GL_ARB_multisample")) {
+ supportMS = GL_TRUE;
+ }
}
- }
-
- wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)
- wglGetProcAddress("wglChoosePixelFormatARB");
-
- if (wglChoosePixelFormatEXT == NULL) {
- wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)
- wglGetProcAddress("wglChoosePixelFormatEXT");
- if (wglChoosePixelFormatEXT == NULL) {
- if (debug) {
- printf("wglChoosePixelFormatARB/EXT not support !\n");
+
+ if(supportMS) {
+
+ index = antialiasIndex;
+ wglAttrs[index++] = WGL_SAMPLE_BUFFERS_ARB;
+ wglAttrs[index++] = 1;
+ wglAttrs[index++] = WGL_SAMPLES_ARB;
+ wglAttrs[index++] = 2;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_S_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, sVal, index);
+
+ if(pFormat >= 0) {
+ return pFormat;
}
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
- }
- if (debug) {
- printf("Support wglChoosePixelFormatEXT\n");
}
- } else {
- if (debug) {
- printf("Support wglChoosePixelFormatARB\n");
- }
}
- idx = 0;
- attr[idx++] = WGL_SUPPORT_OPENGL_EXT;
- attr[idx++] = TRUE;
- attr[idx++] = WGL_DRAW_TO_WINDOW_EXT;
- attr[idx++] = TRUE;
- attr[idx++] = WGL_RED_BITS_EXT;
- attr[idx++] = nativeConfigAttrs[RED_SIZE];
- attr[idx++] = WGL_GREEN_BITS_EXT;
- attr[idx++] = nativeConfigAttrs[GREEN_SIZE];
- attr[idx++] = WGL_BLUE_BITS_EXT;
- attr[idx++] = nativeConfigAttrs[BLUE_SIZE];
- attr[idx++] = WGL_DEPTH_BITS_EXT;
- attr[idx++] = nativeConfigAttrs[DEPTH_SIZE];
-
- if (nativeConfigAttrs[DOUBLEBUFFER] == REQUIRED) {
- attr[idx++] = WGL_DOUBLE_BUFFER_EXT;
- attr[idx++] = TRUE;
- }
- if (nativeConfigAttrs[STEREO] == REQUIRED) {
- attr[idx++] = WGL_STEREO_EXT;
- attr[idx++] = TRUE;
- }
+ if ( antialiasVal == REQUIRED ) {
- if (nativeConfigAttrs[ANTIALIASING] == REQUIRED) {
- attr[idx++] = WGL_SAMPLE_BUFFERS_ARB;
- attr[idx++] = TRUE;
- attr[idx++] = WGL_SAMPLES_ARB;
- attr[idx++] = 2;
+ index = antialiasIndex;
+ wglAttrs[index++] = WGL_ACCUM_RED_BITS_ARB;
+ wglAttrs[index++] = 8;
+ wglAttrs[index++] = WGL_ACCUM_GREEN_BITS_ARB;
+ wglAttrs[index++] = 8;
+ wglAttrs[index++] = WGL_ACCUM_BLUE_BITS_ARB;
+ wglAttrs[index++] = 8;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_S_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, sVal, index);
+
+ if(pFormat >= 0) {
+ return pFormat;
+ }
}
-
+
/*
* Terminate by 2 zeros to avoid driver bugs
* that assume attributes always come in pairs.
*/
- attr[idx++] = 0;
- attr[idx++] = 0;
+ index = antialiasIndex;
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ if (antialiasVal == UNNECESSARY || antialiasVal == PREFERRED) {
+
+ pFormat = find_S_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, sVal, index);
+
+ if(pFormat >= 0) {
+ return pFormat;
+ }
- if (!wglChoosePixelFormatEXT(hdc, (const int *)attr, NULL, NFORMAT,
- pNumFormats, &nAvailableFormat)) {
- printErrorMessage("Failed in wglChoosePixelFormatEXT");
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
- }
-
- if (debug) {
- printf("No. of available pixel format is: %d\n", nAvailableFormat);
}
- if (nAvailableFormat <= 0) {
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
- }
+ return -1;
- wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)
- wglGetProcAddress("wglGetPixelFormatAttribivARB");
+}
- if (wglGetPixelFormatAttribivEXT == NULL) {
- wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)
- wglGetProcAddress("wglGetPixelFormatAttribivEXT");
- if (wglGetPixelFormatAttribivEXT == NULL) {
- if (debug) {
- printf("wglGetPixelFormatAttribivEXT/ARB not support !\n");
- }
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
- }
- if (debug) {
- printf("Support wglGetPixelFormatAttribivEXT\n");
+int find_DB_AA_S_PixelFormat( HDC hdc, PixelFormatInfo * pFormatInfo,
+ int* wglAttrs, int sVal, int dbVal,
+ int antialiasVal, int dbIndex) {
+
+ int index = dbIndex;
+ int pFormat;
+
+ J3D_ASSERT((dbIndex+4) < MAX_WGL_ATTRS_LENGTH);
+
+ if (dbVal == REQUIRED || dbVal== PREFERRED) {
+
+ index = dbIndex;
+ wglAttrs[index++] = WGL_DOUBLE_BUFFER_ARB;
+ wglAttrs[index++] = TRUE;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_AA_S_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, sVal,
+ antialiasVal, index);
+
+ if(pFormat >= 0) {
+ return pFormat;
+ }
+ }
+
+ if (dbVal == UNNECESSARY || dbVal== PREFERRED) {
+ index = dbIndex;
+ wglAttrs[index++] = WGL_DOUBLE_BUFFER_ARB;
+ wglAttrs[index++] = TRUE;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_AA_S_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, sVal,
+ antialiasVal, index);
+
+ if(pFormat >= 0) {
+ return pFormat;
}
- } else {
- if (debug) {
- printf("Support wglGetPixelFormatAttribivARB\n");
- }
}
- idx = 0;
- attr[idx++] = WGL_ACCELERATION_EXT;
- attr[idx++] = WGL_RED_BITS_EXT;
- attr[idx++] = WGL_GREEN_BITS_EXT;
- attr[idx++] = WGL_BLUE_BITS_EXT;
- attr[idx++] = WGL_ALPHA_BITS_EXT;
- attr[idx++] = WGL_DEPTH_BITS_EXT;
- attr[idx++] = WGL_STENCIL_BITS_EXT;
- attr[idx++] = WGL_SAMPLE_BUFFERS_ARB;
- attr[idx++] = WGL_SAMPLES_ARB;
- attr[idx++] = WGL_DOUBLE_BUFFER_EXT;
- attr[idx++] = WGL_STEREO_EXT;
- attr[idx] = 0;
-
- /* Select the best pixel format based on score */
- highestScore = 0;
- highestScorePF = -1;
- highestScoreAlpha = 0;
- lowestScoreMultiSample = 9999;
-
- for (i=0; i < nAvailableFormat; i++) {
- if (!wglGetPixelFormatAttribivEXT(hdc, pNumFormats[i], 0, idx, attr, piValues)) {
- printErrorMessage("Failed in wglGetPixelFormatAttribivEXT");
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return -1;
+ if (dbVal == UNNECESSARY) {
+ index = dbIndex;
+ wglAttrs[index++] = WGL_DOUBLE_BUFFER_ARB;
+ wglAttrs[index++] = TRUE;
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormat = find_AA_S_PixelFormat(hdc, pFormatInfo,
+ wglAttrs, sVal,
+ antialiasVal, index);
+
+ if(pFormat >= 0) {
+ return pFormat;
}
- if (debug) {
- printf("Format %d\n", pNumFormats[i]);
-
- if (piValues[0] == WGL_FULL_ACCELERATION_EXT) {
- printf("WGL_FULL_ACCELERATION_EXT");
- } else if (piValues[0] == WGL_GENERIC_ACCELERATION_EXT) {
- printf("WGL_GENERIC_ACCELERATION_EXT");
- } else {
- printf("WGL_NO_ACCELERATION_EXT");
- }
+ }
- printf(" R %d, G %d, B %d, A %d, Depth %d, Stencil %d",
- piValues[1], piValues[2], piValues[3], piValues[4],
- piValues[5], piValues[6]);
+ return -1;
+}
- if (piValues[7] == TRUE) {
- printf(" MultiSample %d", piValues[8]);
- }
+int chooseSTDPixelFormat(
+ JNIEnv *env,
+ jint screen,
+ jintArray attrList,
+ HDC hdc,
+ GLboolean offScreen)
+{
+ int *mx_ptr;
+ int dbVal; /* value for double buffering */
+ int sVal; /* value for stereo */
+ int pFormat = -1; /* PixelFormat */
+ PIXELFORMATDESCRIPTOR pfd;
- if (piValues[9] == TRUE) {
- printf(" DoubleBuffer");
- }
-
- if (piValues[10] == TRUE) {
- printf(" Stereo");
- }
- printf("\n");
- }
+ /* fprintf(stderr, "chooseSTDPixelFormat : screen 0x%x, offScreen %d hdc 0x%x\n",
+ screen, offScreen, hdc); */
+
+ ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
+ pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
+ pfd.nVersion = 1; /*TODO: when would this change? */
+ pfd.iPixelType = PFD_TYPE_RGBA;
- /* Red, Green, Blue are fixed under windows so they are not checked */
- score = 0;
+ /*
+ * Convert Java 3D values to PixelFormat
+ */
+ mx_ptr = (*env)->GetIntArrayElements(env, attrList, NULL);
- if (piValues[0] == WGL_FULL_ACCELERATION_EXT) {
- score += 20000;
- } else if (piValues[0] == WGL_GENERIC_ACCELERATION_EXT) {
- score += 10000;
- }
- if ((nativeConfigAttrs[DOUBLEBUFFER] == PREFERRED) &&
- (piValues[9] == TRUE)) {
- score += 5000;
- }
- if (piValues[4] > 0) { /* Alpha */
- score += 2500;
- }
- if ((nativeConfigAttrs[STEREO] == PREFERRED) &&
- (piValues[10] == TRUE)) {
- score += 1250;
- }
- if ((nativeConfigAttrs[ANTIALIASING] == PREFERRED) &&
- (piValues[7] == TRUE)) {
- score += 624;
+ if(!offScreen) {
+
+ pfd.cRedBits = (unsigned char) mx_ptr[RED_SIZE];
+ pfd.cGreenBits = (unsigned char) mx_ptr[GREEN_SIZE];
+ pfd.cBlueBits = (unsigned char) mx_ptr[BLUE_SIZE];
+ pfd.cDepthBits = (unsigned char) mx_ptr[DEPTH_SIZE];
+
+ if (mx_ptr[DOUBLEBUFFER] == REQUIRED || mx_ptr[DOUBLEBUFFER] == PREFERRED)
+ dbVal = PFD_DOUBLEBUFFER;
+ else
+ dbVal = PFD_DOUBLEBUFFER_DONTCARE;
+
+ sVal = 0;
+ if (mx_ptr[STEREO] == REQUIRED || mx_ptr[STEREO] == PREFERRED) {
+ sVal = PFD_STEREO;
+ } else {
+ sVal = PFD_STEREO_DONTCARE;
}
+
+ pfd.dwFlags = dbVal | sVal | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
+
+ pfd.cStencilBits = 1;
- /* Stencil bit * 10 + Depth bit */
- score += piValues[6]*10 + piValues[5];
-
- if (score > highestScore) {
- highestScore = score;
- highestScorePF = i;
- highestScoreAlpha = piValues[4];
- lowestScoreMultiSample = getMultiSampleScore(piValues[8]);
- } else if (score == highestScore) {
- if (piValues[4] > highestScoreAlpha) {
- highestScore = score;
- highestScorePF = i;
- highestScoreAlpha = piValues[4];
- lowestScoreMultiSample = getMultiSampleScore(piValues[8]);
- } else if (piValues[4] == highestScoreAlpha) {
- if (getMultiSampleScore(piValues[8]) < lowestScoreMultiSample) {
- highestScore = score;
- highestScorePF = i;
- highestScoreAlpha = piValues[4];
- lowestScoreMultiSample = getMultiSampleScore(piValues[8]);
- }
- }
+ if (mx_ptr[ANTIALIASING] == REQUIRED) {
+ pfd.cAccumRedBits = 8;
+ pfd.cAccumGreenBits = 8;
+ pfd.cAccumBlueBits = 8;
}
}
+ else { /* Offscreen setting. */
+ /* We are here b/c there is no support for Pbuffer on the HW.
+ This is a fallback path, we will hardcore the value. */
+
+ pfd.cRedBits = 0;
+ pfd.cGreenBits = 0;
+ pfd.cBlueBits = 0;
+ pfd.cDepthBits = 32;
+
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.cColorBits = 24;
+ pfd.iLayerType = PFD_MAIN_PLANE;
+ pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI;
- if (debug) {
- printf("Select Pixel Format %d\n", pNumFormats[highestScorePF]);
}
+
+ pFormat = find_DB_S_STDPixelFormat(&pfd, hdc, mx_ptr, offScreen);
- ReleaseDC(hwnd, hdc);
- wglDeleteContext(hrc);
- DestroyWindow(hwnd);
- UnregisterClass(szAppName, (HINSTANCE)NULL);
- return pNumFormats[highestScorePF];
+ if (pFormat == -1) {
+ /* try disable stencil buffer */
+ pfd.cStencilBits = 0;
+ pFormat = find_DB_S_STDPixelFormat(&pfd, hdc, mx_ptr, offScreen);
+ }
+
+ (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT);
+ return pFormat;
}
+PixelFormatInfo * newPixelFormatInfo(HDC hdc)
+{
+ PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;
+
+ PixelFormatInfo *pFormatInfo = (PixelFormatInfo *) malloc(sizeof(PixelFormatInfo));
+
+ /* Initialize pFormatInfo */
+ pFormatInfo->onScreenPFormat = -1;
+ pFormatInfo->offScreenPFormat = -1;
+
+ pFormatInfo->supportARB = GL_FALSE;
+ pFormatInfo->supportPbuffer = GL_FALSE;
+ pFormatInfo->supportedExtensions = NULL;
+ pFormatInfo->wglChoosePixelFormatARB = NULL;
+ pFormatInfo->wglGetPixelFormatAttribivARB = NULL;
+ pFormatInfo->wglCreatePbufferARB = NULL;
+ pFormatInfo->wglGetPbufferDCARB = NULL;
+ pFormatInfo->wglReleasePbufferDCARB = NULL;
+ pFormatInfo->wglDestroyPbufferARB = NULL;
+ pFormatInfo->wglQueryPbufferARB = NULL;
+
+ wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
+ wglGetProcAddress("wglGetExtensionsStringARB");
+ if (wglGetExtensionsStringARB == NULL) {
+ printErrorMessage("wglGetExtensionsStringARB not support !\n");
+ /* Doesn't support extensions, return to use standard choosePixelFormat. */
+ return pFormatInfo;
+ }
+
+ /* get the list of supported extensions */
+ pFormatInfo->supportedExtensions = (char *)wglGetExtensionsStringARB(hdc);
+
+ /* fprintf(stderr, "WGL Supported extensions: %s.\n",
+ pFormatInfo->supportedExtensions); */
+
+ if(isSupportedWGL(pFormatInfo->supportedExtensions, "WGL_ARB_pixel_format")) {
+ pFormatInfo->wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)
+ wglGetProcAddress("wglChoosePixelFormatARB");
+
+ pFormatInfo->wglGetPixelFormatAttribivARB =
+ (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
+ wglGetProcAddress("wglGetPixelFormatAttribivARB");
+
+ if ((pFormatInfo->wglChoosePixelFormatARB != NULL) &&
+ (pFormatInfo->wglGetPixelFormatAttribivARB != NULL)){
+
+ /* fprintf(stderr, "wglChoosePixelFormatARB is supported.\n"); */
+ pFormatInfo->supportARB = GL_TRUE;
+
+ if(isSupportedWGL( pFormatInfo->supportedExtensions, "WGL_ARB_pbuffer")) {
+ /* Get pbuffer entry points */
+ pFormatInfo->wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)
+ wglGetProcAddress("wglCreatePbufferARB");
+ pFormatInfo->wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)
+ wglGetProcAddress("wglGetPbufferDCARB");
+ pFormatInfo->wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)
+ wglGetProcAddress("wglReleasePbufferDCARB");
+ pFormatInfo->wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)
+ wglGetProcAddress("wglDestroyPbufferARB");
+ pFormatInfo->wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)
+ wglGetProcAddress("wglQueryPbufferARB");
+
+ if((pFormatInfo->wglCreatePbufferARB != NULL) &&
+ (pFormatInfo->wglGetPbufferDCARB != NULL) &&
+ (pFormatInfo->wglReleasePbufferDCARB != NULL) &&
+ (pFormatInfo->wglDestroyPbufferARB != NULL) &&
+ (pFormatInfo->wglQueryPbufferARB != NULL)) {
+
+ pFormatInfo->supportPbuffer = GL_TRUE;
+ /* fprintf(stderr, "WGL support Pbuffer\n"); */
+
+ }
+ else {
+ printErrorMessage("Problem in getting WGL_ARB_pbuffer functions !\n");
+ }
+ }
+ }
+ else {
+ printErrorMessage("Problem in getting WGL_ARB_pixel_format functions !\n");
+ }
+ }
+
+ return pFormatInfo;
+}
JNIEXPORT
jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
@@ -1031,92 +1150,214 @@ jint JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_choosePixelFormat(
jobject obj,
jlong ctxInfo,
jint screen,
- jintArray attrList)
+ jintArray attrList,
+ jlongArray offScreenPFArray)
{
- int *mx_ptr;
- int dbVal; /* value for double buffering */
- int sVal; /* value for stereo */
- HDC hdc;
- int pf; /* PixelFormat */
- PIXELFORMATDESCRIPTOR pfd;
-
- mx_ptr = (int *)(*env)->GetIntArrayElements(env, attrList, NULL);
-
- if (mx_ptr[ANTIALIASING] != UNNECESSARY) {
- pf = getExtPixelFormat(mx_ptr);
- if (pf > 0) {
- return pf;
- }
+ static const BOOL debug = TRUE;
+ static char szAppName[] = "Choose Pixel Format";
- /* fallback to use standard ChoosePixelFormat and accumulation buffer */
- }
+ int *mx_ptr;
+ int dbVal; /* value for double buffering */
+ int sVal; /* value for stereo */
+ int antialiasVal; /* value for antialias */
- hdc = getMonitorDC(screen);
+ HWND hwnd;
+ HGLRC hrc;
+ HDC hdc;
+ int pixelFormat;
+ int wglAttrs[MAX_WGL_ATTRS_LENGTH];
+ int index, lastIndex;
+ PixelFormatInfo *pFormatInfo = NULL;
+ jlong * offScreenPFListPtr;
+ PIXELFORMATDESCRIPTOR dummy_pfd = getDummyPFD();
- ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));
- pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
- pfd.nVersion = 1; /*TODO: when would this change? */
- pfd.iPixelType = PFD_TYPE_RGBA;
-
/*
- * Convert Java 3D values to PixelFormat
+ * Select any pixel format and bound current context to
+ * it so that we can get the wglChoosePixelFormatARB entry point.
+ * Otherwise wglxxx entry point will always return null.
+ * That's why we need to create a dummy window also.
*/
+ hwnd = createDummyWindow((const char *)szAppName);
- pfd.cRedBits = (unsigned char) mx_ptr[RED_SIZE];
- pfd.cGreenBits = (unsigned char) mx_ptr[GREEN_SIZE];
- pfd.cBlueBits = (unsigned char) mx_ptr[BLUE_SIZE];
- pfd.cDepthBits = (unsigned char) mx_ptr[DEPTH_SIZE];
+ if (!hwnd) {
+ return -1;
+ }
+ hdc = GetDC(hwnd);
- if (mx_ptr[DOUBLEBUFFER] == REQUIRED || mx_ptr[DOUBLEBUFFER] == PREFERRED)
- dbVal = PFD_DOUBLEBUFFER;
- else
- dbVal = PFD_DOUBLEBUFFER_DONTCARE;
+ pixelFormat = ChoosePixelFormat(hdc, &dummy_pfd);
- sVal = 0;
- if (mx_ptr[STEREO] == REQUIRED || mx_ptr[STEREO] == PREFERRED) {
- sVal = PFD_STEREO;
- } else {
- sVal = 0;
+ if (pixelFormat<1) {
+ printErrorMessage("In NativeConfigTemplate : Failed in ChoosePixelFormat");
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return -1;
}
+
+ SetPixelFormat(hdc, pixelFormat, NULL);
- pfd.dwFlags = dbVal | sVal | PFD_SUPPORT_OPENGL;
- pfd.cStencilBits = 2;
+ hrc = wglCreateContext(hdc);
+ if (!hrc) {
+ printErrorMessage("In NativeConfigTemplate : Failed in wglCreateContext");
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return -1;
+ }
- if (mx_ptr[ANTIALIASING] == REQUIRED || mx_ptr[ANTIALIASING] == PREFERRED) {
- pfd.cAccumRedBits = 8;
- pfd.cAccumGreenBits = 8;
- pfd.cAccumBlueBits = 8;
+ if (!wglMakeCurrent(hdc, hrc)) {
+ printErrorMessage("In NativeConfigTemplate : Failed in wglMakeCurrent");
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return -1;
}
- pf = findPixelFormatSwitchDoubleBufferAndStereo(&pfd, hdc, mx_ptr);
+ pFormatInfo = newPixelFormatInfo(hdc);
+
+ offScreenPFListPtr = (*env)->GetLongArrayElements(env, offScreenPFArray, NULL);
- if (pf == -1) {
- /* try disable stencil buffer */
- pfd.cStencilBits = 0;
- pf = findPixelFormatSwitchDoubleBufferAndStereo(&pfd, hdc, mx_ptr);
-
- if (pf == -1) {
- /* try disable accumulate buffer */
- if (mx_ptr[ANTIALIASING] == PREFERRED) {
- pfd.cStencilBits = 2;
- pfd.cAccumRedBits = 0;
- pfd.cAccumGreenBits = 0;
- pfd.cAccumBlueBits = 0;
- pf = findPixelFormatSwitchDoubleBufferAndStereo(&pfd, hdc, mx_ptr);
-
- if (pf == -1) {
- /* try disable stencil buffer */
- pfd.cStencilBits = 0;
- pf = findPixelFormatSwitchDoubleBufferAndStereo(&pfd, hdc, mx_ptr);
- }
+ if(pFormatInfo->supportARB) {
+
+ mx_ptr = (*env)->GetIntArrayElements(env, attrList, NULL);
+
+ /*
+ * convert Java 3D values to WGL
+ */
+ index = 0;
+
+ wglAttrs[index++] = WGL_SUPPORT_OPENGL_ARB;
+ wglAttrs[index++] = TRUE;
+ wglAttrs[index++] = WGL_DRAW_TO_WINDOW_ARB;
+ wglAttrs[index++] = TRUE;
+ wglAttrs[index++] = WGL_RED_BITS_ARB;
+ wglAttrs[index++] = mx_ptr[RED_SIZE];
+ wglAttrs[index++] = WGL_GREEN_BITS_ARB;
+ wglAttrs[index++] = mx_ptr[GREEN_SIZE];
+ wglAttrs[index++] = WGL_BLUE_BITS_ARB;
+ wglAttrs[index++] = mx_ptr[BLUE_SIZE];
+ wglAttrs[index++] = WGL_DEPTH_BITS_ARB;
+ wglAttrs[index++] = mx_ptr[DEPTH_SIZE];
+
+ lastIndex = index;
+
+ dbVal = mx_ptr[DOUBLEBUFFER];
+ sVal = mx_ptr[STEREO];
+ antialiasVal = mx_ptr[ANTIALIASING];
+
+ (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT);
+
+ if(pFormatInfo->supportPbuffer) {
+
+ wglAttrs[index++] = WGL_DRAW_TO_PBUFFER_ARB;
+ wglAttrs[index++] = TRUE;
+
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormatInfo->onScreenPFormat = find_DB_AA_S_PixelFormat( hdc, pFormatInfo,
+ wglAttrs, sVal, dbVal,
+ antialiasVal, index);
+
+ if(pFormatInfo->onScreenPFormat >= 0) {
+
+ /* Since the return pixel format support pbuffer,
+ copy OnScreenPFormat to offScreenPFormat */
+ pFormatInfo->offScreenPFormat = pFormatInfo->onScreenPFormat;
+ offScreenPFListPtr[0] = (jlong) pFormatInfo;
+ (*env)->ReleaseLongArrayElements(env, offScreenPFArray, offScreenPFListPtr, 0);
+
+ /* Destroy all dummy objects */
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+
+ return (jint) pFormatInfo->onScreenPFormat;
}
+
}
+
+ /* Create a onScreen without Pbuffer */
+ index = lastIndex;
+
+ /*
+ * Terminate by 2 zeros to avoid driver bugs
+ * that assume attributes always come in pairs.
+ */
+ wglAttrs[index] = 0;
+ wglAttrs[index+1] = 0;
+
+ pFormatInfo->onScreenPFormat = find_DB_AA_S_PixelFormat( hdc, pFormatInfo,
+ wglAttrs, sVal, dbVal,
+ antialiasVal, index);
+
+ }
+
+
+ if(pFormatInfo->onScreenPFormat < 0) { /* Fallback to use standard ChoosePixelFormat. */
+ /* fprintf(stderr, "Fallback to use standard ChoosePixelFormat.\n"); */
+
+ pFormatInfo->onScreenPFormat = (jint) chooseSTDPixelFormat( env, screen,
+ attrList, hdc, GL_FALSE);
+
}
- DeleteDC(hdc);
+ if(pFormatInfo->onScreenPFormat < 0) {
+ printErrorMessage("In NativeConfigTemplate : Can't choose a onScreen pixel format");
+
+ offScreenPFListPtr[0] = (jlong) pFormatInfo;
+ (*env)->ReleaseLongArrayElements(env, offScreenPFArray, offScreenPFListPtr, 0);
- (*env)->ReleaseIntArrayElements(env, attrList, mx_ptr, JNI_ABORT);
- return pf;
+ /* We are done with dummy context, so destroy all dummy objects */
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+
+ return -1;
+ }
+
+ /* Create offScreen with standard ChoosePixelFormat */
+ pFormatInfo->offScreenPFormat = chooseSTDPixelFormat( env, screen, attrList, hdc, GL_TRUE);
+
+ /* fprintf(stderr, "********* offScreenPFormat = %d\n", pFormatInfo->offScreenPFormat ); */
+
+ offScreenPFListPtr[0] = (jlong) pFormatInfo;
+ (*env)->ReleaseLongArrayElements(env, offScreenPFArray, offScreenPFListPtr, 0);
+
+ /* We are done with dummy context, so destroy all dummy objects */
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+
+ return (jint) pFormatInfo->onScreenPFormat;
+}
+
+
+JNIEXPORT
+void JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_freePixelFormatInfo(
+ JNIEnv *env,
+ jclass class, /* this is a static native method */
+ jlong pFormatInfo)
+{
+ PixelFormatInfo *pfInfo = (PixelFormatInfo *) pFormatInfo;
+ if(pfInfo->supportedExtensions != NULL) {
+ free(pfInfo->supportedExtensions);
+ pfInfo->supportedExtensions = NULL;
+ }
+ pfInfo->wglChoosePixelFormatARB = NULL;
+ pfInfo->wglGetPixelFormatAttribivARB = NULL;
+ pfInfo->wglCreatePbufferARB = NULL;
+ pfInfo->wglGetPbufferDCARB = NULL;
+ pfInfo->wglReleasePbufferDCARB = NULL;
+ pfInfo->wglDestroyPbufferARB = NULL;
+ pfInfo->wglQueryPbufferARB = NULL;
+ free(pfInfo);
}
diff --git a/src/native/ogl/NativeScreenInfo.c b/src/native/ogl/NativeScreenInfo.c
index 23ad8b8..0c588c6 100644
--- a/src/native/ogl/NativeScreenInfo.c
+++ b/src/native/ogl/NativeScreenInfo.c
@@ -18,6 +18,7 @@
#include <jni.h>
#include <math.h>
+#include <stdio.h>
#include "gldefs.h"
@@ -125,4 +126,108 @@ Java_javax_media_j3d_NativeScreenInfo_queryGLX13(
return JNI_TRUE;
}
-#endif
+#endif /* Solaris and Linux */
+
+
+#ifdef WIN32
+
+extern HWND createDummyWindow(const char* szAppName);
+extern void printErrorMessage(char *message);
+extern PIXELFORMATDESCRIPTOR getDummyPFD();
+extern BOOL isSupportedWGL(const char *extensions, const char *extension_string);
+
+/*
+ * Class: javax_media_j3d_NativeScreenInfo
+ * Method: queryWglARB
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_javax_media_j3d_NativeScreenInfo_queryWglARB(
+ JNIEnv *env,
+ jclass cls)
+{
+
+ static const BOOL debug = TRUE;
+ static char szAppName[] = "Choose Pixel Format";
+
+ PIXELFORMATDESCRIPTOR dummy_pfd = getDummyPFD();
+ HWND hwnd;
+ HGLRC hrc;
+ HDC hdc;
+ int pixelFormat;
+ const char* supportedExtensions;
+
+ /* declare function pointers for WGL functions */
+ PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;
+
+ /*
+ * Select any pixel format and bound current context to
+ * it so that we can get the wglChoosePixelFormatARB entry point.
+ * Otherwise wglxxx entry point will always return null.
+ * That's why we need to create a dummy window also.
+ */
+ hwnd = createDummyWindow((const char *)szAppName);
+
+ if (!hwnd) {
+ return JNI_FALSE;
+ }
+ hdc = GetDC(hwnd);
+
+ pixelFormat = ChoosePixelFormat(hdc, &dummy_pfd);
+
+ if (pixelFormat<1) {
+ printErrorMessage("Failed in ChoosePixelFormat");
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return JNI_FALSE;
+ }
+
+ SetPixelFormat(hdc, pixelFormat, NULL);
+
+ hrc = wglCreateContext(hdc);
+ if (!hrc) {
+ printErrorMessage("Failed in wglCreateContext");
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return JNI_FALSE;
+ }
+
+ if (!wglMakeCurrent(hdc, hrc)) {
+ printErrorMessage("Failed in wglMakeCurrent");
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return JNI_FALSE;
+ }
+
+ wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
+ wglGetProcAddress("wglGetExtensionsStringARB");
+ if (wglGetExtensionsStringARB == NULL) {
+ /* printErrorMessage("wglGetExtensionsStringARB not support !\n"); */
+ return JNI_FALSE;
+ }
+ else {
+
+ /* get the list of supported extensions */
+ supportedExtensions = (const char *)wglGetExtensionsStringARB(hdc);
+
+ if (debug) {
+ fprintf(stderr, "WGL Supported extensions: %s.\n", supportedExtensions);
+ }
+
+ if(!isSupportedWGL(supportedExtensions, "WGL_ARB_pixel_format")) {
+ fprintf(stderr, "WGL_ARB_pixel_format not supported.\n");
+ return JNI_FALSE;
+ }
+ }
+
+ ReleaseDC(hwnd, hdc);
+ wglDeleteContext(hrc);
+ DestroyWindow(hwnd);
+ UnregisterClass(szAppName, (HINSTANCE)NULL);
+ return JNI_TRUE;
+
+
+}
+#endif /* WIN32 */
diff --git a/src/native/ogl/gl_1_2.h b/src/native/ogl/gl_1_2.h
index b540d3e..dd33949 100644
--- a/src/native/ogl/gl_1_2.h
+++ b/src/native/ogl/gl_1_2.h
@@ -93,16 +93,12 @@ extern "C" {
#ifndef GL_ARB_texture_border_clamp
#define GL_CLAMP_TO_BORDER_ARB 0x812D
#endif
-
-#ifndef GL_ARB_multisample
+
#if defined(SOLARIS) || defined(__linux__)
+#ifndef GL_ARB_multisample
#define GLX_SAMPLE_BUFFERS_ARB 100000
#define GLX_SAMPLES_ARB 100001
-#endif
-#ifdef WIN32
-#define WGL_SAMPLE_BUFFERS_ARB 0x2041
-#define WGL_SAMPLES_ARB 0x2042
-#endif
+
#define MULTISAMPLE_ARB 0x809D
#define SAMPLE_ALPHA_TO_COVERATE_ARB 0x809E
#define SAMPLE_ALPHA_TO_ONE_ARB 0x809F
@@ -113,76 +109,12 @@ extern "C" {
#define SAMPLE_COVERAGE_VALUE_ARB 0x80AA
#define SAMPLE_COVERAGE_INVERT_ARB 0x80AB
#endif /* GL_ARB_multisample */
+#endif /* SOLARIS */
#ifndef MULTISAMPLE_ARB
#define MULTISAMPLE_ARB 0x809D
#endif
-
-#ifdef WIN32
-
-/* define those EXT_pixel_format enums from 3DLabs register developer web site */
-#ifndef WGL_SUPPORT_OPENGL_EXT
-#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
-#define WGL_DRAW_TO_WINDOW_EXT 0x2001
-#define WGL_DRAW_TO_BITMAP_EXT 0x2002
-#define WGL_ACCELERATION_EXT 0x2003
-#define WGL_NEED_PALETTE_EXT 0x2004
-#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
-#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
-#define WGL_SWAP_METHOD_EXT 0x2007
-#define WGL_NUMBER_OVERLAYS_EXT 0x2008
-#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
-#define WGL_TRANSPARENT_EXT 0x200A
-#define WGL_TRANSPARENT_VALUE_EXT 0x200B
-#define WGL_SHARE_DEPTH_EXT 0x200C
-#define WGL_SHARE_STENCIL_EXT 0x200D
-#define WGL_SHARE_ACCUM_EXT 0x200E
-#define WGL_SUPPORT_GDI_EXT 0x200F
-#define WGL_SUPPORT_OPENGL_EXT 0x2010
-#define WGL_DOUBLE_BUFFER_EXT 0x2011
-#define WGL_STEREO_EXT 0x2012
-#define WGL_PIXEL_TYPE_EXT 0x2013
-#define WGL_COLOR_BITS_EXT 0x2014
-#define WGL_RED_BITS_EXT 0x2015
-#define WGL_RED_SHIFT_EXT 0x2016
-#define WGL_GREEN_BITS_EXT 0x2017
-#define WGL_GREEN_SHIFT_EXT 0x2018
-#define WGL_BLUE_BITS_EXT 0x2019
-#define WGL_BLUE_SHIFT_EXT 0x201A
-#define WGL_ALPHA_BITS_EXT 0x201B
-#define WGL_ALPHA_SHIFT_EXT 0x201C
-#define WGL_ACCUM_BITS_EXT 0x201D
-#define WGL_ACCUM_RED_BITS_EXT 0x201E
-#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
-#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
-#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
-#define WGL_DEPTH_BITS_EXT 0x2022
-#define WGL_STENCIL_BITS_EXT 0x2023
-#define WGL_AUX_BUFFERS_EXT 0x2024
-#define WGL_NO_ACCELERATION_EXT 0x2025
-#define WGL_GENERIC_ACCELERATION_EXT 0x2026
-#define WGL_FULL_ACCELERATION_EXT 0x2027
-#define WGL_SWAP_EXCHANGE_EXT 0x2028
-#define WGL_SWAP_COPY_EXT 0x2029
-#define WGL_SWAP_UNDEFINED_EXT 0x202A
-#define WGL_TYPE_RGBA_EXT 0x202B
-#define WGL_TYPE_COLORINDEX_EXT 0x202C
-#endif /* WGL_SUPPORT_OPENGL_EXT */
-
-/* define those ARB_pixel_format enums */
-#ifndef WGL_SUPPORT_OPENGL_ARB
-#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
-#define WGL_SUPPORT_OPENGL_ARB 0x2010
-#define WGL_DRAW_TO_WINDOW_ARB 0x2001
-#define WGL_DOUBLE_BUFFER_ARB 0x2011
-#define WGL_STEREO_ARB 0x2012
-#define WGL_RED_BITS_ARB 0x2015
-#define WGL_GREEN_BITS_ARB 0x2017
-#define WGL_BLUE_BITS_ARB 0x2019
-#define WGL_DEPTH_BITS_ARB 0x2022
-#endif /* WGL_SUPPORT_OPENGL_ARB */
-
-#endif /* WIN32 */
+
#ifdef __cplusplus
}
diff --git a/src/native/ogl/gldefs.h b/src/native/ogl/gldefs.h
index 6658201..a79762a 100644
--- a/src/native/ogl/gldefs.h
+++ b/src/native/ogl/gldefs.h
@@ -72,6 +72,7 @@
#ifndef D3D
#include <GL/gl.h>
+#include "wglext.h"
#include "gl_1_2.h"
#include "glext.h"
#endif
@@ -389,27 +390,6 @@ extern int glXgetVideoResizeSUN( Display *, GLXDrawable, float *);
#define APIENTRY
#endif
-#ifdef WIN32
-
-/* declare function prototype for WGL related functions*/
-typedef const char * (APIENTRY * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (HDC hdc);
-typedef BOOL (APIENTRY * PFNWGLCHOOSEPIXELFORMATEXTPROC)(HDC hdc,
- const int *piAttribIList,
- const FLOAT *pfAttriFList,
- UINT nMaxFormats,
- int *piFormats,
- UINT *nNumFormats);
-typedef BOOL (APIENTRY * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)(HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- int *piValues);
-
-
-
-#endif /* WIN32 */
-
/* define function prototypes */
typedef void (APIENTRY * MYPFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green,
GLclampf blue, GLclampf alpha);
@@ -641,5 +621,48 @@ typedef struct {
MYPFNGLTEXFILTERFUNCSGI glTexFilterFuncSGIS;
} GraphicsContextPropertiesInfo;
-#endif /* J3D_BUILDVERTICES */
+
+#ifdef WIN32
+
+/* define the structure to hold the info. of a pixel format */
+typedef struct PixelFormatInfoRec PixelFormatInfo;
+
+struct PixelFormatInfoRec {
+ int onScreenPFormat; /* PixelFormat for onScreen */
+ int offScreenPFormat; /* PixelFormat for offScreen */
+ GLboolean supportARB; /* TRUE if ARB is supported */
+ GLboolean supportPbuffer; /* TRUE if Pbuffer is supported */
+ char* supportedExtensions; /* list of supported ARB extensions */
+ /* handle to ARB functions */
+ PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
+ PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB;
+ PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB;
+ PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB;
+ PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB;
+ PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB;
+ PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB;
+
+ /* TODO include multi-samples buffer */
+
+};
+
+#endif /* WIN32 */
+
+/* define the structure to hold the info. of a offScreen buffer */
+typedef struct OffScreenBufferInfoRec OffScreenBufferInfo;
+
+struct OffScreenBufferInfoRec {
+ GLboolean isPbuffer; /* GL_TRUE if Pbuffer is used. */
+
+#if defined(SOLARIS) || defined(__linux__)
+#endif
+
+#ifdef WIN32
+ HPBUFFERARB hpbuf; /* Handle to the Pbuffer */
+#endif /* WIN32 */
+
+};
+
+
+#endif /* D3D */
#endif /* _Java3D_gldefs_h_ */
diff --git a/src/native/ogl/wglext.h b/src/native/ogl/wglext.h
new file mode 100644
index 0000000..d1ab334
--- /dev/null
+++ b/src/native/ogl/wglext.h
@@ -0,0 +1,619 @@
+#ifndef __wglext_h_
+#define __wglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+/* Header file version number */
+/* wglext.h last updated 2004/07/26 */
+/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
+#define WGL_WGLEXT_VERSION 5
+
+#ifndef WGL_ARB_buffer_region
+#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
+#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
+#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
+#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
+#endif
+
+#ifndef WGL_ARB_multisample
+#define WGL_SAMPLE_BUFFERS_ARB 0x2041
+#define WGL_SAMPLES_ARB 0x2042
+#endif
+
+#ifndef WGL_ARB_extensions_string
+#endif
+
+#ifndef WGL_ARB_pixel_format
+#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
+#define WGL_DRAW_TO_WINDOW_ARB 0x2001
+#define WGL_DRAW_TO_BITMAP_ARB 0x2002
+#define WGL_ACCELERATION_ARB 0x2003
+#define WGL_NEED_PALETTE_ARB 0x2004
+#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
+#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
+#define WGL_SWAP_METHOD_ARB 0x2007
+#define WGL_NUMBER_OVERLAYS_ARB 0x2008
+#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
+#define WGL_TRANSPARENT_ARB 0x200A
+#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
+#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
+#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
+#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
+#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
+#define WGL_SHARE_DEPTH_ARB 0x200C
+#define WGL_SHARE_STENCIL_ARB 0x200D
+#define WGL_SHARE_ACCUM_ARB 0x200E
+#define WGL_SUPPORT_GDI_ARB 0x200F
+#define WGL_SUPPORT_OPENGL_ARB 0x2010
+#define WGL_DOUBLE_BUFFER_ARB 0x2011
+#define WGL_STEREO_ARB 0x2012
+#define WGL_PIXEL_TYPE_ARB 0x2013
+#define WGL_COLOR_BITS_ARB 0x2014
+#define WGL_RED_BITS_ARB 0x2015
+#define WGL_RED_SHIFT_ARB 0x2016
+#define WGL_GREEN_BITS_ARB 0x2017
+#define WGL_GREEN_SHIFT_ARB 0x2018
+#define WGL_BLUE_BITS_ARB 0x2019
+#define WGL_BLUE_SHIFT_ARB 0x201A
+#define WGL_ALPHA_BITS_ARB 0x201B
+#define WGL_ALPHA_SHIFT_ARB 0x201C
+#define WGL_ACCUM_BITS_ARB 0x201D
+#define WGL_ACCUM_RED_BITS_ARB 0x201E
+#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
+#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
+#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
+#define WGL_DEPTH_BITS_ARB 0x2022
+#define WGL_STENCIL_BITS_ARB 0x2023
+#define WGL_AUX_BUFFERS_ARB 0x2024
+#define WGL_NO_ACCELERATION_ARB 0x2025
+#define WGL_GENERIC_ACCELERATION_ARB 0x2026
+#define WGL_FULL_ACCELERATION_ARB 0x2027
+#define WGL_SWAP_EXCHANGE_ARB 0x2028
+#define WGL_SWAP_COPY_ARB 0x2029
+#define WGL_SWAP_UNDEFINED_ARB 0x202A
+#define WGL_TYPE_RGBA_ARB 0x202B
+#define WGL_TYPE_COLORINDEX_ARB 0x202C
+#endif
+
+#ifndef WGL_ARB_make_current_read
+#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
+#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
+#endif
+
+#ifndef WGL_ARB_pbuffer
+#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
+#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
+#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
+#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
+#define WGL_PBUFFER_LARGEST_ARB 0x2033
+#define WGL_PBUFFER_WIDTH_ARB 0x2034
+#define WGL_PBUFFER_HEIGHT_ARB 0x2035
+#define WGL_PBUFFER_LOST_ARB 0x2036
+#endif
+
+#ifndef WGL_ARB_render_texture
+#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
+#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
+#define WGL_TEXTURE_FORMAT_ARB 0x2072
+#define WGL_TEXTURE_TARGET_ARB 0x2073
+#define WGL_MIPMAP_TEXTURE_ARB 0x2074
+#define WGL_TEXTURE_RGB_ARB 0x2075
+#define WGL_TEXTURE_RGBA_ARB 0x2076
+#define WGL_NO_TEXTURE_ARB 0x2077
+#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
+#define WGL_TEXTURE_1D_ARB 0x2079
+#define WGL_TEXTURE_2D_ARB 0x207A
+#define WGL_MIPMAP_LEVEL_ARB 0x207B
+#define WGL_CUBE_MAP_FACE_ARB 0x207C
+#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
+#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
+#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
+#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
+#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
+#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
+#define WGL_FRONT_LEFT_ARB 0x2083
+#define WGL_FRONT_RIGHT_ARB 0x2084
+#define WGL_BACK_LEFT_ARB 0x2085
+#define WGL_BACK_RIGHT_ARB 0x2086
+#define WGL_AUX0_ARB 0x2087
+#define WGL_AUX1_ARB 0x2088
+#define WGL_AUX2_ARB 0x2089
+#define WGL_AUX3_ARB 0x208A
+#define WGL_AUX4_ARB 0x208B
+#define WGL_AUX5_ARB 0x208C
+#define WGL_AUX6_ARB 0x208D
+#define WGL_AUX7_ARB 0x208E
+#define WGL_AUX8_ARB 0x208F
+#define WGL_AUX9_ARB 0x2090
+#endif
+
+#ifndef WGL_EXT_make_current_read
+#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
+#endif
+
+#ifndef WGL_EXT_pixel_format
+#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
+#define WGL_DRAW_TO_WINDOW_EXT 0x2001
+#define WGL_DRAW_TO_BITMAP_EXT 0x2002
+#define WGL_ACCELERATION_EXT 0x2003
+#define WGL_NEED_PALETTE_EXT 0x2004
+#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
+#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
+#define WGL_SWAP_METHOD_EXT 0x2007
+#define WGL_NUMBER_OVERLAYS_EXT 0x2008
+#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
+#define WGL_TRANSPARENT_EXT 0x200A
+#define WGL_TRANSPARENT_VALUE_EXT 0x200B
+#define WGL_SHARE_DEPTH_EXT 0x200C
+#define WGL_SHARE_STENCIL_EXT 0x200D
+#define WGL_SHARE_ACCUM_EXT 0x200E
+#define WGL_SUPPORT_GDI_EXT 0x200F
+#define WGL_SUPPORT_OPENGL_EXT 0x2010
+#define WGL_DOUBLE_BUFFER_EXT 0x2011
+#define WGL_STEREO_EXT 0x2012
+#define WGL_PIXEL_TYPE_EXT 0x2013
+#define WGL_COLOR_BITS_EXT 0x2014
+#define WGL_RED_BITS_EXT 0x2015
+#define WGL_RED_SHIFT_EXT 0x2016
+#define WGL_GREEN_BITS_EXT 0x2017
+#define WGL_GREEN_SHIFT_EXT 0x2018
+#define WGL_BLUE_BITS_EXT 0x2019
+#define WGL_BLUE_SHIFT_EXT 0x201A
+#define WGL_ALPHA_BITS_EXT 0x201B
+#define WGL_ALPHA_SHIFT_EXT 0x201C
+#define WGL_ACCUM_BITS_EXT 0x201D
+#define WGL_ACCUM_RED_BITS_EXT 0x201E
+#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
+#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
+#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
+#define WGL_DEPTH_BITS_EXT 0x2022
+#define WGL_STENCIL_BITS_EXT 0x2023
+#define WGL_AUX_BUFFERS_EXT 0x2024
+#define WGL_NO_ACCELERATION_EXT 0x2025
+#define WGL_GENERIC_ACCELERATION_EXT 0x2026
+#define WGL_FULL_ACCELERATION_EXT 0x2027
+#define WGL_SWAP_EXCHANGE_EXT 0x2028
+#define WGL_SWAP_COPY_EXT 0x2029
+#define WGL_SWAP_UNDEFINED_EXT 0x202A
+#define WGL_TYPE_RGBA_EXT 0x202B
+#define WGL_TYPE_COLORINDEX_EXT 0x202C
+#endif
+
+#ifndef WGL_EXT_pbuffer
+#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
+#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
+#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
+#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
+#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
+#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
+#define WGL_PBUFFER_LARGEST_EXT 0x2033
+#define WGL_PBUFFER_WIDTH_EXT 0x2034
+#define WGL_PBUFFER_HEIGHT_EXT 0x2035
+#endif
+
+#ifndef WGL_EXT_depth_float
+#define WGL_DEPTH_FLOAT_EXT 0x2040
+#endif
+
+#ifndef WGL_3DFX_multisample
+#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
+#define WGL_SAMPLES_3DFX 0x2061
+#endif
+
+#ifndef WGL_EXT_multisample
+#define WGL_SAMPLE_BUFFERS_EXT 0x2041
+#define WGL_SAMPLES_EXT 0x2042
+#endif
+
+#ifndef WGL_I3D_digital_video_control
+#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
+#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
+#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
+#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
+#endif
+
+#ifndef WGL_I3D_gamma
+#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
+#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
+#endif
+
+#ifndef WGL_I3D_genlock
+#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
+#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
+#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
+#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
+#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
+#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
+#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
+#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
+#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
+#endif
+
+#ifndef WGL_I3D_image_buffer
+#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
+#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
+#endif
+
+#ifndef WGL_I3D_swap_frame_lock
+#endif
+
+#ifndef WGL_NV_render_depth_texture
+#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
+#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
+#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
+#define WGL_DEPTH_COMPONENT_NV 0x20A7
+#endif
+
+#ifndef WGL_NV_render_texture_rectangle
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
+#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
+#endif
+
+#ifndef WGL_ATI_pixel_format_float
+#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
+#endif
+
+#ifndef WGL_NV_float_buffer
+#define WGL_FLOAT_COMPONENTS_NV 0x20B0
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
+#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
+#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
+#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
+#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
+#endif
+
+
+/*************************************************************/
+
+#ifndef WGL_ARB_pbuffer
+DECLARE_HANDLE(HPBUFFERARB);
+#endif
+#ifndef WGL_EXT_pbuffer
+DECLARE_HANDLE(HPBUFFEREXT);
+#endif
+
+#ifndef WGL_ARB_buffer_region
+#define WGL_ARB_buffer_region 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT);
+extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE);
+extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int);
+extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
+typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
+typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
+typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
+#endif
+
+#ifndef WGL_ARB_multisample
+#define WGL_ARB_multisample 1
+#endif
+
+#ifndef WGL_ARB_extensions_string
+#define WGL_ARB_extensions_string 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern const char * WINAPI wglGetExtensionsStringARB (HDC);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
+#endif
+
+#ifndef WGL_ARB_pixel_format
+#define WGL_ARB_pixel_format 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *);
+extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *);
+extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
+typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+#endif
+
+#ifndef WGL_ARB_make_current_read
+#define WGL_ARB_make_current_read 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC);
+extern HDC WINAPI wglGetCurrentReadDCARB (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
+#endif
+
+#ifndef WGL_ARB_pbuffer
+#define WGL_ARB_pbuffer 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *);
+extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB);
+extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC);
+extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB);
+extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
+typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
+typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
+typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
+#endif
+
+#ifndef WGL_ARB_render_texture
+#define WGL_ARB_render_texture 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int);
+extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int);
+extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
+typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
+typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
+#endif
+
+#ifndef WGL_EXT_display_color_table
+#define WGL_EXT_display_color_table 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort);
+extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint);
+extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort);
+extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
+typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
+typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
+typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
+#endif
+
+#ifndef WGL_EXT_extensions_string
+#define WGL_EXT_extensions_string 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern const char * WINAPI wglGetExtensionsStringEXT (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
+#endif
+
+#ifndef WGL_EXT_make_current_read
+#define WGL_EXT_make_current_read 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC);
+extern HDC WINAPI wglGetCurrentReadDCEXT (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
+#endif
+
+#ifndef WGL_EXT_pbuffer
+#define WGL_EXT_pbuffer 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *);
+extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT);
+extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC);
+extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT);
+extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
+typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
+typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
+typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
+#endif
+
+#ifndef WGL_EXT_pixel_format
+#define WGL_EXT_pixel_format 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *);
+extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *);
+extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
+typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+#endif
+
+#ifndef WGL_EXT_swap_control
+#define WGL_EXT_swap_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglSwapIntervalEXT (int);
+extern int WINAPI wglGetSwapIntervalEXT (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
+typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
+#endif
+
+#ifndef WGL_EXT_depth_float
+#define WGL_EXT_depth_float 1
+#endif
+
+#ifndef WGL_NV_vertex_array_range
+#define WGL_NV_vertex_array_range 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat);
+extern void WINAPI wglFreeMemoryNV (void *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
+#endif
+
+#ifndef WGL_3DFX_multisample
+#define WGL_3DFX_multisample 1
+#endif
+
+#ifndef WGL_EXT_multisample
+#define WGL_EXT_multisample 1
+#endif
+
+#ifndef WGL_OML_sync_control
+#define WGL_OML_sync_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *);
+extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *);
+extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64);
+extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64);
+extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *);
+extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
+typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
+typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
+typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
+#endif
+
+#ifndef WGL_I3D_digital_video_control
+#define WGL_I3D_digital_video_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *);
+extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
+typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
+#endif
+
+#ifndef WGL_I3D_gamma
+#define WGL_I3D_gamma 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *);
+extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *);
+extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *);
+extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
+typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
+typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
+typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
+#endif
+
+#ifndef WGL_I3D_genlock
+#define WGL_I3D_genlock 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglEnableGenlockI3D (HDC);
+extern BOOL WINAPI wglDisableGenlockI3D (HDC);
+extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *);
+extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT);
+extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *);
+extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT);
+extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *);
+extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT);
+extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *);
+extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT);
+extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *);
+extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
+typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
+typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
+typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
+#endif
+
+#ifndef WGL_I3D_image_buffer
+#define WGL_I3D_image_buffer 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT);
+extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID);
+extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT);
+extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
+typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
+typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
+typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
+#endif
+
+#ifndef WGL_I3D_swap_frame_lock
+#define WGL_I3D_swap_frame_lock 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglEnableFrameLockI3D (void);
+extern BOOL WINAPI wglDisableFrameLockI3D (void);
+extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *);
+extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
+typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
+#endif
+
+#ifndef WGL_I3D_swap_frame_usage
+#define WGL_I3D_swap_frame_usage 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetFrameUsageI3D (float *);
+extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
+extern BOOL WINAPI wglEndFrameTrackingI3D (void);
+extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
+typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
+#endif
+
+#ifndef WGL_ATI_pixel_format_float
+#define WGL_ATI_pixel_format_float 1
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif