diff options
author | Sven Gothel <[email protected]> | 2001-02-23 05:14:46 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2001-02-23 05:14:46 +0000 |
commit | 991622dd909d94b6ed83b84b744f0839b9ab6807 (patch) | |
tree | 3bcf3c79e8ea11358966710d0884a4416a74f8e6 /CNativeCode | |
parent | 82cd20ed209f12e22e2f5a92719b3be2bb92d8ed (diff) |
Version 2.6.0.0
Diffstat (limited to 'CNativeCode')
-rwxr-xr-x | CNativeCode/GLDrawableFactory_Win32_SunJDK13.c | 174 | ||||
-rw-r--r-- | CNativeCode/GLDrawableFactory_X11_SunJDK13.c | 106 |
2 files changed, 280 insertions, 0 deletions
diff --git a/CNativeCode/GLDrawableFactory_Win32_SunJDK13.c b/CNativeCode/GLDrawableFactory_Win32_SunJDK13.c new file mode 100755 index 0000000..7a085d5 --- /dev/null +++ b/CNativeCode/GLDrawableFactory_Win32_SunJDK13.c @@ -0,0 +1,174 @@ +#include "gl4java_drawable_Win32SunJDK13GLDrawableFactory.h"
+#include <windows.h>
+
+/* FIXME: extend to support multiple monitors on Win2K/98 */
+static HDC getScreenDC(int screen)
+{
+ return CreateDC("DISPLAY", NULL, NULL, NULL);
+}
+
+static void freeScreenDC(HDC dc)
+{
+ DeleteDC(dc);
+}
+
+
+JNIEXPORT jboolean JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualSupportsOpenGL(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jboolean res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = (jboolean) (pfd.dwFlags & PFD_SUPPORT_OPENGL != 0);
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualDoubleBuffered(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jboolean res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = (jboolean) (pfd.dwFlags & PFD_DOUBLEBUFFER != 0);
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualTrueColor(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jboolean res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = (jboolean) (pfd.iPixelType == PFD_TYPE_RGBA);
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualStereo(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jboolean res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = (jboolean) (pfd.dwFlags & PFD_STEREO != 0);
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jint JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualDepthBits(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jint res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = pfd.cDepthBits;
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jint JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualStencilBits(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jint res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = pfd.cStencilBits;
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jint JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualColorBits(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jint res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = pfd.cColorBits;
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jint JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualColorShiftBits(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jint res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = pfd.cRedShift+pfd.cGreenShift+pfd.cBlueShift+pfd.cAlphaShift;
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jint JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualAlphaBits(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jint res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = pfd.cAlphaBits;
+ freeScreenDC(dc);
+ return res;
+}
+
+JNIEXPORT jint JNICALL
+Java_gl4java_drawable_Win32SunJDK13GLDrawableFactory_getVisualAccumBits(JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jint pixId)
+{
+ HDC dc;
+ PIXELFORMATDESCRIPTOR pfd;
+ jint res;
+ dc = getScreenDC(screen);
+ DescribePixelFormat(dc, pixId, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ res = pfd.cAccumBits;
+ freeScreenDC(dc);
+ return res;
+}
diff --git a/CNativeCode/GLDrawableFactory_X11_SunJDK13.c b/CNativeCode/GLDrawableFactory_X11_SunJDK13.c new file mode 100644 index 0000000..51e204c --- /dev/null +++ b/CNativeCode/GLDrawableFactory_X11_SunJDK13.c @@ -0,0 +1,106 @@ +#include "gl4java_drawable_X11SunJDK13GLDrawableFactory.h"
+#include "OpenGL_X11_common.h"
+
+JNIEXPORT jlong JNICALL
+Java_gl4java_drawable_X11SunJDK13GLDrawableFactory_glXChooseVisualID
+ (JNIEnv *env,
+ jclass unused,
+ jint screen,
+ jlong display,
+ jobject capsObj, jboolean verbose)
+{
+ Display *disp = (Display *) ( (PointerHolder)display );
+
+ XVisualInfo * visual=NULL;
+ int visualAttribList[32];
+ int done=0;
+
+ GLCapabilities glCaps;
+
+ jboolean ok = javaGLCapabilities2NativeGLCapabilities ( env,
+ capsObj, &glCaps );
+
+ if(JNI_TRUE!=ok)
+ {
+ fprintf(stderr,"GL4Java X11SunJDK13GLDrawableFactory ERROR: gl4java/GLCapabilities fields not accessible\n");
+ fflush(stderr);
+ return JNI_FALSE;
+ }
+
+ /* JAU: What the hell ..
+ The java given display is not alway functional .. ?
+
+ If running without this ugly thing,
+ the derived SimpleGLAnimApplet1 get's an X11 async reply
+ if the thing is initialized by the applet's init method !
+ */
+ disp = XOpenDisplay( NULL );
+ screen = DefaultScreen( disp );
+
+ if(JNI_TRUE==verbose)
+ fprintf(stdout," display=%p, screen=%d\n", disp, (int)screen);
+
+ while(!done && visual==NULL)
+ {
+ (void) setVisualAttribListByGLCapabilities( visualAttribList, &glCaps);
+
+ if(JNI_TRUE==verbose)
+ {
+ fprintf(stdout, "X11DrawableFactory.glXChooseVisual: try capabilities:\n");
+ printGLCapabilities ( &glCaps );
+ }
+
+ visual = glXChooseVisual( disp, screen, visualAttribList );
+
+ if(JNI_TRUE==verbose)
+ {
+ if(visual!=NULL)
+ {
+ fprintf(stdout, "X11DrawableFactory.glXChooseVisual: found visual(ID:%d(0x%X)):\n",
+ (int) visual->visualid,
+ (int) visual->visualid);
+ printVisualInfo ( disp, visual);
+ }
+ fflush(stdout);
+ }
+ /**
+ * Falling-Back the exact (min. requirement) parameters ..
+ */
+ if(visual==NULL && glCaps.stereo==STEREO_ON) {
+ glCaps.stereo=STEREO_OFF;
+ } else if(visual==NULL && glCaps.stencilBits>32) {
+ glCaps.stencilBits=32;
+ } else if(visual==NULL && glCaps.stencilBits>16) {
+ glCaps.stencilBits=16;
+ } else if(visual==NULL && glCaps.stencilBits>8) {
+ glCaps.stencilBits=8;
+ } else if(visual==NULL && glCaps.stencilBits>0) {
+ glCaps.stencilBits=0;
+ } else if(visual==NULL && glCaps.buffer==BUFFER_DOUBLE) {
+ glCaps.buffer=BUFFER_SINGLE;
+ } else done=1; /* forget it .. */
+ }
+
+ if(visual==NULL)
+ {
+ fprintf(stdout, "X11DrawableFactory.glXChooseVisual: no visual\n");
+ return 0;
+ }
+
+ (void ) setGLCapabilities ( disp, visual, &glCaps );
+
+ if(JNI_TRUE==verbose)
+ {
+ fprintf(stdout,"X11DrawableFactory.glXChooseVisual: writing capabilities to GLContext's java object\n");
+ fflush(stdout);
+ }
+
+ (void) nativeGLCapabilities2JavaGLCapabilities
+ (env, capsObj, &glCaps);
+
+ /* JAU: see above .. */
+ XCloseDisplay( disp );
+
+ return (jlong) (visual->visualid);
+}
+
|