From 13854a609700534fa2045c02b0b03d9d905f1e3a Mon Sep 17 00:00:00 2001 From: Billy Biggs Date: Fri, 23 Sep 2005 22:14:10 +0000 Subject: 37709 - Support OpenGL --- ....eclipse.swt.internal.opengl.gtk.GLX.properties | 115 ++++++++ .../internal/org.eclipse.swt.internal.properties | 3 +- bundles/org.eclipse.swt/.classpath_carbon | 2 + bundles/org.eclipse.swt/.classpath_gtk | 3 + bundles/org.eclipse.swt/.classpath_motif | 3 + bundles/org.eclipse.swt/.classpath_photon | 2 + bundles/org.eclipse.swt/.classpath_win32 | 2 + .../Eclipse SWT OpenGL/carbon/library/agl.c | 193 +++++++++++++ .../Eclipse SWT OpenGL/carbon/library/agl.h | 3 + .../Eclipse SWT OpenGL/carbon/library/agl_stats.c | 56 ++++ .../Eclipse SWT OpenGL/carbon/library/agl_stats.h | 38 +++ .../carbon/library/agl_structs.h | 13 + .../eclipse/swt/internal/opengl/carbon/AGL.java | 62 ++++ .../carbon/org/eclipse/swt/opengl/GLCanvas.java | 280 ++++++++++++++++++ .../common/org/eclipse/swt/opengl/GLData.java | 135 +++++++++ .../common/org/eclipse/swt/opengl/package.html | 15 + .../emulated/org/eclipse/swt/opengl/GLCanvas.java | 128 +++++++++ .../Eclipse SWT OpenGL/glx/library/glx.c | 314 +++++++++++++++++++++ .../Eclipse SWT OpenGL/glx/library/glx.h | 5 + .../Eclipse SWT OpenGL/glx/library/glx_stats.c | 65 +++++ .../Eclipse SWT OpenGL/glx/library/glx_stats.h | 47 +++ .../Eclipse SWT OpenGL/glx/library/glx_structs.c | 72 +++++ .../Eclipse SWT OpenGL/glx/library/glx_structs.h | 25 ++ .../org/eclipse/swt/internal/opengl/glx/GLX.java | 228 +++++++++++++++ .../swt/internal/opengl/glx/XVisualInfo.java | 23 ++ .../gtk/org/eclipse/swt/opengl/GLCanvas.java | 295 +++++++++++++++++++ .../motif/org/eclipse/swt/opengl/GLCanvas.java | 306 ++++++++++++++++++++ .../Eclipse SWT OpenGL/win32/library/build.bat | 34 +++ .../Eclipse SWT OpenGL/win32/library/glw.c | 283 +++++++++++++++++++ .../win32/library/make_win32.mak | 56 ++++ .../Eclipse SWT OpenGL/win32/library/structs.c | 304 ++++++++++++++++++++ .../Eclipse SWT OpenGL/win32/library/structs.h | 24 ++ .../Eclipse SWT OpenGL/win32/library/swt.rc | 67 +++++ .../opengl/win32/LAYERPLANEDESCRIPTOR.java | 40 +++ .../opengl/win32/PIXELFORMATDESCRIPTOR.java | 42 +++ .../org/eclipse/swt/internal/opengl/win32/WGL.java | 132 +++++++++ .../win32/org/eclipse/swt/opengl/GLCanvas.java | 211 ++++++++++++++ .../Eclipse SWT PI/gtk/library/make_linux.mak | 25 +- .../Eclipse SWT PI/motif/library/make_linux.mak | 23 +- .../Eclipse SWT PI/motif/library/os.c | 24 ++ .../Eclipse SWT PI/motif/library/os_stats.c | 6 +- .../Eclipse SWT PI/motif/library/os_stats.h | 2 + .../motif/org/eclipse/swt/internal/motif/OS.java | 21 ++ bundles/org.eclipse.swt/META-INF/MANIFEST.MF | 1 + 44 files changed, 3723 insertions(+), 5 deletions(-) create mode 100644 bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.opengl.gtk.GLX.properties create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.c create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.h create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.c create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.h create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_structs.h create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/internal/opengl/carbon/AGL.java create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/opengl/GLCanvas.java create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/GLData.java create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/package.html create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/emulated/org/eclipse/swt/opengl/GLCanvas.java create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.c create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.h create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.c create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.h create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.c create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.h create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/GLX.java create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/motif/org/eclipse/swt/opengl/GLCanvas.java create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/build.bat create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/glw.c create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/make_win32.mak create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.c create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.h create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/swt.rc create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/LAYERPLANEDESCRIPTOR.java create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/PIXELFORMATDESCRIPTOR.java create mode 100755 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/WGL.java create mode 100644 bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/opengl/GLCanvas.java (limited to 'bundles') diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.opengl.gtk.GLX.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.opengl.gtk.GLX.properties new file mode 100644 index 0000000000..b49b711046 --- /dev/null +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.opengl.gtk.GLX.properties @@ -0,0 +1,115 @@ +############################################################################### +# Copyright (c) 2000, 2005 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +org_eclipse_swt_internal_opengl_gtk_GLX= +GLX_glXChooseVisual= +GLX_glXChooseVisual_0= +GLX_glXChooseVisual_1= +GLX_glXChooseVisual_2= + +GLX_glXCopyContext= +GLX_glXCopyContext_0= +GLX_glXCopyContext_1= +GLX_glXCopyContext_2= +GLX_glXCopyContext_3= + +GLX_glXCreateContext= +GLX_glXCreateContext_0= +GLX_glXCreateContext_1= +GLX_glXCreateContext_2= +GLX_glXCreateContext_3= + +GLX_glXCreateGLXPixmap= +GLX_glXCreateGLXPixmap_0= +GLX_glXCreateGLXPixmap_1= +GLX_glXCreateGLXPixmap_2= + +GLX_glXDestroyContext= +GLX_glXDestroyContext_0= +GLX_glXDestroyContext_1= + +GLX_glXDestroyGLXPixmap= +GLX_glXDestroyGLXPixmap_0= +GLX_glXDestroyGLXPixmap_1= + +GLX_glXGetClientString= +GLX_glXGetClientString_0= +GLX_glXGetClientString_1= + +GLX_glXGetConfig= +GLX_glXGetConfig_0= +GLX_glXGetConfig_1= +GLX_glXGetConfig_2= +GLX_glXGetConfig_3= + +GLX_glXGetCurrentContext= + +GLX_glXGetCurrentDrawable= + +GLX_glXIsDirect= +GLX_glXIsDirect_0= +GLX_glXIsDirect_1= + +GLX_glXMakeCurrent= +GLX_glXMakeCurrent_0= +GLX_glXMakeCurrent_1= +GLX_glXMakeCurrent_2= + +GLX_glXQueryExtension= +GLX_glXQueryExtension_0= +GLX_glXQueryExtension_1= +GLX_glXQueryExtension_2= + +GLX_glXQueryExtensionsString= +GLX_glXQueryExtensionsString_0= +GLX_glXQueryExtensionsString_1= + +GLX_glXQueryServerString= +GLX_glXQueryServerString_0= +GLX_glXQueryServerString_1= +GLX_glXQueryServerString_2= + +GLX_glXQueryVersion= +GLX_glXQueryVersion_0= +GLX_glXQueryVersion_1= +GLX_glXQueryVersion_2= + +GLX_glXSwapBuffers= +GLX_glXSwapBuffers_0= +GLX_glXSwapBuffers_1= + +GLX_glXUseXFont= +GLX_glXUseXFont_0= +GLX_glXUseXFont_1= +GLX_glXUseXFont_2= +GLX_glXUseXFont_3= + +GLX_glXWaitGL= + +GLX_glXWaitX= + +GLX_memmove= +GLX_memmove_0= +GLX_memmove_1= +GLX_memmove_2= + + +org_eclipse_swt_internal_opengl_gtk_XVisualInfo= +XVisualInfo_visual= +XVisualInfo_visualid= +XVisualInfo_screen= +XVisualInfo_depth= +XVisualInfo_cclass= +XVisualInfo_red_mask= +XVisualInfo_green_mask= +XVisualInfo_blue_mask= +XVisualInfo_colormap_size= +XVisualInfo_bits_per_rgb= + diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties index 1d3849aca1..153315813b 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.properties @@ -41,4 +41,5 @@ org.eclipse.swt.internal.ole.win32.COM,../org.eclipse.swt/Eclipse SWT PI/win32/l org.eclipse.swt.internal.photon.OS,../org.eclipse.swt/Eclipse SWT PI/photon/library/,\ org.eclipse.swt.internal.win32.OS,../org.eclipse.swt/Eclipse SWT PI/win32/library/,\ org.eclipse.swt.internal.gdip.Gdip,../org.eclipse.swt/Eclipse SWT PI/win32/library/,\ -org.eclipse.swt.internal.cairo.Cairo,../org.eclipse.swt/Eclipse SWT PI/cairo/library/ +org.eclipse.swt.internal.cairo.Cairo,../org.eclipse.swt/Eclipse SWT PI/cairo/library/,\ +org.eclipse.swt.internal.opengl.glx.GLX,../org.eclipse.swt/Eclipse SWT OpenGL/glx/library/ diff --git a/bundles/org.eclipse.swt/.classpath_carbon b/bundles/org.eclipse.swt/.classpath_carbon index 5492fd97a7..1f02185001 100644 --- a/bundles/org.eclipse.swt/.classpath_carbon +++ b/bundles/org.eclipse.swt/.classpath_carbon @@ -26,5 +26,7 @@ + + diff --git a/bundles/org.eclipse.swt/.classpath_gtk b/bundles/org.eclipse.swt/.classpath_gtk index 31289ecd80..b12228c95d 100644 --- a/bundles/org.eclipse.swt/.classpath_gtk +++ b/bundles/org.eclipse.swt/.classpath_gtk @@ -32,5 +32,8 @@ + + + diff --git a/bundles/org.eclipse.swt/.classpath_motif b/bundles/org.eclipse.swt/.classpath_motif index 8e8bf666d8..97049a0451 100755 --- a/bundles/org.eclipse.swt/.classpath_motif +++ b/bundles/org.eclipse.swt/.classpath_motif @@ -35,5 +35,8 @@ + + + \ No newline at end of file diff --git a/bundles/org.eclipse.swt/.classpath_photon b/bundles/org.eclipse.swt/.classpath_photon index 236c7f57ce..53dcc7122d 100755 --- a/bundles/org.eclipse.swt/.classpath_photon +++ b/bundles/org.eclipse.swt/.classpath_photon @@ -29,5 +29,7 @@ + + diff --git a/bundles/org.eclipse.swt/.classpath_win32 b/bundles/org.eclipse.swt/.classpath_win32 index 39f6afb72b..a313d28d97 100755 --- a/bundles/org.eclipse.swt/.classpath_win32 +++ b/bundles/org.eclipse.swt/.classpath_win32 @@ -24,5 +24,7 @@ + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.c new file mode 100644 index 0000000000..6b612c0697 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.c @@ -0,0 +1,193 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "swt.h" +#include "agl_structs.h" +#include "agl_stats.h" + +#define AGL_NATIVE(func) Java_org_eclipse_swt_internal_opengl_carbon_AGL_##func + +#ifndef NO_aglChoosePixelFormat +JNIEXPORT jint JNICALL AGL_NATIVE(aglChoosePixelFormat) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc = 0; + AGL_NATIVE_ENTER(env, that, aglChoosePixelFormat_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + rc = (jint)aglChoosePixelFormat(arg0, arg1, lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + AGL_NATIVE_EXIT(env, that, aglChoosePixelFormat_FUNC); + return rc; +} +#endif + +#ifndef NO_aglCreateContext +JNIEXPORT jint JNICALL AGL_NATIVE(aglCreateContext) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jint rc = 0; + AGL_NATIVE_ENTER(env, that, aglCreateContext_FUNC); + rc = (jint)aglCreateContext(arg0, arg1); + AGL_NATIVE_EXIT(env, that, aglCreateContext_FUNC); + return rc; +} +#endif + +#ifndef NO_aglDescribePixelFormat +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglDescribePixelFormat) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglDescribePixelFormat_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + rc = (jboolean)aglDescribePixelFormat(arg0, arg1, lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + AGL_NATIVE_EXIT(env, that, aglDescribePixelFormat_FUNC); + return rc; +} +#endif + +#ifndef NO_aglDestroyContext +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglDestroyContext) + (JNIEnv *env, jclass that, jint arg0) +{ + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglDestroyContext_FUNC); + rc = (jboolean)aglDestroyContext(arg0); + AGL_NATIVE_EXIT(env, that, aglDestroyContext_FUNC); + return rc; +} +#endif + +#ifndef NO_aglDestroyPixelFormat +JNIEXPORT void JNICALL AGL_NATIVE(aglDestroyPixelFormat) + (JNIEnv *env, jclass that, jint arg0) +{ + AGL_NATIVE_ENTER(env, that, aglDestroyPixelFormat_FUNC); + aglDestroyPixelFormat(arg0); + AGL_NATIVE_EXIT(env, that, aglDestroyPixelFormat_FUNC); +} +#endif + +#ifndef NO_aglEnable +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglEnable) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglEnable_FUNC); + rc = (jboolean)aglEnable(arg0, arg1); + AGL_NATIVE_EXIT(env, that, aglEnable_FUNC); + return rc; +} +#endif + +#ifndef NO_aglGetCurrentContext +JNIEXPORT jint JNICALL AGL_NATIVE(aglGetCurrentContext) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + AGL_NATIVE_ENTER(env, that, aglGetCurrentContext_FUNC); + rc = (jint)aglGetCurrentContext(); + AGL_NATIVE_EXIT(env, that, aglGetCurrentContext_FUNC); + return rc; +} +#endif + +#ifndef NO_aglGetDrawable +JNIEXPORT jint JNICALL AGL_NATIVE(aglGetDrawable) + (JNIEnv *env, jclass that, jint arg0) +{ + jint rc = 0; + AGL_NATIVE_ENTER(env, that, aglGetDrawable_FUNC); + rc = (jint)aglGetDrawable(arg0); + AGL_NATIVE_EXIT(env, that, aglGetDrawable_FUNC); + return rc; +} +#endif + +#ifndef NO_aglSetCurrentContext +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglSetCurrentContext) + (JNIEnv *env, jclass that, jint arg0) +{ + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglSetCurrentContext_FUNC); + rc = (jboolean)aglSetCurrentContext(arg0); + AGL_NATIVE_EXIT(env, that, aglSetCurrentContext_FUNC); + return rc; +} +#endif + +#ifndef NO_aglSetDrawable +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglSetDrawable) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglSetDrawable_FUNC); + rc = (jboolean)aglSetDrawable(arg0, arg1); + AGL_NATIVE_EXIT(env, that, aglSetDrawable_FUNC); + return rc; +} +#endif + +#ifndef NO_aglSetInteger__III +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglSetInteger__III) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglSetInteger__III_FUNC); + rc = (jboolean)aglSetInteger(arg0, arg1, arg2); + AGL_NATIVE_EXIT(env, that, aglSetInteger__III_FUNC); + return rc; +} +#endif + +#ifndef NO_aglSetInteger__II_3I +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglSetInteger__II_3I) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglSetInteger__II_3I_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + rc = (jboolean)aglSetInteger(arg0, arg1, lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + AGL_NATIVE_EXIT(env, that, aglSetInteger__II_3I_FUNC); + return rc; +} +#endif + +#ifndef NO_aglSwapBuffers +JNIEXPORT void JNICALL AGL_NATIVE(aglSwapBuffers) + (JNIEnv *env, jclass that, jint arg0) +{ + AGL_NATIVE_ENTER(env, that, aglSwapBuffers_FUNC); + aglSwapBuffers(arg0); + AGL_NATIVE_EXIT(env, that, aglSwapBuffers_FUNC); +} +#endif + +#ifndef NO_aglUpdateContext +JNIEXPORT jboolean JNICALL AGL_NATIVE(aglUpdateContext) + (JNIEnv *env, jclass that, jint arg0) +{ + jboolean rc = 0; + AGL_NATIVE_ENTER(env, that, aglUpdateContext_FUNC); + rc = (jboolean)aglUpdateContext(arg0); + AGL_NATIVE_EXIT(env, that, aglUpdateContext_FUNC); + return rc; +} +#endif + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.h new file mode 100644 index 0000000000..9a87d429a7 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl.h @@ -0,0 +1,3 @@ + +#include + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.c new file mode 100644 index 0000000000..c1f016799f --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.c @@ -0,0 +1,56 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "swt.h" +#include "agl_stats.h" + +#ifdef NATIVE_STATS + +int AGL_nativeFunctionCount = 14; +int AGL_nativeFunctionCallCount[14]; +char * AGL_nativeFunctionNames[] = { + "aglChoosePixelFormat", + "aglCreateContext", + "aglDescribePixelFormat", + "aglDestroyContext", + "aglDestroyPixelFormat", + "aglEnable", + "aglGetCurrentContext", + "aglGetDrawable", + "aglSetCurrentContext", + "aglSetDrawable", + "aglSetInteger__III", + "aglSetInteger__II_3I", + "aglSwapBuffers", + "aglUpdateContext", +}; + +#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func + +JNIEXPORT jint JNICALL STATS_NATIVE(AGL_1GetFunctionCount) + (JNIEnv *env, jclass that) +{ + return AGL_nativeFunctionCount; +} + +JNIEXPORT jstring JNICALL STATS_NATIVE(AGL_1GetFunctionName) + (JNIEnv *env, jclass that, jint index) +{ + return (*env)->NewStringUTF(env, AGL_nativeFunctionNames[index]); +} + +JNIEXPORT jint JNICALL STATS_NATIVE(AGL_1GetFunctionCallCount) + (JNIEnv *env, jclass that, jint index) +{ + return AGL_nativeFunctionCallCount[index]; +} + +#endif diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.h new file mode 100644 index 0000000000..fc359aff5c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_stats.h @@ -0,0 +1,38 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#ifdef NATIVE_STATS +extern int AGL_nativeFunctionCount; +extern int AGL_nativeFunctionCallCount[]; +extern char* AGL_nativeFunctionNames[]; +#define AGL_NATIVE_ENTER(env, that, func) AGL_nativeFunctionCallCount[func]++; +#define AGL_NATIVE_EXIT(env, that, func) +#else +#define AGL_NATIVE_ENTER(env, that, func) +#define AGL_NATIVE_EXIT(env, that, func) +#endif + +typedef enum { + aglChoosePixelFormat_FUNC, + aglCreateContext_FUNC, + aglDescribePixelFormat_FUNC, + aglDestroyContext_FUNC, + aglDestroyPixelFormat_FUNC, + aglEnable_FUNC, + aglGetCurrentContext_FUNC, + aglGetDrawable_FUNC, + aglSetCurrentContext_FUNC, + aglSetDrawable_FUNC, + aglSetInteger__III_FUNC, + aglSetInteger__II_3I_FUNC, + aglSwapBuffers_FUNC, + aglUpdateContext_FUNC, +} AGL_FUNCS; diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_structs.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_structs.h new file mode 100644 index 0000000000..36531f5373 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/library/agl_structs.h @@ -0,0 +1,13 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "agl.h" + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/internal/opengl/carbon/AGL.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/internal/opengl/carbon/AGL.java new file mode 100644 index 0000000000..0435858b62 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/internal/opengl/carbon/AGL.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.internal.opengl.carbon; + +import org.eclipse.swt.internal.Library; + +public class AGL { + static { + Library.loadLibrary("swt-agl"); + } + + /* Attributes */ + public static final int AGL_NONE = 0; + public static final int AGL_BUFFER_SIZE = 2; + public static final int AGL_LEVEL = 3; + public static final int AGL_RGBA = 4; + public static final int AGL_DOUBLEBUFFER = 5; + public static final int AGL_STEREO = 6; + public static final int AGL_AUX_BUFFERS = 7; + public static final int AGL_RED_SIZE = 8; + public static final int AGL_GREEN_SIZE = 9; + public static final int AGL_BLUE_SIZE = 10; + public static final int AGL_ALPHA_SIZE = 11; + public static final int AGL_DEPTH_SIZE = 12; + public static final int AGL_STENCIL_SIZE = 13; + public static final int AGL_ACCUM_RED_SIZE = 14; + public static final int AGL_ACCUM_GREEN_SIZE = 15; + public static final int AGL_ACCUM_BLUE_SIZE = 16; + public static final int AGL_ACCUM_ALPHA_SIZE = 17; + + public static final int AGL_SAMPLE_BUFFERS_ARB = 55; + public static final int AGL_SAMPLES_ARB = 56; + + /* Integer parameters */ + public static final int AGL_BUFFER_RECT = 202; + public static final int AGL_SWAP_INTERVAL = 222; + public static final int AGL_BUFFER_NAME = 231; + public static final int AGL_CLIP_REGION = 254; + +public static final native int aglChoosePixelFormat(int gdevs, int ndev, int[] attribs); +public static final native int aglCreateContext(int pix, int share); +public static final native boolean aglDescribePixelFormat(int pix, int attrib, int[] value); +public static final native boolean aglDestroyContext(int ctx); +public static final native void aglDestroyPixelFormat(int pix); +public static final native boolean aglEnable(int ctx, int pname); +public static final native int aglGetCurrentContext(); +public static final native int aglGetDrawable(int ctx); +public static final native boolean aglSetCurrentContext(int ctx); +public static final native boolean aglSetDrawable(int ctx, int draw); +public static final native boolean aglSetInteger(int ctx, int pname, int[] params); +public static final native boolean aglSetInteger(int ctx, int pname, int param); +public static final native void aglSwapBuffers(int ctx); +public static final native boolean aglUpdateContext(int ctx); +} \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/opengl/GLCanvas.java new file mode 100755 index 0000000000..eb4edff1d9 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/carbon/org/eclipse/swt/opengl/GLCanvas.java @@ -0,0 +1,280 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl; + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.opengl.carbon.*; + +/** + * GLCanvas is a widget capable of displaying OpenGL content. + * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ + +public class GLCanvas extends Canvas { + int context; + int pixelFormat; + static final int MAX_ATTRIBUTES = 32; + +/** + * Create a GLCanvas widget using the attributes described in the GLData + * object provided. + * + * @param parent a composite widget + * @param style the bitwise OR'ing of widget styles + * @param data the requested attributes of the GLCanvas + * + * @exception IllegalArgumentException + *
  • ERROR_NULL_ARGUMENT when the data is null + *
  • ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
+ * @exception SWTException + *
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + *
  • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + *
  • ERROR_CANNOT_OPEN_FILE when failed to open file + *
  • ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces + *
  • ERROR_INVALID_CLASSID + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLCanvas (Composite parent, int style, GLData data) { + super (parent, style); + if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int aglAttrib [] = new int [MAX_ATTRIBUTES]; + int pos = 0; + aglAttrib [pos++] = AGL.AGL_RGBA; + if (data.doubleBuffer) aglAttrib [pos++] = AGL.AGL_DOUBLEBUFFER; + if (data.stereo) aglAttrib [pos++] = AGL.AGL_STEREO; + if (data.redSize > 0) { + aglAttrib [pos++] = AGL.AGL_RED_SIZE; + aglAttrib [pos++] = data.redSize; + } + if (data.greenSize > 0) { + aglAttrib [pos++] = AGL.AGL_GREEN_SIZE; + aglAttrib [pos++] = data.greenSize; + } + if (data.blueSize > 0) { + aglAttrib [pos++] = AGL.AGL_BLUE_SIZE; + aglAttrib [pos++] = data.blueSize; + } + if (data.alphaSize > 0) { + aglAttrib [pos++] = AGL.AGL_ALPHA_SIZE; + aglAttrib [pos++] = data.alphaSize; + } + if (data.depthSize > 0) { + aglAttrib [pos++] = AGL.AGL_DEPTH_SIZE; + aglAttrib [pos++] = data.depthSize; + } + if (data.stencilSize > 0) { + aglAttrib [pos++] = AGL.AGL_STENCIL_SIZE; + aglAttrib [pos++] = data.stencilSize; + } + if (data.accumRedSize > 0) { + aglAttrib [pos++] = AGL.AGL_ACCUM_RED_SIZE; + aglAttrib [pos++] = data.accumRedSize; + } + if (data.accumGreenSize > 0) { + aglAttrib [pos++] = AGL.AGL_ACCUM_GREEN_SIZE; + aglAttrib [pos++] = data.accumGreenSize; + } + if (data.accumBlueSize > 0) { + aglAttrib [pos++] = AGL.AGL_ACCUM_BLUE_SIZE; + aglAttrib [pos++] = data.accumBlueSize; + } + if (data.accumAlphaSize > 0) { + aglAttrib [pos++] = AGL.AGL_ACCUM_ALPHA_SIZE; + aglAttrib [pos++] = data.accumAlphaSize; + } + if (data.sampleBuffers > 0) { + aglAttrib [pos++] = AGL.AGL_SAMPLE_BUFFERS_ARB; + aglAttrib [pos++] = data.sampleBuffers; + } + if (data.samples > 0) { + aglAttrib [pos++] = AGL.AGL_SAMPLES_ARB; + aglAttrib [pos++] = data.samples; + } + aglAttrib [pos++] = AGL.AGL_NONE; + pixelFormat = AGL.aglChoosePixelFormat (0, 0, aglAttrib); + //FIXME- share lists + //context = AGL.aglCreateContext (pixelFormat, share == null ? 0 : share.context); + context = AGL.aglCreateContext (pixelFormat, 0); + int window = OS.GetControlOwner (handle); + int port = OS.GetWindowPort (window); + AGL.aglSetDrawable (context, port); + + Listener listener = new Listener () { + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Dispose: + AGL.aglDestroyContext (context); + AGL.aglDestroyPixelFormat (pixelFormat); + break; + case SWT.Resize: + case SWT.Hide: + case SWT.Show: + getDisplay().asyncExec(new Runnable() { + public void run() { + fixBounds(); + } + }); + break; + } + } + }; + addListener (SWT.Resize, listener); + Shell shell = getShell(); + shell.addListener(SWT.Resize, listener); + shell.addListener(SWT.Show, listener); + shell.addListener(SWT.Hide, listener); + Control c = this; + do { + c.addListener(SWT.Show, listener); + c.addListener(SWT.Hide, listener); + c = c.getParent(); + } while (c != shell); + addListener (SWT.Dispose, listener); +} + +void fixBounds () { + GCData data = new GCData (); + int gc = internal_new_GC (data); + Rect bounds = new Rect (); + OS.GetRegionBounds (data.visibleRgn, bounds); + int width = bounds.right - bounds.left; + int height = bounds.bottom - bounds.top; + Rect rect = new Rect (); + int window = OS.GetControlOwner (handle); + int port = OS.GetWindowPort (window); + OS.GetPortBounds (port, rect); + int [] glbounds = new int [4]; + glbounds[0] = bounds.left; + glbounds[1] = rect.bottom - rect.top - bounds.top - height; + glbounds[2] = width; + glbounds[3] = height; + AGL.aglSetInteger (context, AGL.AGL_BUFFER_RECT, glbounds); + AGL.aglEnable (context, AGL.AGL_BUFFER_RECT); + AGL.aglSetInteger (context, AGL.AGL_CLIP_REGION, data.visibleRgn); + AGL.aglUpdateContext (context); + internal_dispose_GC (gc, data); +} + +/** + * Returns a GLData object describing the created context. + * + * @return GLData description of the OpenGL context attributes + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLData getGLData () { + checkWidget (); + GLData data = new GLData (); + int [] value = new int [1]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_DOUBLEBUFFER, value); + data.doubleBuffer = value [0] != 0; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_STEREO, value); + data.stereo = value [0] != 0; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_RED_SIZE, value); + data.redSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_GREEN_SIZE, value); + data.greenSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_BLUE_SIZE, value); + data.blueSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ALPHA_SIZE, value); + data.alphaSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_DEPTH_SIZE, value); + data.depthSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_STENCIL_SIZE, value); + data.stencilSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_RED_SIZE, value); + data.accumRedSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_GREEN_SIZE, value); + data.accumGreenSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_BLUE_SIZE, value); + data.accumBlueSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_ACCUM_ALPHA_SIZE, value); + data.accumAlphaSize = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_SAMPLE_BUFFERS_ARB, value); + data.sampleBuffers = value [0]; + AGL.aglDescribePixelFormat (pixelFormat, AGL.AGL_SAMPLES_ARB, value); + data.samples = value [0]; + return data; +} + +/** + * Returns a boolean indicating whether the receiver's OpenGL context + * is the current context. + * + * @return true if the receiver holds the current OpenGL context, + * false otherwise + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public boolean isCurrent () { + checkWidget (); + return AGL.aglGetCurrentContext () == context; +} + +/** + * Sets the OpenGL context associated with this GLCanvas to be the + * current GL context. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void setCurrent () { + checkWidget (); + if (AGL.aglGetCurrentContext () != context) { + AGL.aglSetCurrentContext (context); + } +} + +/** + * Swaps the front and back color buffers. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void swapBuffers () { + checkWidget (); + AGL.aglSwapBuffers (context); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/GLData.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/GLData.java new file mode 100644 index 0000000000..f25f11d156 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/GLData.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl; + +/** + * The GLData class is a device-independent description + * of the pixel format attributes of a GL drawable. + * + * @see GLCanvas + */ + +public class GLData { + /** + * Specifies a double-buffered surface. During context + * creation, only double-buffered formats are considered + * when set to true. + */ + public boolean doubleBuffer; + + /** + * Specifies a stereo surface. During context creation, + * only stereo formats are considered when set to true. + */ + public boolean stereo; + + /** + * The size in bits of the color buffer's red channel. + * During context creation, this specifies the minimum + * required red bits. + */ + public int redSize; + + /** + * The size in bits of the color buffer's green channel. + * During context creation, this specifies the minimum + * required green bits. + */ + public int greenSize; + + /** + * The size in bits of the color buffer's blue channel. + * During context creation, this specifies the minimum + * required blue bits. + */ + public int blueSize; + + /** + * The size in bits of the color buffer's alpha channel. + * During context creation, this specifies the minimum + * required alpha bits. + */ + public int alphaSize; + + /** + * The size in bits of the depth buffer. During context + * creation, the smallest depth buffer of at least the + * specified value is preferred, or zero for no depth + * buffer. + */ + public int depthSize; + + /** + * The desired number of stencil bitplanes. During + * context creation, the smallest stencil buffer of at + * least the specified value is preferred, or zero for + * no stencil buffer. + */ + public int stencilSize; + + /** + * The size in bits of the accumulation buffer's red + * channel. During context creation, this specifies the + * minimum required red bits. + */ + public int accumRedSize; + + /** + * The size in bits of the accumulation buffer's green + * channel. During context creation, this specifies the + * minimum required green bits. + */ + public int accumGreenSize; + + /** + * The size in bits of the accumulation buffer's blue + * channel. During context creation, this specifies the + * minimum required blue bits. + */ + public int accumBlueSize; + + /** + * The size in bits of the accumulation buffer's alpha + * channel. During context creation, this specifies the + * minimum required alpha bits. + */ + public int accumAlphaSize; + + /** + * The number of multisample buffers used by this context. + * During context creation, this specifies the minimum + * number of multisample buffers requested. + */ + public int sampleBuffers; + + /** + * The number of samples accepted in the multisample buffer. + * During creation, pixel formats with the smallest number of + * samples that meets or exceeds the specified minimum number + * are preferred. + */ + public int samples; + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the data + */ +public String toString() { + return (doubleBuffer ? "doubleBuffer," : "") + + (stereo ? "stereo," : "") + + "r:" + redSize + " g:" + greenSize + " b:" + blueSize + " a:" + alphaSize + "," + + "depth:" + depthSize + ",stencil:" + stencilSize + + ",accum r:" + accumRedSize + "g:" + accumGreenSize + "b:" + accumBlueSize + "a:" + accumAlphaSize + + ",sampleBuffers:" + sampleBuffers + ",samples:" + samples; +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/package.html b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/package.html new file mode 100755 index 0000000000..3ad94aefab --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/common/org/eclipse/swt/opengl/package.html @@ -0,0 +1,15 @@ + + + + + + Package-level Javadoc + + +SWT OpenGL support. +

+Package Specification

+This package contains widgets for integrating OpenGL graphics +into SWT applications. + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/emulated/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/emulated/org/eclipse/swt/opengl/GLCanvas.java new file mode 100644 index 0000000000..3cf09bf186 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/emulated/org/eclipse/swt/opengl/GLCanvas.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl; + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; + +/** + * GLCanvas is a widget capable of displaying OpenGL content. + * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ + +public class GLCanvas extends Canvas { + +/** + * Create a GLCanvas widget using the attributes described in the GLData + * object provided. + * + * @param parent a composite widget + * @param style the bitwise OR'ing of widget styles + * @param data the requested attributes of the GLCanvas + * + * @exception IllegalArgumentException + *
  • ERROR_NULL_ARGUMENT when the data is null + *
  • ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
+ * @exception SWTException + *
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + *
  • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + *
  • ERROR_CANNOT_OPEN_FILE when failed to open file + *
  • ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces + *
  • ERROR_INVALID_CLASSID + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLCanvas (Composite parent, int style, GLData data) { + super (parent, style); + SWT.error (SWT.ERROR_NOT_IMPLEMENTED); +} + +/** + * Returns a GLData object describing the created context. + * + * @return GLData description of the OpenGL context attributes + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLData getGLData () { + checkWidget (); + SWT.error (SWT.ERROR_NOT_IMPLEMENTED); + return null; +} + +/** + * Returns a boolean indicating whether the receiver's OpenGL context + * is the current context. + * + * @return true if the receiver holds the current OpenGL context, + * false otherwise + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public boolean isCurrent () { + checkWidget (); + SWT.error (SWT.ERROR_NOT_IMPLEMENTED); + return false; +} + +/** + * Sets the OpenGL context associated with this GLCanvas to be the + * current GL context. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void setCurrent () { + checkWidget (); + SWT.error (SWT.ERROR_NOT_IMPLEMENTED); +} + +/** + * Swaps the front and back color buffers. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void swapBuffers () { + checkWidget (); + SWT.error (SWT.ERROR_NOT_IMPLEMENTED); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.c new file mode 100644 index 0000000000..7a2f1bf4cc --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.c @@ -0,0 +1,314 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "swt.h" +#include "glx_structs.h" +#include "glx_stats.h" + +#define GLX_NATIVE(func) Java_org_eclipse_swt_internal_opengl_glx_GLX_##func + +#ifndef NO_glGetIntegerv +JNIEXPORT void JNICALL GLX_NATIVE(glGetIntegerv) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + GLX_NATIVE_ENTER(env, that, glGetIntegerv_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; + glGetIntegerv(arg0, lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + GLX_NATIVE_EXIT(env, that, glGetIntegerv_FUNC); +} +#endif + +#ifndef NO_glViewport +JNIEXPORT void JNICALL GLX_NATIVE(glViewport) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + GLX_NATIVE_ENTER(env, that, glViewport_FUNC); + glViewport(arg0, arg1, arg2, arg3); + GLX_NATIVE_EXIT(env, that, glViewport_FUNC); +} +#endif + +#ifndef NO_glXChooseVisual +JNIEXPORT jint JNICALL GLX_NATIVE(glXChooseVisual) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXChooseVisual_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + rc = (jint)glXChooseVisual(arg0, arg1, lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + GLX_NATIVE_EXIT(env, that, glXChooseVisual_FUNC); + return rc; +} +#endif + +#ifndef NO_glXCopyContext +JNIEXPORT void JNICALL GLX_NATIVE(glXCopyContext) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + GLX_NATIVE_ENTER(env, that, glXCopyContext_FUNC); + glXCopyContext(arg0, arg1, arg2, arg3); + GLX_NATIVE_EXIT(env, that, glXCopyContext_FUNC); +} +#endif + +#ifndef NO_glXCreateContext +JNIEXPORT jint JNICALL GLX_NATIVE(glXCreateContext) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jboolean arg3) +{ + XVisualInfo _arg1, *lparg1=NULL; + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXCreateContext_FUNC); + if (arg1) if ((lparg1 = getXVisualInfoFields(env, arg1, &_arg1)) == NULL) goto fail; + rc = (jint)glXCreateContext(arg0, lparg1, arg2, arg3); +fail: + if (arg1 && lparg1) setXVisualInfoFields(env, arg1, lparg1); + GLX_NATIVE_EXIT(env, that, glXCreateContext_FUNC); + return rc; +} +#endif + +#ifndef NO_glXCreateGLXPixmap +JNIEXPORT jint JNICALL GLX_NATIVE(glXCreateGLXPixmap) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + XVisualInfo _arg1, *lparg1=NULL; + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXCreateGLXPixmap_FUNC); + if (arg1) if ((lparg1 = getXVisualInfoFields(env, arg1, &_arg1)) == NULL) goto fail; + rc = (jint)glXCreateGLXPixmap(arg0, lparg1, arg2); +fail: + if (arg1 && lparg1) setXVisualInfoFields(env, arg1, lparg1); + GLX_NATIVE_EXIT(env, that, glXCreateGLXPixmap_FUNC); + return rc; +} +#endif + +#ifndef NO_glXDestroyContext +JNIEXPORT void JNICALL GLX_NATIVE(glXDestroyContext) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + GLX_NATIVE_ENTER(env, that, glXDestroyContext_FUNC); + glXDestroyContext(arg0, arg1); + GLX_NATIVE_EXIT(env, that, glXDestroyContext_FUNC); +} +#endif + +#ifndef NO_glXDestroyGLXPixmap +JNIEXPORT void JNICALL GLX_NATIVE(glXDestroyGLXPixmap) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + GLX_NATIVE_ENTER(env, that, glXDestroyGLXPixmap_FUNC); + glXDestroyGLXPixmap(arg0, arg1); + GLX_NATIVE_EXIT(env, that, glXDestroyGLXPixmap_FUNC); +} +#endif + +#ifndef NO_glXGetClientString +JNIEXPORT jint JNICALL GLX_NATIVE(glXGetClientString) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXGetClientString_FUNC); + rc = (jint)glXGetClientString(arg0, arg1); + GLX_NATIVE_EXIT(env, that, glXGetClientString_FUNC); + return rc; +} +#endif + +#ifndef NO_glXGetConfig +JNIEXPORT jint JNICALL GLX_NATIVE(glXGetConfig) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jintArray arg3) +{ + XVisualInfo _arg1, *lparg1=NULL; + jint *lparg3=NULL; + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXGetConfig_FUNC); + if (arg1) if ((lparg1 = getXVisualInfoFields(env, arg1, &_arg1)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail; + rc = (jint)glXGetConfig(arg0, lparg1, arg2, lparg3); +fail: + if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg1 && lparg1) setXVisualInfoFields(env, arg1, lparg1); + GLX_NATIVE_EXIT(env, that, glXGetConfig_FUNC); + return rc; +} +#endif + +#ifndef NO_glXGetCurrentContext +JNIEXPORT jint JNICALL GLX_NATIVE(glXGetCurrentContext) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXGetCurrentContext_FUNC); + rc = (jint)glXGetCurrentContext(); + GLX_NATIVE_EXIT(env, that, glXGetCurrentContext_FUNC); + return rc; +} +#endif + +#ifndef NO_glXGetCurrentDrawable +JNIEXPORT jint JNICALL GLX_NATIVE(glXGetCurrentDrawable) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXGetCurrentDrawable_FUNC); + rc = (jint)glXGetCurrentDrawable(); + GLX_NATIVE_EXIT(env, that, glXGetCurrentDrawable_FUNC); + return rc; +} +#endif + +#ifndef NO_glXIsDirect +JNIEXPORT jboolean JNICALL GLX_NATIVE(glXIsDirect) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jboolean rc = 0; + GLX_NATIVE_ENTER(env, that, glXIsDirect_FUNC); + rc = (jboolean)glXIsDirect(arg0, arg1); + GLX_NATIVE_EXIT(env, that, glXIsDirect_FUNC); + return rc; +} +#endif + +#ifndef NO_glXMakeCurrent +JNIEXPORT jboolean JNICALL GLX_NATIVE(glXMakeCurrent) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + jboolean rc = 0; + GLX_NATIVE_ENTER(env, that, glXMakeCurrent_FUNC); + rc = (jboolean)glXMakeCurrent(arg0, arg1, arg2); + GLX_NATIVE_EXIT(env, that, glXMakeCurrent_FUNC); + return rc; +} +#endif + +#ifndef NO_glXQueryExtension +JNIEXPORT jboolean JNICALL GLX_NATIVE(glXQueryExtension) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jboolean rc = 0; + GLX_NATIVE_ENTER(env, that, glXQueryExtension_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + rc = (jboolean)glXQueryExtension(arg0, lparg1, lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + GLX_NATIVE_EXIT(env, that, glXQueryExtension_FUNC); + return rc; +} +#endif + +#ifndef NO_glXQueryExtensionsString +JNIEXPORT jint JNICALL GLX_NATIVE(glXQueryExtensionsString) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXQueryExtensionsString_FUNC); + rc = (jint)glXQueryExtensionsString(arg0, arg1); + GLX_NATIVE_EXIT(env, that, glXQueryExtensionsString_FUNC); + return rc; +} +#endif + +#ifndef NO_glXQueryServerString +JNIEXPORT jint JNICALL GLX_NATIVE(glXQueryServerString) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + jint rc = 0; + GLX_NATIVE_ENTER(env, that, glXQueryServerString_FUNC); + rc = (jint)glXQueryServerString(arg0, arg1, arg2); + GLX_NATIVE_EXIT(env, that, glXQueryServerString_FUNC); + return rc; +} +#endif + +#ifndef NO_glXQueryVersion +JNIEXPORT jboolean JNICALL GLX_NATIVE(glXQueryVersion) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jboolean rc = 0; + GLX_NATIVE_ENTER(env, that, glXQueryVersion_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + rc = (jboolean)glXQueryVersion(arg0, lparg1, lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + GLX_NATIVE_EXIT(env, that, glXQueryVersion_FUNC); + return rc; +} +#endif + +#ifndef NO_glXSwapBuffers +JNIEXPORT void JNICALL GLX_NATIVE(glXSwapBuffers) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + GLX_NATIVE_ENTER(env, that, glXSwapBuffers_FUNC); + glXSwapBuffers(arg0, arg1); + GLX_NATIVE_EXIT(env, that, glXSwapBuffers_FUNC); +} +#endif + +#ifndef NO_glXUseXFont +JNIEXPORT void JNICALL GLX_NATIVE(glXUseXFont) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + GLX_NATIVE_ENTER(env, that, glXUseXFont_FUNC); + glXUseXFont(arg0, arg1, arg2, arg3); + GLX_NATIVE_EXIT(env, that, glXUseXFont_FUNC); +} +#endif + +#ifndef NO_glXWaitGL +JNIEXPORT void JNICALL GLX_NATIVE(glXWaitGL) + (JNIEnv *env, jclass that) +{ + GLX_NATIVE_ENTER(env, that, glXWaitGL_FUNC); + glXWaitGL(); + GLX_NATIVE_EXIT(env, that, glXWaitGL_FUNC); +} +#endif + +#ifndef NO_glXWaitX +JNIEXPORT void JNICALL GLX_NATIVE(glXWaitX) + (JNIEnv *env, jclass that) +{ + GLX_NATIVE_ENTER(env, that, glXWaitX_FUNC); + glXWaitX(); + GLX_NATIVE_EXIT(env, that, glXWaitX_FUNC); +} +#endif + +#ifndef NO_memmove +JNIEXPORT void JNICALL GLX_NATIVE(memmove) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + XVisualInfo _arg0, *lparg0=NULL; + GLX_NATIVE_ENTER(env, that, memmove_FUNC); + if (arg0) if ((lparg0 = getXVisualInfoFields(env, arg0, &_arg0)) == NULL) goto fail; + memmove(lparg0, arg1, arg2); +fail: + if (arg0 && lparg0) setXVisualInfoFields(env, arg0, lparg0); + GLX_NATIVE_EXIT(env, that, memmove_FUNC); +} +#endif + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.h new file mode 100644 index 0000000000..ad4b6fe486 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx.h @@ -0,0 +1,5 @@ + +#include +#include + +#define cclass class diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.c new file mode 100644 index 0000000000..5665208ab2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.c @@ -0,0 +1,65 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "swt.h" +#include "glx_stats.h" + +#ifdef NATIVE_STATS + +int GLX_nativeFunctionCount = 23; +int GLX_nativeFunctionCallCount[23]; +char * GLX_nativeFunctionNames[] = { + "glGetIntegerv", + "glViewport", + "glXChooseVisual", + "glXCopyContext", + "glXCreateContext", + "glXCreateGLXPixmap", + "glXDestroyContext", + "glXDestroyGLXPixmap", + "glXGetClientString", + "glXGetConfig", + "glXGetCurrentContext", + "glXGetCurrentDrawable", + "glXIsDirect", + "glXMakeCurrent", + "glXQueryExtension", + "glXQueryExtensionsString", + "glXQueryServerString", + "glXQueryVersion", + "glXSwapBuffers", + "glXUseXFont", + "glXWaitGL", + "glXWaitX", + "memmove", +}; + +#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func + +JNIEXPORT jint JNICALL STATS_NATIVE(GLX_1GetFunctionCount) + (JNIEnv *env, jclass that) +{ + return GLX_nativeFunctionCount; +} + +JNIEXPORT jstring JNICALL STATS_NATIVE(GLX_1GetFunctionName) + (JNIEnv *env, jclass that, jint index) +{ + return (*env)->NewStringUTF(env, GLX_nativeFunctionNames[index]); +} + +JNIEXPORT jint JNICALL STATS_NATIVE(GLX_1GetFunctionCallCount) + (JNIEnv *env, jclass that, jint index) +{ + return GLX_nativeFunctionCallCount[index]; +} + +#endif diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.h new file mode 100644 index 0000000000..ceb72af874 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_stats.h @@ -0,0 +1,47 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#ifdef NATIVE_STATS +extern int GLX_nativeFunctionCount; +extern int GLX_nativeFunctionCallCount[]; +extern char* GLX_nativeFunctionNames[]; +#define GLX_NATIVE_ENTER(env, that, func) GLX_nativeFunctionCallCount[func]++; +#define GLX_NATIVE_EXIT(env, that, func) +#else +#define GLX_NATIVE_ENTER(env, that, func) +#define GLX_NATIVE_EXIT(env, that, func) +#endif + +typedef enum { + glGetIntegerv_FUNC, + glViewport_FUNC, + glXChooseVisual_FUNC, + glXCopyContext_FUNC, + glXCreateContext_FUNC, + glXCreateGLXPixmap_FUNC, + glXDestroyContext_FUNC, + glXDestroyGLXPixmap_FUNC, + glXGetClientString_FUNC, + glXGetConfig_FUNC, + glXGetCurrentContext_FUNC, + glXGetCurrentDrawable_FUNC, + glXIsDirect_FUNC, + glXMakeCurrent_FUNC, + glXQueryExtension_FUNC, + glXQueryExtensionsString_FUNC, + glXQueryServerString_FUNC, + glXQueryVersion_FUNC, + glXSwapBuffers_FUNC, + glXUseXFont_FUNC, + glXWaitGL_FUNC, + glXWaitX_FUNC, + memmove_FUNC, +} GLX_FUNCS; diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.c new file mode 100644 index 0000000000..b873c1dfa8 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.c @@ -0,0 +1,72 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "swt.h" +#include "glx_structs.h" + +#ifndef NO_XVisualInfo +typedef struct XVisualInfo_FID_CACHE { + int cached; + jclass clazz; + jfieldID visual, visualid, screen, depth, cclass, red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb; +} XVisualInfo_FID_CACHE; + +XVisualInfo_FID_CACHE XVisualInfoFc; + +void cacheXVisualInfoFields(JNIEnv *env, jobject lpObject) +{ + if (XVisualInfoFc.cached) return; + XVisualInfoFc.clazz = (*env)->GetObjectClass(env, lpObject); + XVisualInfoFc.visual = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "visual", "I"); + XVisualInfoFc.visualid = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "visualid", "I"); + XVisualInfoFc.screen = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "screen", "I"); + XVisualInfoFc.depth = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "depth", "I"); + XVisualInfoFc.cclass = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "cclass", "I"); + XVisualInfoFc.red_mask = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "red_mask", "I"); + XVisualInfoFc.green_mask = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "green_mask", "I"); + XVisualInfoFc.blue_mask = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "blue_mask", "I"); + XVisualInfoFc.colormap_size = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "colormap_size", "I"); + XVisualInfoFc.bits_per_rgb = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "bits_per_rgb", "I"); + XVisualInfoFc.cached = 1; +} + +XVisualInfo *getXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct) +{ + if (!XVisualInfoFc.cached) cacheXVisualInfoFields(env, lpObject); + lpStruct->visual = (*env)->GetIntField(env, lpObject, XVisualInfoFc.visual); + lpStruct->visualid = (*env)->GetIntField(env, lpObject, XVisualInfoFc.visualid); + lpStruct->screen = (*env)->GetIntField(env, lpObject, XVisualInfoFc.screen); + lpStruct->depth = (*env)->GetIntField(env, lpObject, XVisualInfoFc.depth); + lpStruct->cclass = (*env)->GetIntField(env, lpObject, XVisualInfoFc.cclass); + lpStruct->red_mask = (*env)->GetIntField(env, lpObject, XVisualInfoFc.red_mask); + lpStruct->green_mask = (*env)->GetIntField(env, lpObject, XVisualInfoFc.green_mask); + lpStruct->blue_mask = (*env)->GetIntField(env, lpObject, XVisualInfoFc.blue_mask); + lpStruct->colormap_size = (*env)->GetIntField(env, lpObject, XVisualInfoFc.colormap_size); + lpStruct->bits_per_rgb = (*env)->GetIntField(env, lpObject, XVisualInfoFc.bits_per_rgb); + return lpStruct; +} + +void setXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct) +{ + if (!XVisualInfoFc.cached) cacheXVisualInfoFields(env, lpObject); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.visual, (jint)lpStruct->visual); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.visualid, (jint)lpStruct->visualid); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.screen, (jint)lpStruct->screen); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.depth, (jint)lpStruct->depth); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.cclass, (jint)lpStruct->cclass); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.red_mask, (jint)lpStruct->red_mask); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.green_mask, (jint)lpStruct->green_mask); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.blue_mask, (jint)lpStruct->blue_mask); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.colormap_size, (jint)lpStruct->colormap_size); + (*env)->SetIntField(env, lpObject, XVisualInfoFc.bits_per_rgb, (jint)lpStruct->bits_per_rgb); +} +#endif + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.h new file mode 100644 index 0000000000..c04f09282b --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/library/glx_structs.h @@ -0,0 +1,25 @@ +/******************************************************************************* +* Copyright (c) 2000, 2005 IBM Corporation and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* IBM Corporation - initial API and implementation +*******************************************************************************/ + +#include "glx.h" + +#ifndef NO_XVisualInfo +void cacheXVisualInfoFields(JNIEnv *env, jobject lpObject); +XVisualInfo *getXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct); +void setXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct); +#define XVisualInfo_sizeof() sizeof(XVisualInfo) +#else +#define cacheXVisualInfoFields(a,b) +#define getXVisualInfoFields(a,b,c) NULL +#define setXVisualInfoFields(a,b,c) +#define XVisualInfo_sizeof() 0 +#endif + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/GLX.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/GLX.java new file mode 100755 index 0000000000..e34457e9ec --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/GLX.java @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.internal.opengl.glx; + +import org.eclipse.swt.internal.Library; + +public class GLX { + static { + Library.loadLibrary("swt-glx"); + } + + /* + ** Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib) + */ + public static final int GLX_USE_GL = 1; /* support GLX rendering */ + public static final int GLX_BUFFER_SIZE = 2; /* depth of the color buffer */ + public static final int GLX_LEVEL = 3; /* level in plane stacking */ + public static final int GLX_RGBA = 4; /* true if RGBA mode */ + public static final int GLX_DOUBLEBUFFER = 5; /* double buffering supported */ + public static final int GLX_STEREO = 6; /* stereo buffering supported */ + public static final int GLX_AUX_BUFFERS = 7; /* number of aux buffers */ + public static final int GLX_RED_SIZE = 8; /* number of red component bits */ + public static final int GLX_GREEN_SIZE = 9; /* number of green component bits */ + public static final int GLX_BLUE_SIZE = 10; /* number of blue component bits */ + public static final int GLX_ALPHA_SIZE = 11; /* number of alpha component bits */ + public static final int GLX_DEPTH_SIZE = 12; /* number of depth bits */ + public static final int GLX_STENCIL_SIZE = 13; /* number of stencil bits */ + public static final int GLX_ACCUM_RED_SIZE = 14; /* number of red accum bits */ + public static final int GLX_ACCUM_GREEN_SIZE = 15; /* number of green accum bits */ + public static final int GLX_ACCUM_BLUE_SIZE = 16; /* number of blue accum bits */ + public static final int GLX_ACCUM_ALPHA_SIZE = 17; /* number of alpha accum bits */ + /* + ** FBConfig-specific attributes + */ + public static final int GLX_X_VISUAL_TYPE = 0x22; + public static final int GLX_CONFIG_CAVEAT = 0x20; /* Like visual_info VISUAL_CAVEAT_EXT */ + public static final int GLX_TRANSPARENT_TYPE = 0x23; + public static final int GLX_TRANSPARENT_INDEX_VALUE = 0x24; + public static final int GLX_TRANSPARENT_RED_VALUE = 0x25; + public static final int GLX_TRANSPARENT_GREEN_VALUE = 0x26; + public static final int GLX_TRANSPARENT_BLUE_VALUE = 0x27; + public static final int GLX_TRANSPARENT_ALPHA_VALUE = 0x28; + public static final int GLX_DRAWABLE_TYPE = 0x8010; + public static final int GLX_RENDER_TYPE = 0x8011; + public static final int GLX_X_RENDERABLE = 0x8012; + public static final int GLX_FBCONFIG_ID = 0x8013; + public static final int GLX_MAX_PBUFFER_WIDTH = 0x8016; + public static final int GLX_MAX_PBUFFER_HEIGHT = 0x8017; + public static final int GLX_MAX_PBUFFER_PIXELS = 0x8018; + public static final int GLX_VISUAL_ID = 0x800B; + + /* + ** Error return values from glXGetConfig. Success is indicated by + ** a value of 0. + */ + public static final int GLX_BAD_SCREEN = 1; /* screen # is bad */ + public static final int GLX_BAD_ATTRIBUTE = 2; /* attribute to get is bad */ + public static final int GLX_NO_EXTENSION = 3; /* no glx extension on server */ + public static final int GLX_BAD_VISUAL = 4; /* visual # not known by GLX */ + public static final int GLX_BAD_CONTEXT = 5; /* returned only by import_context EXT? */ + public static final int GLX_BAD_VALUE = 6; /* returned only by glXSwapIntervalSGI? */ + public static final int GLX_BAD_ENUM = 7; /* unused? */ + + /* FBConfig attribute values */ + + /* + ** Generic "don't care" value for glX ChooseFBConfig attributes (except + ** GLX_LEVEL) + */ + public static final int GLX_DONT_CARE = 0xFFFFFFFF; + + /* GLX_RENDER_TYPE bits */ + public static final int GLX_RGBA_BIT = 0x00000001; + public static final int GLX_COLOR_INDEX_BIT = 0x00000002; + + /* GLX_DRAWABLE_TYPE bits */ + public static final int GLX_WINDOW_BIT = 0x00000001; + public static final int GLX_PIXMAP_BIT = 0x00000002; + public static final int GLX_PBUFFER_BIT = 0x00000004; + + /* GLX_CONFIG_CAVEAT attribute values */ + public static final int GLX_NONE = 0x8000; + public static final int GLX_SLOW_CONFIG = 0x8001; + public static final int GLX_NON_CONFORMANT_CONFIG = 0x800D; + + /* GLX_X_VISUAL_TYPE attribute values */ + public static final int GLX_TRUE_COLOR = 0x8002; + public static final int GLX_DIRECT_COLOR = 0x8003; + public static final int GLX_PSEUDO_COLOR = 0x8004; + public static final int GLX_STATIC_COLOR = 0x8005; + public static final int GLX_GRAY_SCALE = 0x8006; + public static final int GLX_STATIC_GRAY = 0x8007; + + /* GLX_TRANSPARENT_TYPE attribute values */ + /* public static final int GLX_NONE 0x8000 */ + public static final int GLX_TRANSPARENT_RGB = 0x8008; + public static final int GLX_TRANSPARENT_INDEX = 0x8009; + + /* glXCreateGLXPbuffer attributes */ + public static final int GLX_PRESERVED_CONTENTS = 0x801B; + public static final int GLX_LARGEST_PBUFFER = 0x801C; + public static final int GLX_PBUFFER_HEIGHT = 0x8040; /* New for GLX 1.3 */ + public static final int GLX_PBUFFER_WIDTH = 0x8041; /* New for GLX 1.3 */ + + /* glXQueryGLXPBuffer attributes */ + public static final int GLX_WIDTH = 0x801D; + public static final int GLX_HEIGHT = 0x801E; + public static final int GLX_EVENT_MASK = 0x801F; + + /* glXCreateNewContext render_type attribute values */ + public static final int GLX_RGBA_TYPE = 0x8014; + public static final int GLX_COLOR_INDEX_TYPE = 0x8015; + + /* glXQueryContext attributes */ + /* public static final int GLX_FBCONFIG_ID 0x8013 */ + /* public static final int GLX_RENDER_TYPE 0x8011 */ + public static final int GLX_SCREEN = 0x800C; + + /* glXSelectEvent event mask bits */ + public static final int GLX_PBUFFER_CLOBBER_MASK = 0x08000000; + + /* GLXPbufferClobberEvent event_type values */ + public static final int GLX_DAMAGED = 0x8020; + public static final int GLX_SAVED = 0x8021; + + /* GLXPbufferClobberEvent draw_type values */ + public static final int GLX_WINDOW = 0x8022; + public static final int GLX_PBUFFER = 0x8023; + + /* GLXPbufferClobberEvent buffer_mask bits */ + public static final int GLX_FRONT_LEFT_BUFFER_BIT = 0x00000001; + public static final int GLX_FRONT_RIGHT_BUFFER_BIT = 0x00000002; + public static final int GLX_BACK_LEFT_BUFFER_BIT = 0x00000004; + public static final int GLX_BACK_RIGHT_BUFFER_BIT = 0x00000008; + public static final int GLX_AUX_BUFFERS_BIT = 0x00000010; + public static final int GLX_DEPTH_BUFFER_BIT = 0x00000020; + public static final int GLX_STENCIL_BUFFER_BIT = 0x00000040; + public static final int GLX_ACCUM_BUFFER_BIT = 0x00000080; + + /* + ** Extension return values from glXGetConfig. These are also + ** accepted as parameter values for glXChooseVisual. + */ + + public static final int GLX_X_VISUAL_TYPE_EXT = 0x22; /* visual_info extension type */ + public static final int GLX_TRANSPARENT_TYPE_EXT = 0x23; /* visual_info extension */ + public static final int GLX_TRANSPARENT_INDEX_VALUE_EXT = 0x24; /* visual_info extension */ + public static final int GLX_TRANSPARENT_RED_VALUE_EXT = 0x25; /* visual_info extension */ + public static final int GLX_TRANSPARENT_GREEN_VALUE_EXT = 0x26; /* visual_info extension */ + public static final int GLX_TRANSPARENT_BLUE_VALUE_EXT = 0x27; /* visual_info extension */ + public static final int GLX_TRANSPARENT_ALPHA_VALUE_EXT = 0x28; /* visual_info extension */ + + /* Property values for visual_type */ + public static final int GLX_TRUE_COLOR_EXT = 0x8002; + public static final int GLX_DIRECT_COLOR_EXT = 0x8003; + public static final int GLX_PSEUDO_COLOR_EXT = 0x8004; + public static final int GLX_STATIC_COLOR_EXT = 0x8005; + public static final int GLX_GRAY_SCALE_EXT = 0x8006; + public static final int GLX_STATIC_GRAY_EXT = 0x8007; + + /* Property values for transparent pixel */ + public static final int GLX_NONE_EXT = 0x8000; + public static final int GLX_TRANSPARENT_RGB_EXT = 0x8008; + public static final int GLX_TRANSPARENT_INDEX_EXT = 0x8009; + + /* Property values for visual_rating */ + public static final int GLX_VISUAL_CAVEAT_EXT = 0x20; /* visual_rating extension type */ + public static final int GLX_SLOW_VISUAL_EXT = 0x8001; + public static final int GLX_NON_CONFORMANT_VISUAL_EXT = 0x800D; + + /* + ** Names for attributes to glXGetClientString. + */ + public static final int GLX_VENDOR = 0x1; + public static final int GLX_VERSION = 0x2; + public static final int GLX_EXTENSIONS = 0x3; + + /* + ** Names for attributes to glXQueryContextInfoEXT. + */ + public static final int GLX_SHARE_CONTEXT_EXT = 0x800A; /* id of share context */ + public static final int GLX_VISUAL_ID_EXT = 0x800B; /* id of context's visual */ + public static final int GLX_SCREEN_EXT = 0x800C; /* screen number */ + + /* + * GLX 1.4 + */ + public static final int GLX_SAMPLE_BUFFERS = 100000; + public static final int GLX_SAMPLES = 100001; + + /* + * GL bits + */ + public static final int GL_VIEWPORT = 0x0BA2; + +public static final native void glGetIntegerv (int pname, int[] params); +public static final native void glViewport (int x, int y, int width, int height); + +public static final native int glXChooseVisual(int dpy, int screen, int[] attribList); +public static final native void glXCopyContext(int dpy, int src, int dst, int mask); +public static final native int glXCreateContext(int dpy, XVisualInfo vis, int shareList, boolean direct); +public static final native int glXCreateGLXPixmap(int dpy, XVisualInfo vis, int pixmap); +public static final native void glXDestroyContext(int dpy, int ctx); +public static final native void glXDestroyGLXPixmap(int dpy, int pix); +public static final native int glXGetConfig(int dpy, XVisualInfo vis, int attrib, int[] value); +public static final native int glXGetCurrentContext(); +public static final native int glXGetCurrentDrawable(); +public static final native boolean glXIsDirect(int dpy, int ctx); +public static final native boolean glXMakeCurrent(int dpy, int drawable, int ctx); +public static final native boolean glXQueryExtension(int dpy, int[] errorBase, int[] eventBase); +public static final native boolean glXQueryVersion(int dpy, int[] major, int[] minor); +public static final native void glXSwapBuffers(int dpy, int drawable); +public static final native void glXUseXFont(int font, int first, int count, int listBase); +public static final native void glXWaitGL(); +public static final native void glXWaitX(); +public static final native int glXGetClientString(int dpy, int name); +public static final native int glXQueryServerString(int dpy, int screen, int name); +public static final native int glXQueryExtensionsString(int dpy, int screen); +public static final native void memmove(XVisualInfo dest, int src, int size); +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java new file mode 100755 index 0000000000..04ee0aa15d --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.internal.opengl.glx; + +public class XVisualInfo { + public int visual; + public int visualid; + public int screen; + public int depth; + public int cclass; + public int red_mask, green_mask, blue_mask; + public int colormap_size; + public int bits_per_rgb; + public static final int sizeof = 40; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java new file mode 100644 index 0000000000..7d4384134a --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java @@ -0,0 +1,295 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl; + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.gtk.*; +import org.eclipse.swt.internal.opengl.glx.*; + +/** + * GLCanvas is a widget capable of displaying OpenGL content. + * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ + +public class GLCanvas extends Canvas { + int /*long*/ context; + int /*long*/ xWindow; + int /*long*/ glWindow; + XVisualInfo vinfo; + + private static final int MAX_ATTRIBUTES = 32; + +/** + * Create a GLCanvas widget using the attributes described in the GLData + * object provided. + * + * @param parent a composite widget + * @param style the bitwise OR'ing of widget styles + * @param data the requested attributes of the GLCanvas + * + * @exception IllegalArgumentException + *
  • ERROR_NULL_ARGUMENT when the data is null + *
  • ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
+ * @exception SWTException + *
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + *
  • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + *
  • ERROR_CANNOT_OPEN_FILE when failed to open file + *
  • ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces + *
  • ERROR_INVALID_CLASSID + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLCanvas (Composite parent, int style, GLData data) { + super (parent, style); + if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int glxAttrib [] = new int [MAX_ATTRIBUTES]; + int pos = 0; + glxAttrib [pos++] = GLX.GLX_RGBA; + if (data.doubleBuffer) glxAttrib [pos++] = GLX.GLX_DOUBLEBUFFER; + if (data.stereo) glxAttrib [pos++] = GLX.GLX_STEREO; + if (data.redSize > 0) { + glxAttrib [pos++] = GLX.GLX_RED_SIZE; + glxAttrib [pos++] = data.redSize; + } + if (data.greenSize > 0) { + glxAttrib [pos++] = GLX.GLX_GREEN_SIZE; + glxAttrib [pos++] = data.greenSize; + } + if (data.blueSize > 0) { + glxAttrib [pos++] = GLX.GLX_BLUE_SIZE; + glxAttrib [pos++] = data.blueSize; + } + if (data.alphaSize > 0) { + glxAttrib [pos++] = GLX.GLX_ALPHA_SIZE; + glxAttrib [pos++] = data.alphaSize; + } + if (data.depthSize > 0) { + glxAttrib [pos++] = GLX.GLX_DEPTH_SIZE; + glxAttrib [pos++] = data.depthSize; + } + if (data.stencilSize > 0) { + glxAttrib [pos++] = GLX.GLX_STENCIL_SIZE; + glxAttrib [pos++] = data.stencilSize; + } + if (data.accumRedSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_RED_SIZE; + glxAttrib [pos++] = data.accumRedSize; + } + if (data.accumGreenSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_GREEN_SIZE; + glxAttrib [pos++] = data.accumGreenSize; + } + if (data.accumBlueSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_BLUE_SIZE; + glxAttrib [pos++] = data.accumBlueSize; + } + if (data.accumAlphaSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_ALPHA_SIZE; + glxAttrib [pos++] = data.accumAlphaSize; + } + if (data.sampleBuffers > 0) { + glxAttrib [pos++] = GLX.GLX_SAMPLE_BUFFERS; + glxAttrib [pos++] = data.sampleBuffers; + } + if (data.samples > 0) { + glxAttrib [pos++] = GLX.GLX_SAMPLES; + glxAttrib [pos++] = data.samples; + } + glxAttrib [pos++] = 0; + OS.gtk_widget_realize (handle); + int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle); + int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window); + int infoPtr = GLX.glXChooseVisual (xDisplay, OS.XDefaultScreen (xDisplay), glxAttrib); + if (infoPtr == 0) SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH); + vinfo = new XVisualInfo (); + GLX.memmove (vinfo, infoPtr, XVisualInfo.sizeof); + OS.XFree (infoPtr); + int /*long*/ screen = OS.gdk_screen_get_default (); + int /*long*/ gdkvisual = OS.gdk_x11_screen_lookup_visual (screen, vinfo.visualid); + //FIXME- share lists + //context = GLX.glXCreateContext (xDisplay, info, share == null ? 0 : share.context, true); + context = GLX.glXCreateContext (xDisplay, vinfo, 0, true); + if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES); + GdkWindowAttr attrs = new GdkWindowAttr (); + attrs.width = 1; + attrs.height = 1; + attrs.event_mask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | + OS.GDK_FOCUS_CHANGE_MASK | OS.GDK_POINTER_MOTION_MASK | + OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | + OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | + OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK; + attrs.window_type = OS.GDK_WINDOW_CHILD; + attrs.visual = gdkvisual; + glWindow = OS.gdk_window_new (window, attrs, OS.GDK_WA_VISUAL); + OS.gdk_window_set_user_data (glWindow, handle); + xWindow = OS.gdk_x11_drawable_get_xid (glWindow); + OS.gdk_window_show (glWindow); + + Listener listener = new Listener () { + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Paint: + /** + * Bug in MESA. MESA does some nasty sort of polling to try + * and ensure that their buffer sizes match the current X state. + * This state can be updated using glViewport(). + * FIXME: There has to be a better way of doing this. + */ + int [] viewport = new int [4]; + GLX.glGetIntegerv (GLX.GL_VIEWPORT, viewport); + GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]); + break; + case SWT.Resize: + Rectangle clientArea = getClientArea(); + OS.gdk_window_move (glWindow, clientArea.x, clientArea.y); + OS.gdk_window_resize (glWindow, clientArea.width, clientArea.height); + break; + case SWT.Dispose: + int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle); + int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window); + if (context != 0) { + if (GLX.glXGetCurrentContext () == context) { + GLX.glXMakeCurrent (xDisplay, 0, 0); + } + GLX.glXDestroyContext (xDisplay, context); + context = 0; + } + if (glWindow != 0) { + OS.gdk_window_destroy (glWindow); + glWindow = 0; + } + break; + } + } + }; + addListener (SWT.Resize, listener); + addListener (SWT.Paint, listener); + addListener (SWT.Dispose, listener); +} + +/** + * Returns a GLData object describing the created context. + * + * @return GLData description of the OpenGL context attributes + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLData getGLData () { + checkWidget (); + int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle); + int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window); + GLData data = new GLData (); + int [] value = new int [1]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_DOUBLEBUFFER, value); + data.doubleBuffer = value [0] != 0; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_STEREO, value); + data.stereo = value [0] != 0; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_RED_SIZE, value); + data.redSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_GREEN_SIZE, value); + data.greenSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_BLUE_SIZE, value); + data.blueSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ALPHA_SIZE, value); + data.alphaSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_DEPTH_SIZE, value); + data.depthSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_STENCIL_SIZE, value); + data.stencilSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_RED_SIZE, value); + data.accumRedSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_GREEN_SIZE, value); + data.accumGreenSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_BLUE_SIZE, value); + data.accumBlueSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_ALPHA_SIZE, value); + data.accumAlphaSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_SAMPLE_BUFFERS, value); + data.sampleBuffers = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_SAMPLES, value); + data.samples = value [0]; + return data; +} + +/** + * Returns a boolean indicating whether the receiver's OpenGL context + * is the current context. + * + * @return true if the receiver holds the current OpenGL context, + * false otherwise + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public boolean isCurrent () { + checkWidget (); + return GLX.glXGetCurrentContext () == context; +} + +/** + * Sets the OpenGL context associated with this GLCanvas to be the + * current GL context. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void setCurrent () { + checkWidget (); + if (GLX.glXGetCurrentContext () == context) return; + int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle); + int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window); + GLX.glXMakeCurrent (xDisplay, xWindow, context); +} + +/** + * Swaps the front and back color buffers. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void swapBuffers () { + checkWidget (); + int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle); + int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window); + GLX.glXSwapBuffers (xDisplay, xWindow); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/motif/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/motif/org/eclipse/swt/opengl/GLCanvas.java new file mode 100644 index 0000000000..5e46eb4c41 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/motif/org/eclipse/swt/opengl/GLCanvas.java @@ -0,0 +1,306 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl; + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.motif.*; +import org.eclipse.swt.internal.opengl.glx.*; + +/** + * GLCanvas is a widget capable of displaying OpenGL content. + * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ + +public class GLCanvas extends Canvas { + int xWindow; + int context; + int colormap; + XVisualInfo vinfo; + + private static final int MAX_ATTRIBUTES = 32; + +/** + * Create a GLCanvas widget using the attributes described in the GLData + * object provided. + * + * @param parent a composite widget + * @param style the bitwise OR'ing of widget styles + * @param data the requested attributes of the GLCanvas + * + * @exception IllegalArgumentException + *
  • ERROR_NULL_ARGUMENT when the data is null + *
  • ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
+ * @exception SWTException + *
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + *
  • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + *
  • ERROR_CANNOT_OPEN_FILE when failed to open file + *
  • ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces + *
  • ERROR_INVALID_CLASSID + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLCanvas (Composite parent, int style, GLData data) { + super (parent, style); + if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + int glxAttrib [] = new int [MAX_ATTRIBUTES]; + int pos = 0; + glxAttrib [pos++] = GLX.GLX_RGBA; + if (data.doubleBuffer) glxAttrib [pos++] = GLX.GLX_DOUBLEBUFFER; + if (data.stereo) glxAttrib [pos++] = GLX.GLX_STEREO; + if (data.redSize > 0) { + glxAttrib [pos++] = GLX.GLX_RED_SIZE; + glxAttrib [pos++] = data.redSize; + } + if (data.greenSize > 0) { + glxAttrib [pos++] = GLX.GLX_GREEN_SIZE; + glxAttrib [pos++] = data.greenSize; + } + if (data.blueSize > 0) { + glxAttrib [pos++] = GLX.GLX_BLUE_SIZE; + glxAttrib [pos++] = data.blueSize; + } + if (data.alphaSize > 0) { + glxAttrib [pos++] = GLX.GLX_ALPHA_SIZE; + glxAttrib [pos++] = data.alphaSize; + } + if (data.depthSize > 0) { + glxAttrib [pos++] = GLX.GLX_DEPTH_SIZE; + glxAttrib [pos++] = data.depthSize; + } + if (data.stencilSize > 0) { + glxAttrib [pos++] = GLX.GLX_STENCIL_SIZE; + glxAttrib [pos++] = data.stencilSize; + } + if (data.accumRedSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_RED_SIZE; + glxAttrib [pos++] = data.accumRedSize; + } + if (data.accumGreenSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_GREEN_SIZE; + glxAttrib [pos++] = data.accumGreenSize; + } + if (data.accumBlueSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_BLUE_SIZE; + glxAttrib [pos++] = data.accumBlueSize; + } + if (data.accumAlphaSize > 0) { + glxAttrib [pos++] = GLX.GLX_ACCUM_ALPHA_SIZE; + glxAttrib [pos++] = data.accumAlphaSize; + } + if (data.sampleBuffers > 0) { + glxAttrib [pos++] = GLX.GLX_SAMPLE_BUFFERS; + glxAttrib [pos++] = data.sampleBuffers; + } + if (data.samples > 0) { + glxAttrib [pos++] = GLX.GLX_SAMPLES; + glxAttrib [pos++] = data.samples; + } + glxAttrib [pos++] = 0; + + //FIXME - need to ensure the widget is realized at this point + new GC(this).dispose(); + + int xDisplay = OS.XtDisplay (handle); + int xScreen = OS.XDefaultScreen (xDisplay); + int infoPtr = GLX.glXChooseVisual (xDisplay, xScreen, glxAttrib); + if (infoPtr == 0) SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH); + vinfo = new XVisualInfo (); + GLX.memmove (vinfo, infoPtr, XVisualInfo.sizeof); + OS.XFree (infoPtr); + //FIXME- share lists + //context = GLX.glXCreateContext (xdisplay, info, share == null ? 0 : share.context, true); + context = GLX.glXCreateContext (xDisplay, vinfo, 0, true); + if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES); + + int xParent = OS.XtWindow (handle); + XSetWindowAttributes attributes = new XSetWindowAttributes (); + int mask = OS.CWDontPropagate | OS.CWEventMask | OS.CWColormap; + colormap = OS.XCreateColormap(xDisplay, xParent, vinfo.visual, OS.AllocNone); + attributes.colormap = colormap; + xWindow = OS.XCreateWindow (xDisplay, xParent, 0, 0, 1, 1, 0, + vinfo.depth, 1, vinfo.visual, mask, attributes); + int event_mask = OS.XtBuildEventMask (handle); + /* + * Attempting to propogate EnterWindowMask and LeaveWindowMask + * causes an X error so these must be specially cleared out from + * the event mask, not included in the propogate mask. + */ + //FIXME - check this + //event_mask = event_mask | ~(OS.EnterWindowMask | OS.LeaveWindowMask); + OS.XSelectInput (xDisplay, xWindow, event_mask); + OS.XMapWindow (xDisplay, xWindow); + OS.XtRegisterDrawable (xDisplay, xWindow, handle); + + Listener listener = new Listener () { + public void handleEvent (Event event) { + int xDisplay = OS.XtDisplay (handle); + switch (event.type) { + case SWT.Paint: + /** + * Bug in MESA. MESA does some nasty sort of polling to try + * and ensure that their buffer sizes match the current X state. + * This state can be updated using glViewport(). + * FIXME: There has to be a better way of doing this. + */ + int [] viewport = new int [4]; + GLX.glGetIntegerv (GLX.GL_VIEWPORT, viewport); + GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]); + break; + case SWT.KeyDown: + break; + case SWT.Resize: + Rectangle clientArea = getClientArea(); + OS.XMoveResizeWindow (xDisplay, xWindow, clientArea.x, clientArea.y, clientArea.width, clientArea.height); + break; + case SWT.Dispose: + System.out.println("parent " + handle); + System.out.println("disposing " + context); + if (context != 0) { + if (GLX.glXGetCurrentContext () == context) { + GLX.glXMakeCurrent (xDisplay, 0, 0); + } + GLX.glXDestroyContext (xDisplay, context); + context = 0; + } + if (xWindow != 0) { + OS.XtUnregisterDrawable (xDisplay, xWindow); + OS.XDestroyWindow (xDisplay, xWindow); + xWindow = 0; + } + if (colormap != 0) { + OS.XFreeColormap (xDisplay, colormap); + colormap = 0; + } + break; + } + } + }; + addListener (SWT.KeyDown, listener); + addListener (SWT.Resize, listener); + addListener (SWT.Paint, listener); + addListener (SWT.Dispose, listener); +} + +/** + * Returns a GLData object describing the created context. + * + * @return GLData description of the OpenGL context attributes + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLData getGLData () { + checkWidget (); + int xDisplay = OS.XtDisplay (handle); + GLData data = new GLData (); + int [] value = new int [1]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_DOUBLEBUFFER, value); + data.doubleBuffer = value [0] != 0; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_STEREO, value); + data.stereo = value [0] != 0; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_RED_SIZE, value); + data.redSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_GREEN_SIZE, value); + data.greenSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_BLUE_SIZE, value); + data.blueSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ALPHA_SIZE, value); + data.alphaSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_DEPTH_SIZE, value); + data.depthSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_STENCIL_SIZE, value); + data.stencilSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_RED_SIZE, value); + data.accumRedSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_GREEN_SIZE, value); + data.accumGreenSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_BLUE_SIZE, value); + data.accumBlueSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_ALPHA_SIZE, value); + data.accumAlphaSize = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_SAMPLE_BUFFERS, value); + data.sampleBuffers = value [0]; + GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_SAMPLES, value); + data.samples = value [0]; + return data; +} + +/** + * Returns a boolean indicating whether the receiver's OpenGL context + * is the current context. + * + * @return true if the receiver holds the current OpenGL context, + * false otherwise + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public boolean isCurrent () { + checkWidget (); + return GLX.glXGetCurrentContext () == context; +} + +/** + * Sets the OpenGL context associated with this GLCanvas to be the + * current GL context. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void setCurrent () { + checkWidget (); + if (GLX.glXGetCurrentContext () == context) return; + int xDisplay = OS.XtDisplay (handle); + GLX.glXMakeCurrent (xDisplay, xWindow, context); +} + +/** + * Swaps the front and back color buffers. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void swapBuffers () { + checkWidget (); + int xDisplay = OS.XtDisplay (handle); + GLX.glXSwapBuffers (xDisplay, xWindow); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/build.bat b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/build.bat new file mode 100755 index 0000000000..e3cd949c2e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/build.bat @@ -0,0 +1,34 @@ +rem ******************************************************************************* +rem Copyright (c) 2000, 2005 IBM Corporation and others. +rem All rights reserved. This program and the accompanying materials +rem are made available under the terms of the Eclipse Public License v1.0 +rem which accompanies this distribution, and is available at +rem http://www.eclipse.org/legal/epl-v10.html +rem +rem Contributors: +rem IBM Corporation - initial API and implementation +rem ******************************************************************************* + +@echo off + +IF NOT "%JAVA_HOME%"=="" GOTO MAKE + +rem ***** +rem Javah +rem ***** +set JAVA_HOME=j:\teamswt\swt-builddir\ive\bin +set path=%JAVA_HOME%;%path% + +rem ******** +rem MSVC 6.0 +rem ******** +call k:\dev\products\msvc60\vc98\bin\vcvars32.bat + +rem ****** +rem MS-SDK +rem ****** +set Mssdk=j:\teamswt\swt-builddir\mssdk +call %mssdk%\setenv.bat + +:MAKE +nmake -f make_win32.mak %1 %2 %3 %4 diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/glw.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/glw.c new file mode 100755 index 0000000000..81c8ed5494 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/glw.c @@ -0,0 +1,283 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +#include +#include +#include "jni.h" +#include "swt.h" +#include "structs.h" + +#define WGL_NATIVE(func) Java_org_eclipse_swt_opengl_internal_win32_WGL_##func + +JNIEXPORT jint JNICALL WGL_NATIVE(ChoosePixelFormat) + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + PIXELFORMATDESCRIPTOR _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("ChoosePixelFormat\n") + + if (arg1) lparg1 = getPIXELFORMATDESCRIPTORFields(env, arg1, &_arg1); + rc = (jint)ChoosePixelFormat((HDC)arg0, (CONST PIXELFORMATDESCRIPTOR *)lparg1); + if (arg1) setPIXELFORMATDESCRIPTORFields(env, arg1, lparg1); + return rc; +} + +JNIEXPORT jint JNICALL WGL_NATIVE(DescribePixelFormat) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3) +{ + PIXELFORMATDESCRIPTOR _arg3, *lparg3=NULL; + jint rc; + + DEBUG_CALL("DescribePixelFormat\n") + + if (arg3) lparg3 = getPIXELFORMATDESCRIPTORFields(env, arg3, &_arg3); + rc = (jint)DescribePixelFormat((HDC)arg0, arg1, arg2, (LPPIXELFORMATDESCRIPTOR)lparg3); + if (arg3) setPIXELFORMATDESCRIPTORFields(env, arg3, lparg3); + return rc; +} + +JNIEXPORT jint JNICALL WGL_NATIVE(GetPixelFormat) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetPixelFormat\n") + + return (jint)GetPixelFormat((HDC)arg0); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(SetPixelFormat) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2) +{ + PIXELFORMATDESCRIPTOR _arg2, *lparg2=NULL; + jboolean rc; + + DEBUG_CALL("SetPixelFormat\n") + + if (arg2) lparg2 = getPIXELFORMATDESCRIPTORFields(env, arg2, &_arg2); + rc = (jboolean)SetPixelFormat((HDC)arg0, arg1, (CONST PIXELFORMATDESCRIPTOR *)lparg2); + if (arg2) setPIXELFORMATDESCRIPTORFields(env, arg2, lparg2); + return rc; +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(SwapBuffers) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SwapBuffers\n") + + return (jboolean)SwapBuffers((HDC)arg0); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglCopyContext) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("wglCopyContext\n") + + return (jboolean)wglCopyContext((HGLRC)arg0, (HGLRC)arg1, (UINT)arg2); +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglCreateContext) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("wglCreateContext\n") + + return (jint)wglCreateContext((HDC)arg0); +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglCreateLayerContext) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("wglCreateLayerContext\n") + + return (jint)wglCreateLayerContext((HDC)arg0, arg1); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglDeleteContext) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("wglDeleteContext\n") + + return (jboolean)wglDeleteContext((HGLRC)arg0); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglDescribeLayerPlane) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4) +{ + LAYERPLANEDESCRIPTOR _arg4, *lparg4=NULL; + jboolean rc; + + DEBUG_CALL("wglDescribeLayerPlane\n") + + if (arg4) lparg4 = getLAYERPLANEDESCRIPTORFields(env, arg4, &_arg4); + rc = (jboolean)wglDescribeLayerPlane((HDC)arg0, arg1, arg2, arg3, (LPLAYERPLANEDESCRIPTOR)lparg4); + if (arg4) setLAYERPLANEDESCRIPTORFields(env, arg4, lparg4); + return rc; +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglGetCurrentContext) + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("wglGetCurrentContext\n") + + return (jint)wglGetCurrentContext(); +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglGetCurrentDC) + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("wglGetCurrentDC\n") + + return (jint)wglGetCurrentDC(); +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglGetLayerPaletteEntries) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4) +{ + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("wglGetLayerPaletteEntries\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)wglGetLayerPaletteEntries((HDC)arg0, arg1, arg2, arg3, (COLORREF *)lparg4); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglGetProcAddress) + (JNIEnv *env, jclass that, jbyteArray arg0) +{ + jbyte *lparg0=NULL; + jint rc; + + DEBUG_CALL("wglGetProcAddress\n") + + if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); + rc = (jint)wglGetProcAddress((LPCSTR)lparg0); + if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + return rc; +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglMakeCurrent) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("wglMakeCurrent\n") + + return (jboolean)wglMakeCurrent((HDC)arg0, (HGLRC)arg1); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglRealizeLayerPalette) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2) +{ + DEBUG_CALL("wglRealizeLayerPalette\n") + + return (jboolean)wglRealizeLayerPalette((HDC)arg0, arg1, (BOOL)arg2); +} + +JNIEXPORT jint JNICALL WGL_NATIVE(wglSetLayerPaletteEntries) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4) +{ + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("wglSetLayerPaletteEntries\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)wglSetLayerPaletteEntries((HDC)arg0, arg1, arg2, arg3, (CONST COLORREF *)lparg4); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglShareLists) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("wglShareLists\n") + + return (jboolean)wglShareLists((HGLRC)arg0, (HGLRC)arg1); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglSwapLayerBuffers) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("wglSwapLayerBuffers\n") + + return (jboolean)wglSwapLayerBuffers((HDC)arg0, arg1); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglUseFontBitmapsA) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + DEBUG_CALL("wglUseFontBitmapsA\n") + + return (jboolean)wglUseFontBitmapsA((HDC)arg0, arg1, arg2, arg3); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglUseFontBitmapsW) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + DEBUG_CALL("wglUseFontBitmapsW\n") + + return (jboolean)wglUseFontBitmapsW((HDC)arg0, arg1, arg2, arg3); +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglUseFontOutlinesA) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jfloat arg4, jfloat arg5, jint arg6, jobject arg7) +{ +// GLYPHMETRICSFLOAT _arg7, *lparg7=NULL; + jboolean rc; + + DEBUG_CALL("wglUseFontOutlinesA\n") + +// if (arg7) lparg7 = getGLYPHMETRICSFLOATFields(env, arg7, &_arg7); + rc = (jboolean)wglUseFontOutlinesA((HDC)arg0, arg1, arg2, arg3, (FLOAT)arg4, (FLOAT)arg5, arg6, (LPGLYPHMETRICSFLOAT)arg7); +// if (arg7) setGLYPHMETRICSFLOATFields(env, arg7, lparg7); + return rc; +} + +JNIEXPORT jboolean JNICALL WGL_NATIVE(wglUseFontOutlinesW) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jfloat arg4, jfloat arg5, jint arg6, jobject arg7) +{ +// GLYPHMETRICSFLOAT _arg7, *lparg7=NULL; + jboolean rc; + + DEBUG_CALL("wglUseFontOutlinesW\n") + +// if (arg7) lparg7 = getGLYPHMETRICSFLOATFields(env, arg7, &_arg7); + rc = (jboolean)wglUseFontOutlinesW((HDC)arg0, arg1, arg2, arg3, (FLOAT)arg4, (FLOAT)arg5, arg6, (LPGLYPHMETRICSFLOAT)arg7); +// if (arg7) setGLYPHMETRICSFLOATFields(env, arg7, lparg7); + return rc; +} + +JNIEXPORT void JNICALL WGL_NATIVE(MoveMemoryW__Lorg_eclipse_swt_opengl_internal_win32_GLYPHMETRICSFLOAT_2II) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + GLYPHMETRICSFLOAT _arg0, *lparg0=NULL; + + DEBUG_CALL("MoveMemoryW__Lorg_eclipse_swt_opengl_internal_win32_GLYPHMETRICSFLOAT_2II\n") + DEBUG_CHECK_NULL(env, arg1) + + if (arg0) lparg0 = &_arg0; + MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2); + if (arg0) setGLYPHMETRICSFLOATFields(env, arg0, lparg0); +} + +JNIEXPORT void JNICALL WGL_NATIVE(MoveMemoryA__Lorg_eclipse_swt_opengl_internal_win32_GLYPHMETRICSFLOAT_2II) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + GLYPHMETRICSFLOAT _arg0, *lparg0=NULL; + + DEBUG_CALL("MoveMemoryA__Lorg_eclipse_swt_opengl_internal_win32_GLYPHMETRICSFLOAT_2II\n") + DEBUG_CHECK_NULL(env, arg1) + + if (arg0) lparg0 = &_arg0; + MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2); + if (arg0) setGLYPHMETRICSFLOATFields(env, arg0, lparg0); +} + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/make_win32.mak b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/make_win32.mak new file mode 100755 index 0000000000..af6a861e89 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/make_win32.mak @@ -0,0 +1,56 @@ +#******************************************************************************* +# Copyright (c) 2000, 2005 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +#******************************************************************************* + +# assumes JAVA_HOME is set in the environment from which nmake is run + +APPVER=5.0 +!include + +pgm_ver_str="SWT $(maj_ver).$(min_ver) for Windows" +timestamp_str=__DATE__\" \"__TIME__\" (EST)\" +copyright = "Copyright (C) 1999, 2003 IBM Corp. All rights reserved." + +SWT_PREFIX=gl +WS_PREFIX=win32 +SWT_LIB = $(SWT_PREFIX)-$(WS_PREFIX).dll + +LINK_LIBS = opengl32.lib glu32.lib gdi32.lib + +# note: thoroughly test all examples after changing any optimization flags +SWT_CDEBUG = #-Zi -Odi +SWT_LDEBUG = #/DEBUG /DEBUGTYPE:both +CFLAGS = -c -W3 -G6 -GD -O1 $(SWT_CDEBUG) -nologo -D_X86_=1 -D_WIN32 -D_WIN95 -D_WIN32_WINDOWS=0x0400 -D_MT -MT -DWIN32 -D_WIN32_DCOM /I$(JAVA_HOME)\include /I. +RCFLAGS = -DSWT_COMMA_VERSION=$(comma_ver) +LFLAGS = /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO $(SWT_LDEBUG) -entry:_DllMainCRTStartup@12 -dll /BASE:0x10000000 /comment:$(pgm_ver_str) /comment:$(copyright) /DLL + +SWT_OBJS = swt.obj gl.obj glu.obj glw.obj structs.obj + +all: $(SWT_LIB) + +.c.obj: + cl $(CFLAGS) $*.c + +$(SWT_LIB): $(SWT_OBJS) swt.res + echo $(LFLAGS) >templrf + echo $(LINK_LIBS) >>templrf + echo -machine:IX86 >>templrf + echo -subsystem:windows >>templrf + echo -out:$(SWT_LIB) >>templrf + echo $(SWT_OBJS) >>templrf + echo swt.res >>templrf + link @templrf + del templrf + +swt.res: + rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc + +clean: + del *.obj *.res *.dll *.lib *.exp diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.c new file mode 100755 index 0000000000..a38435b144 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.c @@ -0,0 +1,304 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +#include "swt.h" +#include "structs.h" + +typedef struct GLYPHMETRICSFLOAT_FID_CACHE { + int cached; + jclass clazz; + jfieldID gmfCellIncY, gmfCellIncX, gmfptGlyphOrigin_y, gmfptGlyphOrigin_x, gmfBlackBoxY, gmfBlackBoxX; +} GLYPHMETRICSFLOAT_FID_CACHE; +typedef GLYPHMETRICSFLOAT_FID_CACHE *PGLYPHMETRICSFLOAT_FID_CACHE; + +GLYPHMETRICSFLOAT_FID_CACHE GLYPHMETRICSFLOATFc; + +void cacheGLYPHMETRICSFLOATFids(JNIEnv *env, jobject lpObject, PGLYPHMETRICSFLOAT_FID_CACHE lpCache) +{ + if (lpCache->cached) return; + lpCache->clazz = (*env)->GetObjectClass(env, lpObject); + lpCache->gmfCellIncY = (*env)->GetFieldID(env, lpCache->clazz, "gmfCellIncY", "F"); + lpCache->gmfCellIncX = (*env)->GetFieldID(env, lpCache->clazz, "gmfCellIncX", "F"); + lpCache->gmfptGlyphOrigin_y = (*env)->GetFieldID(env, lpCache->clazz, "gmfptGlyphOrigin_y", "F"); + lpCache->gmfptGlyphOrigin_x = (*env)->GetFieldID(env, lpCache->clazz, "gmfptGlyphOrigin_x", "F"); + lpCache->gmfBlackBoxY = (*env)->GetFieldID(env, lpCache->clazz, "gmfBlackBoxY", "F"); + lpCache->gmfBlackBoxX = (*env)->GetFieldID(env, lpCache->clazz, "gmfBlackBoxX", "F"); + lpCache->cached = 1; +} + +GLYPHMETRICSFLOAT *getGLYPHMETRICSFLOATFields(JNIEnv *env, jobject lpObject, GLYPHMETRICSFLOAT *lpStruct) +{ + PGLYPHMETRICSFLOAT_FID_CACHE lpCache = &GLYPHMETRICSFLOATFc; + if (!lpCache->cached) cacheGLYPHMETRICSFLOATFids(env, lpObject, lpCache); + lpStruct->gmfCellIncY = (*env)->GetFloatField(env, lpObject, lpCache->gmfCellIncY); + lpStruct->gmfCellIncX = (*env)->GetFloatField(env, lpObject, lpCache->gmfCellIncX); + lpStruct->gmfptGlyphOrigin.y = (*env)->GetFloatField(env, lpObject, lpCache->gmfptGlyphOrigin_y); + lpStruct->gmfptGlyphOrigin.x = (*env)->GetFloatField(env, lpObject, lpCache->gmfptGlyphOrigin_x); + lpStruct->gmfBlackBoxY = (*env)->GetFloatField(env, lpObject, lpCache->gmfBlackBoxY); + lpStruct->gmfBlackBoxX = (*env)->GetFloatField(env, lpObject, lpCache->gmfBlackBoxX); + return lpStruct; +} + +void setGLYPHMETRICSFLOATFields(JNIEnv *env, jobject lpObject, GLYPHMETRICSFLOAT *lpStruct) +{ + PGLYPHMETRICSFLOAT_FID_CACHE lpCache = &GLYPHMETRICSFLOATFc; + if (!lpCache->cached) cacheGLYPHMETRICSFLOATFids(env, lpObject, lpCache); + (*env)->SetFloatField(env, lpObject, lpCache->gmfCellIncY, (jfloat)lpStruct->gmfCellIncY); + (*env)->SetFloatField(env, lpObject, lpCache->gmfCellIncX, (jfloat)lpStruct->gmfCellIncX); + (*env)->SetFloatField(env, lpObject, lpCache->gmfptGlyphOrigin_y, (jfloat)lpStruct->gmfptGlyphOrigin.y); + (*env)->SetFloatField(env, lpObject, lpCache->gmfptGlyphOrigin_x, (jfloat)lpStruct->gmfptGlyphOrigin.x); + (*env)->SetFloatField(env, lpObject, lpCache->gmfBlackBoxY, (jfloat)lpStruct->gmfBlackBoxY); + (*env)->SetFloatField(env, lpObject, lpCache->gmfBlackBoxX, (jfloat)lpStruct->gmfBlackBoxX); +} + +typedef struct LAYERPLANEDESCRIPTOR_FID_CACHE { + int cached; + jclass clazz; + jfieldID crTransparent, bReserved, iLayerPlane, cAuxBuffers, cStencilBits, cDepthBits, cAccumAlphaBits, cAccumBlueBits, cAccumGreenBits, cAccumRedBits, cAccumBits, cAlphaShift, cAlphaBits, cBlueShift, cBlueBits, cGreenShift, cGreenBits, cRedShift, cRedBits, cColorBits, iPixelType, dwFlags, nVersion, nSize; +} LAYERPLANEDESCRIPTOR_FID_CACHE; +typedef LAYERPLANEDESCRIPTOR_FID_CACHE *PLAYERPLANEDESCRIPTOR_FID_CACHE; + +LAYERPLANEDESCRIPTOR_FID_CACHE LAYERPLANEDESCRIPTORFc; + +void cacheLAYERPLANEDESCRIPTORFids(JNIEnv *env, jobject lpObject, PLAYERPLANEDESCRIPTOR_FID_CACHE lpCache) +{ + if (lpCache->cached) return; + lpCache->clazz = (*env)->GetObjectClass(env, lpObject); + lpCache->crTransparent = (*env)->GetFieldID(env, lpCache->clazz, "crTransparent", "I"); + lpCache->bReserved = (*env)->GetFieldID(env, lpCache->clazz, "bReserved", "B"); + lpCache->iLayerPlane = (*env)->GetFieldID(env, lpCache->clazz, "iLayerPlane", "B"); + lpCache->cAuxBuffers = (*env)->GetFieldID(env, lpCache->clazz, "cAuxBuffers", "B"); + lpCache->cStencilBits = (*env)->GetFieldID(env, lpCache->clazz, "cStencilBits", "B"); + lpCache->cDepthBits = (*env)->GetFieldID(env, lpCache->clazz, "cDepthBits", "B"); + lpCache->cAccumAlphaBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumAlphaBits", "B"); + lpCache->cAccumBlueBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumBlueBits", "B"); + lpCache->cAccumGreenBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumGreenBits", "B"); + lpCache->cAccumRedBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumRedBits", "B"); + lpCache->cAccumBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumBits", "B"); + lpCache->cAlphaShift = (*env)->GetFieldID(env, lpCache->clazz, "cAlphaShift", "B"); + lpCache->cAlphaBits = (*env)->GetFieldID(env, lpCache->clazz, "cAlphaBits", "B"); + lpCache->cBlueShift = (*env)->GetFieldID(env, lpCache->clazz, "cBlueShift", "B"); + lpCache->cBlueBits = (*env)->GetFieldID(env, lpCache->clazz, "cBlueBits", "B"); + lpCache->cGreenShift = (*env)->GetFieldID(env, lpCache->clazz, "cGreenShift", "B"); + lpCache->cGreenBits = (*env)->GetFieldID(env, lpCache->clazz, "cGreenBits", "B"); + lpCache->cRedShift = (*env)->GetFieldID(env, lpCache->clazz, "cRedShift", "B"); + lpCache->cRedBits = (*env)->GetFieldID(env, lpCache->clazz, "cRedBits", "B"); + lpCache->cColorBits = (*env)->GetFieldID(env, lpCache->clazz, "cColorBits", "B"); + lpCache->iPixelType = (*env)->GetFieldID(env, lpCache->clazz, "iPixelType", "B"); + lpCache->dwFlags = (*env)->GetFieldID(env, lpCache->clazz, "dwFlags", "I"); + lpCache->nVersion = (*env)->GetFieldID(env, lpCache->clazz, "nVersion", "S"); + lpCache->nSize = (*env)->GetFieldID(env, lpCache->clazz, "nSize", "S"); + lpCache->cached = 1; +} + +LAYERPLANEDESCRIPTOR *getLAYERPLANEDESCRIPTORFields(JNIEnv *env, jobject lpObject, LAYERPLANEDESCRIPTOR *lpStruct) +{ + PLAYERPLANEDESCRIPTOR_FID_CACHE lpCache = &LAYERPLANEDESCRIPTORFc; + if (!lpCache->cached) cacheLAYERPLANEDESCRIPTORFids(env, lpObject, lpCache); + lpStruct->crTransparent = (*env)->GetIntField(env, lpObject, lpCache->crTransparent); + lpStruct->bReserved = (*env)->GetByteField(env, lpObject, lpCache->bReserved); + lpStruct->iLayerPlane = (*env)->GetByteField(env, lpObject, lpCache->iLayerPlane); + lpStruct->cAuxBuffers = (*env)->GetByteField(env, lpObject, lpCache->cAuxBuffers); + lpStruct->cStencilBits = (*env)->GetByteField(env, lpObject, lpCache->cStencilBits); + lpStruct->cDepthBits = (*env)->GetByteField(env, lpObject, lpCache->cDepthBits); + lpStruct->cAccumAlphaBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumAlphaBits); + lpStruct->cAccumBlueBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumBlueBits); + lpStruct->cAccumGreenBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumGreenBits); + lpStruct->cAccumRedBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumRedBits); + lpStruct->cAccumBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumBits); + lpStruct->cAlphaShift = (*env)->GetByteField(env, lpObject, lpCache->cAlphaShift); + lpStruct->cAlphaBits = (*env)->GetByteField(env, lpObject, lpCache->cAlphaBits); + lpStruct->cBlueShift = (*env)->GetByteField(env, lpObject, lpCache->cBlueShift); + lpStruct->cBlueBits = (*env)->GetByteField(env, lpObject, lpCache->cBlueBits); + lpStruct->cGreenShift = (*env)->GetByteField(env, lpObject, lpCache->cGreenShift); + lpStruct->cGreenBits = (*env)->GetByteField(env, lpObject, lpCache->cGreenBits); + lpStruct->cRedShift = (*env)->GetByteField(env, lpObject, lpCache->cRedShift); + lpStruct->cRedBits = (*env)->GetByteField(env, lpObject, lpCache->cRedBits); + lpStruct->cColorBits = (*env)->GetByteField(env, lpObject, lpCache->cColorBits); + lpStruct->iPixelType = (*env)->GetByteField(env, lpObject, lpCache->iPixelType); + lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, lpCache->dwFlags); + lpStruct->nVersion = (*env)->GetShortField(env, lpObject, lpCache->nVersion); + lpStruct->nSize = (*env)->GetShortField(env, lpObject, lpCache->nSize); + return lpStruct; +} + +void setLAYERPLANEDESCRIPTORFields(JNIEnv *env, jobject lpObject, LAYERPLANEDESCRIPTOR *lpStruct) +{ + PLAYERPLANEDESCRIPTOR_FID_CACHE lpCache = &LAYERPLANEDESCRIPTORFc; + if (!lpCache->cached) cacheLAYERPLANEDESCRIPTORFids(env, lpObject, lpCache); + (*env)->SetIntField(env, lpObject, lpCache->crTransparent, (jint)lpStruct->crTransparent); + (*env)->SetByteField(env, lpObject, lpCache->bReserved, (jbyte)lpStruct->bReserved); + (*env)->SetByteField(env, lpObject, lpCache->iLayerPlane, (jbyte)lpStruct->iLayerPlane); + (*env)->SetByteField(env, lpObject, lpCache->cAuxBuffers, (jbyte)lpStruct->cAuxBuffers); + (*env)->SetByteField(env, lpObject, lpCache->cStencilBits, (jbyte)lpStruct->cStencilBits); + (*env)->SetByteField(env, lpObject, lpCache->cDepthBits, (jbyte)lpStruct->cDepthBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumAlphaBits, (jbyte)lpStruct->cAccumAlphaBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumBlueBits, (jbyte)lpStruct->cAccumBlueBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumGreenBits, (jbyte)lpStruct->cAccumGreenBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumRedBits, (jbyte)lpStruct->cAccumRedBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumBits, (jbyte)lpStruct->cAccumBits); + (*env)->SetByteField(env, lpObject, lpCache->cAlphaShift, (jbyte)lpStruct->cAlphaShift); + (*env)->SetByteField(env, lpObject, lpCache->cAlphaBits, (jbyte)lpStruct->cAlphaBits); + (*env)->SetByteField(env, lpObject, lpCache->cBlueShift, (jbyte)lpStruct->cBlueShift); + (*env)->SetByteField(env, lpObject, lpCache->cBlueBits, (jbyte)lpStruct->cBlueBits); + (*env)->SetByteField(env, lpObject, lpCache->cGreenShift, (jbyte)lpStruct->cGreenShift); + (*env)->SetByteField(env, lpObject, lpCache->cGreenBits, (jbyte)lpStruct->cGreenBits); + (*env)->SetByteField(env, lpObject, lpCache->cRedShift, (jbyte)lpStruct->cRedShift); + (*env)->SetByteField(env, lpObject, lpCache->cRedBits, (jbyte)lpStruct->cRedBits); + (*env)->SetByteField(env, lpObject, lpCache->cColorBits, (jbyte)lpStruct->cColorBits); + (*env)->SetByteField(env, lpObject, lpCache->iPixelType, (jbyte)lpStruct->iPixelType); + (*env)->SetIntField(env, lpObject, lpCache->dwFlags, (jint)lpStruct->dwFlags); + (*env)->SetShortField(env, lpObject, lpCache->nVersion, (jshort)lpStruct->nVersion); + (*env)->SetShortField(env, lpObject, lpCache->nSize, (jshort)lpStruct->nSize); +} + +typedef struct POINTFLOAT_FID_CACHE { + int cached; + jclass clazz; + jfieldID y, x; +} POINTFLOAT_FID_CACHE; +typedef POINTFLOAT_FID_CACHE *PPOINTFLOAT_FID_CACHE; + +POINTFLOAT_FID_CACHE POINTFLOATFc; + +void cachePOINTFLOATFids(JNIEnv *env, jobject lpObject, PPOINTFLOAT_FID_CACHE lpCache) +{ + if (lpCache->cached) return; + lpCache->clazz = (*env)->GetObjectClass(env, lpObject); + lpCache->y = (*env)->GetFieldID(env, lpCache->clazz, "y", "F"); + lpCache->x = (*env)->GetFieldID(env, lpCache->clazz, "x", "F"); + lpCache->cached = 1; +} + +POINTFLOAT *getPOINTFLOATFields(JNIEnv *env, jobject lpObject, POINTFLOAT *lpStruct) +{ + PPOINTFLOAT_FID_CACHE lpCache = &POINTFLOATFc; + if (!lpCache->cached) cachePOINTFLOATFids(env, lpObject, lpCache); + lpStruct->y = (*env)->GetFloatField(env, lpObject, lpCache->y); + lpStruct->x = (*env)->GetFloatField(env, lpObject, lpCache->x); + return lpStruct; +} + +void setPOINTFLOATFields(JNIEnv *env, jobject lpObject, POINTFLOAT *lpStruct) +{ + PPOINTFLOAT_FID_CACHE lpCache = &POINTFLOATFc; + if (!lpCache->cached) cachePOINTFLOATFids(env, lpObject, lpCache); + (*env)->SetFloatField(env, lpObject, lpCache->y, (jfloat)lpStruct->y); + (*env)->SetFloatField(env, lpObject, lpCache->x, (jfloat)lpStruct->x); +} + +typedef struct PIXELFORMATDESCRIPTOR_FID_CACHE { + int cached; + jclass clazz; + jfieldID dwDamageMask, dwVisibleMask, dwLayerMask, bReserved, iLayerType, cAuxBuffers, cStencilBits, cDepthBits, cAccumAlphaBits, cAccumBlueBits, cAccumGreenBits, cAccumRedBits, cAccumBits, cAlphaShift, cAlphaBits, cBlueShift, cBlueBits, cGreenShift, cGreenBits, cRedShift, cRedBits, cColorBits, iPixelType, dwFlags, nVersion, nSize; +} PIXELFORMATDESCRIPTOR_FID_CACHE; +typedef PIXELFORMATDESCRIPTOR_FID_CACHE *PPIXELFORMATDESCRIPTOR_FID_CACHE; + +PIXELFORMATDESCRIPTOR_FID_CACHE PIXELFORMATDESCRIPTORFc; + +void cachePIXELFORMATDESCRIPTORFids(JNIEnv *env, jobject lpObject, PPIXELFORMATDESCRIPTOR_FID_CACHE lpCache) +{ + if (lpCache->cached) return; + lpCache->clazz = (*env)->GetObjectClass(env, lpObject); + lpCache->dwDamageMask = (*env)->GetFieldID(env, lpCache->clazz, "dwDamageMask", "I"); + lpCache->dwVisibleMask = (*env)->GetFieldID(env, lpCache->clazz, "dwVisibleMask", "I"); + lpCache->dwLayerMask = (*env)->GetFieldID(env, lpCache->clazz, "dwLayerMask", "I"); + lpCache->bReserved = (*env)->GetFieldID(env, lpCache->clazz, "bReserved", "B"); + lpCache->iLayerType = (*env)->GetFieldID(env, lpCache->clazz, "iLayerType", "B"); + lpCache->cAuxBuffers = (*env)->GetFieldID(env, lpCache->clazz, "cAuxBuffers", "B"); + lpCache->cStencilBits = (*env)->GetFieldID(env, lpCache->clazz, "cStencilBits", "B"); + lpCache->cDepthBits = (*env)->GetFieldID(env, lpCache->clazz, "cDepthBits", "B"); + lpCache->cAccumAlphaBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumAlphaBits", "B"); + lpCache->cAccumBlueBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumBlueBits", "B"); + lpCache->cAccumGreenBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumGreenBits", "B"); + lpCache->cAccumRedBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumRedBits", "B"); + lpCache->cAccumBits = (*env)->GetFieldID(env, lpCache->clazz, "cAccumBits", "B"); + lpCache->cAlphaShift = (*env)->GetFieldID(env, lpCache->clazz, "cAlphaShift", "B"); + lpCache->cAlphaBits = (*env)->GetFieldID(env, lpCache->clazz, "cAlphaBits", "B"); + lpCache->cBlueShift = (*env)->GetFieldID(env, lpCache->clazz, "cBlueShift", "B"); + lpCache->cBlueBits = (*env)->GetFieldID(env, lpCache->clazz, "cBlueBits", "B"); + lpCache->cGreenShift = (*env)->GetFieldID(env, lpCache->clazz, "cGreenShift", "B"); + lpCache->cGreenBits = (*env)->GetFieldID(env, lpCache->clazz, "cGreenBits", "B"); + lpCache->cRedShift = (*env)->GetFieldID(env, lpCache->clazz, "cRedShift", "B"); + lpCache->cRedBits = (*env)->GetFieldID(env, lpCache->clazz, "cRedBits", "B"); + lpCache->cColorBits = (*env)->GetFieldID(env, lpCache->clazz, "cColorBits", "B"); + lpCache->iPixelType = (*env)->GetFieldID(env, lpCache->clazz, "iPixelType", "B"); + lpCache->dwFlags = (*env)->GetFieldID(env, lpCache->clazz, "dwFlags", "I"); + lpCache->nVersion = (*env)->GetFieldID(env, lpCache->clazz, "nVersion", "S"); + lpCache->nSize = (*env)->GetFieldID(env, lpCache->clazz, "nSize", "S"); + lpCache->cached = 1; +} + +PIXELFORMATDESCRIPTOR *getPIXELFORMATDESCRIPTORFields(JNIEnv *env, jobject lpObject, PIXELFORMATDESCRIPTOR *lpStruct) +{ + PPIXELFORMATDESCRIPTOR_FID_CACHE lpCache = &PIXELFORMATDESCRIPTORFc; + if (!lpCache->cached) cachePIXELFORMATDESCRIPTORFids(env, lpObject, lpCache); + lpStruct->dwDamageMask = (*env)->GetIntField(env, lpObject, lpCache->dwDamageMask); + lpStruct->dwVisibleMask = (*env)->GetIntField(env, lpObject, lpCache->dwVisibleMask); + lpStruct->dwLayerMask = (*env)->GetIntField(env, lpObject, lpCache->dwLayerMask); + lpStruct->bReserved = (*env)->GetByteField(env, lpObject, lpCache->bReserved); + lpStruct->iLayerType = (*env)->GetByteField(env, lpObject, lpCache->iLayerType); + lpStruct->cAuxBuffers = (*env)->GetByteField(env, lpObject, lpCache->cAuxBuffers); + lpStruct->cStencilBits = (*env)->GetByteField(env, lpObject, lpCache->cStencilBits); + lpStruct->cDepthBits = (*env)->GetByteField(env, lpObject, lpCache->cDepthBits); + lpStruct->cAccumAlphaBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumAlphaBits); + lpStruct->cAccumBlueBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumBlueBits); + lpStruct->cAccumGreenBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumGreenBits); + lpStruct->cAccumRedBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumRedBits); + lpStruct->cAccumBits = (*env)->GetByteField(env, lpObject, lpCache->cAccumBits); + lpStruct->cAlphaShift = (*env)->GetByteField(env, lpObject, lpCache->cAlphaShift); + lpStruct->cAlphaBits = (*env)->GetByteField(env, lpObject, lpCache->cAlphaBits); + lpStruct->cBlueShift = (*env)->GetByteField(env, lpObject, lpCache->cBlueShift); + lpStruct->cBlueBits = (*env)->GetByteField(env, lpObject, lpCache->cBlueBits); + lpStruct->cGreenShift = (*env)->GetByteField(env, lpObject, lpCache->cGreenShift); + lpStruct->cGreenBits = (*env)->GetByteField(env, lpObject, lpCache->cGreenBits); + lpStruct->cRedShift = (*env)->GetByteField(env, lpObject, lpCache->cRedShift); + lpStruct->cRedBits = (*env)->GetByteField(env, lpObject, lpCache->cRedBits); + lpStruct->cColorBits = (*env)->GetByteField(env, lpObject, lpCache->cColorBits); + lpStruct->iPixelType = (*env)->GetByteField(env, lpObject, lpCache->iPixelType); + lpStruct->dwFlags = (*env)->GetIntField(env, lpObject, lpCache->dwFlags); + lpStruct->nVersion = (*env)->GetShortField(env, lpObject, lpCache->nVersion); + lpStruct->nSize = (*env)->GetShortField(env, lpObject, lpCache->nSize); + return lpStruct; +} + +void setPIXELFORMATDESCRIPTORFields(JNIEnv *env, jobject lpObject, PIXELFORMATDESCRIPTOR *lpStruct) +{ + PPIXELFORMATDESCRIPTOR_FID_CACHE lpCache = &PIXELFORMATDESCRIPTORFc; + if (!lpCache->cached) cachePIXELFORMATDESCRIPTORFids(env, lpObject, lpCache); + (*env)->SetIntField(env, lpObject, lpCache->dwDamageMask, (jint)lpStruct->dwDamageMask); + (*env)->SetIntField(env, lpObject, lpCache->dwVisibleMask, (jint)lpStruct->dwVisibleMask); + (*env)->SetIntField(env, lpObject, lpCache->dwLayerMask, (jint)lpStruct->dwLayerMask); + (*env)->SetByteField(env, lpObject, lpCache->bReserved, (jbyte)lpStruct->bReserved); + (*env)->SetByteField(env, lpObject, lpCache->iLayerType, (jbyte)lpStruct->iLayerType); + (*env)->SetByteField(env, lpObject, lpCache->cAuxBuffers, (jbyte)lpStruct->cAuxBuffers); + (*env)->SetByteField(env, lpObject, lpCache->cStencilBits, (jbyte)lpStruct->cStencilBits); + (*env)->SetByteField(env, lpObject, lpCache->cDepthBits, (jbyte)lpStruct->cDepthBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumAlphaBits, (jbyte)lpStruct->cAccumAlphaBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumBlueBits, (jbyte)lpStruct->cAccumBlueBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumGreenBits, (jbyte)lpStruct->cAccumGreenBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumRedBits, (jbyte)lpStruct->cAccumRedBits); + (*env)->SetByteField(env, lpObject, lpCache->cAccumBits, (jbyte)lpStruct->cAccumBits); + (*env)->SetByteField(env, lpObject, lpCache->cAlphaShift, (jbyte)lpStruct->cAlphaShift); + (*env)->SetByteField(env, lpObject, lpCache->cAlphaBits, (jbyte)lpStruct->cAlphaBits); + (*env)->SetByteField(env, lpObject, lpCache->cBlueShift, (jbyte)lpStruct->cBlueShift); + (*env)->SetByteField(env, lpObject, lpCache->cBlueBits, (jbyte)lpStruct->cBlueBits); + (*env)->SetByteField(env, lpObject, lpCache->cGreenShift, (jbyte)lpStruct->cGreenShift); + (*env)->SetByteField(env, lpObject, lpCache->cGreenBits, (jbyte)lpStruct->cGreenBits); + (*env)->SetByteField(env, lpObject, lpCache->cRedShift, (jbyte)lpStruct->cRedShift); + (*env)->SetByteField(env, lpObject, lpCache->cRedBits, (jbyte)lpStruct->cRedBits); + (*env)->SetByteField(env, lpObject, lpCache->cColorBits, (jbyte)lpStruct->cColorBits); + (*env)->SetByteField(env, lpObject, lpCache->iPixelType, (jbyte)lpStruct->iPixelType); + (*env)->SetIntField(env, lpObject, lpCache->dwFlags, (jint)lpStruct->dwFlags); + (*env)->SetShortField(env, lpObject, lpCache->nVersion, (jshort)lpStruct->nVersion); + (*env)->SetShortField(env, lpObject, lpCache->nSize, (jshort)lpStruct->nSize); +} + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.h new file mode 100755 index 0000000000..14c62a85dd --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/structs.h @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +#include + +GLYPHMETRICSFLOAT *getGLYPHMETRICSFLOATFields(JNIEnv *env, jobject lpObject, GLYPHMETRICSFLOAT *lpStruct); +void setGLYPHMETRICSFLOATFields(JNIEnv *env, jobject lpObject, GLYPHMETRICSFLOAT *lpStruct); + +LAYERPLANEDESCRIPTOR *getLAYERPLANEDESCRIPTORFields(JNIEnv *env, jobject lpObject, LAYERPLANEDESCRIPTOR *lpStruct); +void setLAYERPLANEDESCRIPTORFields(JNIEnv *env, jobject lpObject, LAYERPLANEDESCRIPTOR *lpStruct); + +POINTFLOAT *getPOINTFLOATFields(JNIEnv *env, jobject lpObject, POINTFLOAT *lpStruct); +void setPOINTFLOATFields(JNIEnv *env, jobject lpObject, POINTFLOAT *lpStruct); + +PIXELFORMATDESCRIPTOR *getPIXELFORMATDESCRIPTORFields(JNIEnv *env, jobject lpObject, PIXELFORMATDESCRIPTOR *lpStruct); +void setPIXELFORMATDESCRIPTORFields(JNIEnv *env, jobject lpObject, PIXELFORMATDESCRIPTOR *lpStruct); + diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/swt.rc b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/swt.rc new file mode 100755 index 0000000000..c5b350cb38 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/library/swt.rc @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +#include "windows.h" + +VS_VERSION_INFO VERSIONINFO + PRODUCTVERSION 0,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40000L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "IBM Corporation\0" + VALUE "FileDescription", "Standard Widget Toolkit\0" + VALUE "InternalName", "SWT\0" + VALUE "LegalCopyright", "© Copyright 2000, 2003 IBM Corp. All Rights Reserved.\0" + VALUE "OriginalFilename", SWT_ORG_FILENAME + VALUE "ProductName", "\0" + VALUE "ProductVersion", "0,0,0,0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +/* SHMENUBAR Pocket PC + * ID_MENU SHMENUBAR DISCARDABLE + * BEGIN + * ID_MENU, 1, + * IMAGE_NONE, ID_MENU_ITEM1, 0, 0, + * 0, 0, 0, + * END + * ID_MENU MENU DISCARDABLE + * BEGIN + * MENUITEM "", ID_MENU_ITEM1 + * END + */ +100 RCDATA DISCARDABLE +BEGIN + 100, 1, + -2, 101, 0, 0, + 0, 0, 0, +END + +100 MENU DISCARDABLE +BEGIN + MENUITEM "", 101 +END \ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/LAYERPLANEDESCRIPTOR.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/LAYERPLANEDESCRIPTOR.java new file mode 100755 index 0000000000..8f674ae39e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/LAYERPLANEDESCRIPTOR.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl.internal.win32; + + +public class LAYERPLANEDESCRIPTOR { + public short nSize; + public short nVersion; + public int dwFlags; + public byte iPixelType; + public byte cColorBits; + public byte cRedBits; + public byte cRedShift; + public byte cGreenBits; + public byte cGreenShift; + public byte cBlueBits; + public byte cBlueShift; + public byte cAlphaBits; + public byte cAlphaShift; + public byte cAccumBits; + public byte cAccumRedBits; + public byte cAccumGreenBits; + public byte cAccumBlueBits; + public byte cAccumAlphaBits; + public byte cDepthBits; + public byte cStencilBits; + public byte cAuxBuffers; + public byte iLayerPlane; + public byte bReserved; + public int crTransparent; + public static final int sizeof = 36; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/PIXELFORMATDESCRIPTOR.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/PIXELFORMATDESCRIPTOR.java new file mode 100755 index 0000000000..a817010b7e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/PIXELFORMATDESCRIPTOR.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl.internal.win32; + + +public class PIXELFORMATDESCRIPTOR { + public short nSize; + public short nVersion; + public int dwFlags; + public byte iPixelType; + public byte cColorBits; + public byte cRedBits; + public byte cRedShift; + public byte cGreenBits; + public byte cGreenShift; + public byte cBlueBits; + public byte cBlueShift; + public byte cAlphaBits; + public byte cAlphaShift; + public byte cAccumBits; + public byte cAccumRedBits; + public byte cAccumGreenBits; + public byte cAccumBlueBits; + public byte cAccumAlphaBits; + public byte cDepthBits; + public byte cStencilBits; + public byte cAuxBuffers; + public byte iLayerType; + public byte bReserved; + public int dwLayerMask; + public int dwVisibleMask; + public int dwDamageMask; + public static final int sizeof = 40; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/WGL.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/WGL.java new file mode 100755 index 0000000000..caea947698 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/internal/opengl/win32/WGL.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl.internal.win32; + +import org.eclipse.swt.internal.Library; + +public class WGL { + static { + Library.loadLibrary("swt-wgl"); + } + + public static final int WGL_FONT_LINES = 0; + public static final int WGL_FONT_POLYGONS = 1; + + /* LAYERPLANEDESCRIPTOR flags */ + public static final int LPD_DOUBLEBUFFER = 0x00000001; + public static final int LPD_STEREO = 0x00000002; + public static final int LPD_SUPPORT_GDI = 0x00000010; + public static final int LPD_SUPPORT_OPENGL = 0x00000020; + public static final int LPD_SHARE_DEPTH = 0x00000040; + public static final int LPD_SHARE_STENCIL = 0x00000080; + public static final int LPD_SHARE_ACCUM = 0x00000100; + public static final int LPD_SWAP_EXCHANGE = 0x00000200; + public static final int LPD_SWAP_COPY = 0x00000400; + public static final int LPD_TRANSPARENT = 0x00001000; + + public static final int LPD_TYPE_RGBA = 0; + public static final int LPD_TYPE_COLORINDEX = 1; + + /* wglSwapLayerBuffers flags */ + public static final int WGL_SWAP_MAIN_PLANE = 0x00000001; + public static final int WGL_SWAP_OVERLAY1 = 0x00000002; + public static final int WGL_SWAP_OVERLAY2 = 0x00000004; + public static final int WGL_SWAP_OVERLAY3 = 0x00000008; + public static final int WGL_SWAP_OVERLAY4 = 0x00000010; + public static final int WGL_SWAP_OVERLAY5 = 0x00000020; + public static final int WGL_SWAP_OVERLAY6 = 0x00000040; + public static final int WGL_SWAP_OVERLAY7 = 0x00000080; + public static final int WGL_SWAP_OVERLAY8 = 0x00000100; + public static final int WGL_SWAP_OVERLAY9 = 0x00000200; + public static final int WGL_SWAP_OVERLAY10 = 0x00000400; + public static final int WGL_SWAP_OVERLAY11 = 0x00000800; + public static final int WGL_SWAP_OVERLAY12 = 0x00001000; + public static final int WGL_SWAP_OVERLAY13 = 0x00002000; + public static final int WGL_SWAP_OVERLAY14 = 0x00004000; + public static final int WGL_SWAP_OVERLAY15 = 0x00008000; + public static final int WGL_SWAP_UNDERLAY1 = 0x00010000; + public static final int WGL_SWAP_UNDERLAY2 = 0x00020000; + public static final int WGL_SWAP_UNDERLAY3 = 0x00040000; + public static final int WGL_SWAP_UNDERLAY4 = 0x00080000; + public static final int WGL_SWAP_UNDERLAY5 = 0x00100000; + public static final int WGL_SWAP_UNDERLAY6 = 0x00200000; + public static final int WGL_SWAP_UNDERLAY7 = 0x00400000; + public static final int WGL_SWAP_UNDERLAY8 = 0x00800000; + public static final int WGL_SWAP_UNDERLAY9 = 0x01000000; + public static final int WGL_SWAP_UNDERLAY10 = 0x02000000; + public static final int WGL_SWAP_UNDERLAY11 = 0x04000000; + public static final int WGL_SWAP_UNDERLAY12 = 0x08000000; + public static final int WGL_SWAP_UNDERLAY13 = 0x10000000; + public static final int WGL_SWAP_UNDERLAY14 = 0x20000000; + public static final int WGL_SWAP_UNDERLAY15 = 0x40000000; + + /* pixel types */ + public static final int PFD_TYPE_RGBA = 0; + public static final int PFD_TYPE_COLORINDEX = 1; + + /* layer types */ + public static final int PFD_MAIN_PLANE = 0; + public static final int PFD_OVERLAY_PLANE = 1; + public static final int PFD_UNDERLAY_PLANE = (-1); + + /* PIXELFORMATDESCRIPTOR flags */ + public static final int PFD_DOUBLEBUFFER = 0x00000001; + public static final int PFD_STEREO = 0x00000002; + public static final int PFD_DRAW_TO_WINDOW = 0x00000004; + public static final int PFD_DRAW_TO_BITMAP = 0x00000008; + public static final int PFD_SUPPORT_GDI = 0x00000010; + public static final int PFD_SUPPORT_OPENGL = 0x00000020; + public static final int PFD_GENERIC_FORMAT = 0x00000040; + public static final int PFD_NEED_PALETTE = 0x00000080; + public static final int PFD_NEED_SYSTEM_PALETTE = 0x00000100; + public static final int PFD_SWAP_EXCHANGE = 0x00000200; + public static final int PFD_SWAP_COPY = 0x00000400; + public static final int PFD_SWAP_LAYER_BUFFERS = 0x00000800; + public static final int PFD_GENERIC_ACCELERATED = 0x00001000; + public static final int PFD_SUPPORT_DIRECTDRAW = 0x00002000; + + /* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */ + public static final int PFD_DEPTH_DONTCARE = 0x20000000; + public static final int PFD_DOUBLEBUFFER_DONTCARE = 0x40000000; + public static final int PFD_STEREO_DONTCARE = 0x80000000; + +public static final native int ChoosePixelFormat(int hdc, PIXELFORMATDESCRIPTOR ppfd); +public static final native int DescribePixelFormat(int hdc, int iPixelFormat, int nBytes, PIXELFORMATDESCRIPTOR ppfd); +public static final native int GetPixelFormat(int hdc); +public static final native boolean SetPixelFormat(int hdc, int iPixelFormat, PIXELFORMATDESCRIPTOR ppfd); +public static final native boolean SwapBuffers(int hdc); +public static final native boolean wglCopyContext(int hglrcSrc, int hglrcDst, int mask); +public static final native int wglCreateContext(int hdc); +public static final native int wglCreateLayerContext(int hdc, int iLayerPlane); +public static final native boolean wglDeleteContext(int hglrc); +public static final native int wglGetCurrentContext(); +public static final native int wglGetCurrentDC(); +public static final native int wglGetProcAddress(byte[] lpszProc); +public static final native boolean wglMakeCurrent(int hdc, int hglrc); +public static final native boolean wglShareLists(int hglrc1, int hglrc2); +public static final native boolean wglUseFontBitmapsA(int hdc, int first, int count, int listBase); +public static final native boolean wglUseFontBitmapsW(int hdc, int first, int count, int listBase); +public static final boolean wglUseFontBitmaps(int hdc, int first, int count, int listBase) { + if (OS.IsUnicode) return wglUseFontBitmapsW(hdc, first, count, listBase); + return wglUseFontBitmapsA(hdc, first, count, listBase); +} +public static final native boolean wglUseFontOutlinesA(int hdc, int first, int count, int listBase, float deviation, float extrusion, int format, int lpgmf); +public static final native boolean wglUseFontOutlinesW(int hdc, int first, int count, int listBase, float deviation, float extrusion, int format, int lpgmf); +public static final boolean wglUseFontOutlines(int hdc, int first, int count, int listBase, float deviation, float extrusion, int format, int lpgmf) { + if (OS.IsUnicode) return wglUseFontOutlinesW(hdc, first, count, listBase, deviation, extrusion, format, lpgmf); + return wglUseFontOutlinesA(hdc, first, count, listBase, deviation, extrusion, format, lpgmf); +} +public static final native boolean wglDescribeLayerPlane(int hdc, int iPixelFormat, int iLayerPlane, int nBytes, LAYERPLANEDESCRIPTOR plpd); +public static final native int wglSetLayerPaletteEntries(int hdc, int iLayerPlane, int iStart, int cEntries, int[] pcr); +public static final native int wglGetLayerPaletteEntries(int hdc, int iLayerPlane, int iStart, int cEntries, int[] pcr); +public static final native boolean wglRealizeLayerPalette(int hdc, int iLayerPlane, boolean bRealize); +public static final native boolean wglSwapLayerBuffers(int hdc, int fuPlanes); +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/opengl/GLCanvas.java new file mode 100644 index 0000000000..c0b709dd7c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32/org/eclipse/swt/opengl/GLCanvas.java @@ -0,0 +1,211 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.opengl; + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.internal.win32.*; +import org.eclipse.swt.internal.opengl.win32.*; + +/** + * GLCanvas is a widget capable of displaying OpenGL content. + * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ + +public class GLCanvas extends Canvas { + int context; + int pixelFormat; + +/** + * Create a GLCanvas widget using the attributes described in the GLData + * object provided. + * + * @param parent a composite widget + * @param style the bitwise OR'ing of widget styles + * @param data the requested attributes of the GLCanvas + * + * @exception IllegalArgumentException + *
  • ERROR_NULL_ARGUMENT when the data is null + *
  • ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
+ * @exception SWTException + *
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread + *
  • ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object + *
  • ERROR_CANNOT_OPEN_FILE when failed to open file + *
  • ERROR_INTERFACE_NOT_FOUND when unable to create callbacks for OLE Interfaces + *
  • ERROR_INVALID_CLASSID + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLCanvas (Composite parent, int style, GLData data) { + super (parent, style); + if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR (); + pfd.nSize = (short) PIXELFORMATDESCRIPTOR.sizeof; + pfd.nVersion = 1; + pfd.dwFlags = WGL.PFD_DRAW_TO_WINDOW | WGL.PFD_SUPPORT_OPENGL; + pfd.dwLayerMask = WGL.PFD_MAIN_PLANE; + pfd.iPixelType = (byte) WGL.PFD_TYPE_RGBA; + if (data.doubleBuffer) pfd.dwFlags |= WGL.PFD_DOUBLEBUFFER; + if (data.stereo) pfd.dwFlags |= WGL.PFD_STEREO; + pfd.cRedBits = (byte) data.redSize; + pfd.cGreenBits = (byte) data.greenSize; + pfd.cBlueBits = (byte) data.blueSize; + pfd.cAlphaBits = (byte) data.alphaSize; + pfd.cDepthBits = (byte) data.depthSize; + pfd.cStencilBits = (byte) data.stencilSize; + pfd.cAccumRedBits = (byte) data.accumRedSize; + pfd.cAccumGreenBits = (byte) data.accumGreenSize; + pfd.cAccumBlueBits = (byte) data.accumBlueSize; + pfd.cAccumAlphaBits = (byte) data.accumAlphaSize; + pfd.cAccumBits = (byte) (pfd.cAccumRedBits + pfd.cAccumGreenBits + pfd.cAccumBlueBits + pfd.cAccumAlphaBits); + //FIXME - use wglChoosePixelFormatARB +// if (data.sampleBuffers > 0) { +// wglAttrib [pos++] = WGL.WGL_SAMPLE_BUFFERS_ARB; +// wglAttrib [pos++] = data.sampleBuffers; +// } +// if (data.samples > 0) { +// wglAttrib [pos++] = WGL.WGL_SAMPLES_ARB; +// wglAttrib [pos++] = data.samples; +// } + + int hDC = OS.GetDC (handle); + pixelFormat = WGL.ChoosePixelFormat (hDC, pfd); + if (pixelFormat == 0) { + OS.ReleaseDC (handle, hDC); + SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH); + } + if (!WGL.SetPixelFormat (hDC, pixelFormat, pfd)) { + OS.ReleaseDC (handle, hDC); + SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH); + } + context = WGL.wglCreateContext (hDC); + if (context == 0) { + OS.ReleaseDC (handle, hDC); + SWT.error (SWT.ERROR_NO_HANDLES); + } + OS.ReleaseDC (handle, hDC); + //FIXME- share lists + //if (share != null) WGL.wglShareLists (context, share.context); + + Listener listener = new Listener () { + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Dispose: + WGL.wglDeleteContext (context); + break; + } + } + }; + addListener (SWT.Dispose, listener); +} + +/** + * Returns a GLData object describing the created context. + * + * @return GLData description of the OpenGL context attributes + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public GLData getGLData () { + checkWidget (); + GLData data = new GLData (); + PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR (); + pfd.nSize = (short) PIXELFORMATDESCRIPTOR.sizeof; + int hDC = OS.GetDC (handle); + WGL.DescribePixelFormat (hDC, pixelFormat, PIXELFORMATDESCRIPTOR.sizeof, pfd); + OS.ReleaseDC (handle, hDC); + data.doubleBuffer = (pfd.dwFlags & WGL.PFD_DOUBLEBUFFER) != 0; + data.stereo = (pfd.dwFlags & WGL.PFD_STEREO) != 0; + data.redSize = pfd.cRedBits; + data.greenSize = pfd.cGreenBits; + data.blueSize = pfd.cBlueBits; + data.alphaSize = pfd.cAlphaBits; + data.depthSize = pfd.cDepthBits; + data.stencilSize = pfd.cStencilBits; + data.accumRedSize = pfd.cAccumRedBits; + data.accumGreenSize = pfd.cAccumGreenBits; + data.accumBlueSize = pfd.cAccumBlueBits; + data.accumAlphaSize = pfd.cAccumAlphaBits; + return data; +} + +/** + * Returns a boolean indicating whether the receiver's OpenGL context + * is the current context. + * + * @return true if the receiver holds the current OpenGL context, + * false otherwise + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public boolean isCurrent () { + checkWidget (); + return WGL.wglGetCurrentContext () == handle; +} + +/** + * Sets the OpenGL context associated with this GLCanvas to be the + * current GL context. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void setCurrent () { + checkWidget (); + if (WGL.wglGetCurrentContext () == handle) return; + int hDC = OS.GetDC (handle); + WGL.wglMakeCurrent (hDC, context); + OS.ReleaseDC (handle, hDC); +} + +/** + * Swaps the front and back color buffers. + * + * @exception SWTException
    + *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
+ * + * WARNING API STILL UNDER CONSTRUCTION AND SUBJECT TO CHANGE + * + * @since 3.2 + */ +public void swapBuffers () { + checkWidget (); + int hDC = OS.GetDC (handle); + WGL.SwapBuffers (hDC); + OS.ReleaseDC (handle, hDC); +} +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak index fcb1dabccd..cb8c846325 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_linux.mak @@ -24,6 +24,7 @@ CAIRO_PREFIX = swt-cairo ATK_PREFIX = swt-atk GNOME_PREFIX = swt-gnome MOZILLA_PREFIX = swt-mozilla +GLX_PREFIX = swt-glx SWT_LIB = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so AWT_LIB = lib$(AWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so SWTPI_LIB = lib$(SWTPI_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so @@ -31,6 +32,7 @@ CAIRO_LIB = lib$(CAIRO_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so ATK_LIB = lib$(ATK_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so GNOME_LIB = lib$(GNOME_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so MOZILLA_LIB = lib$(MOZILLA_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so +GLX_LIB = lib$(GLX_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so CAIROCFLAGS = `pkg-config --cflags cairo` CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo @@ -47,6 +49,9 @@ ATKLIBS = `pkg-config --libs-only-L atk gtk+-2.0` -latk-1.0 -lgtk-x11-2.0 GNOMECFLAGS = `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` GNOMELIBS = `pkg-config --libs-only-L gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -lgnomevfs-2 -lgnome-2 -lgnomeui-2 +GLXCFLAGS = +GLXLIBS = -shared -fpic -fPIC -L/usr/X11R6/lib -lGL -lGLU -lm + # Uncomment for Native Stats tool #NATIVE_STATS = -DNATIVE_STATS @@ -74,6 +79,7 @@ CAIRO_OBJECTS = swt.o cairo.o cairo_structs.o cairo_stats.o ATK_OBJECTS = swt.o atk.o atk_structs.o atk_custom.o atk_stats.o GNOME_OBJECTS = swt.o gnome.o gnome_structs.o gnome_stats.o MOZILLA_OBJECTS = swt.o xpcom.o xpcom_custom.o xpcom_structs.o xpcom_stats.o +GLX_OBJECTS = swt.o glx.o glx_structs.o glx_stats.o CFLAGS = -O -Wall \ -DSWT_VERSION=$(SWT_VERSION) \ @@ -86,7 +92,7 @@ CFLAGS = -O -Wall \ LIBS = -shared -fpic -s -all: make_swt make_atk make_gnome make_awt +all: make_swt make_atk make_gnome make_awt make_glx # # SWT libs @@ -190,6 +196,23 @@ xpcom_custom.o: xpcom_custom.cpp xpcom_stats.o: xpcom_stats.cpp $(CXX) $(MOZILLACFLAGS) -c xpcom_stats.cpp +# +# GLX lib +# +make_glx: $(GLX_LIB) + +$(GLX_LIB): $(GLX_OBJECTS) + $(LD) $(LIBS) $(GLXLIBS) -o $(GLX_LIB) $(GLX_OBJECTS) + +glx.o: glx.c + $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx.c + +glx_structs.o: glx_structs.c + $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_structs.c + +glx_stats.o: glx_stats.c glx_stats.h + $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_stats.c + # # Install # diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak index 2040fc0436..6f844be482 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_linux.mak @@ -77,7 +77,13 @@ MOZILLACFLAGS = -O \ ${SWT_PTR_CFLAGS} MOZILLALIBS = -shared -s -Wl,--version-script=mozilla_exports -Bsymbolic ${GECKO_LIBS} -all: make_swt make_awt make_gnome make_gtk +GLX_PREFIX = swt-glx +GLX_LIB = lib$(GLX_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so +GLX_OBJECTS = swt.o glx.o glx_structs.o glx_stats.o +GLXCFLAGS = +GLXLIBS = -shared -fpic -fPIC -L/usr/X11R6/lib -lGL -lGLU -lm + +all: make_swt make_awt make_gnome make_gtk make_glx make_swt: $(SWT_LIB) @@ -148,6 +154,21 @@ xpcom_custom.o: xpcom_custom.cpp xpcom_stats.o: xpcom_stats.cpp $(CXX) $(MOZILLACFLAGS) -c xpcom_stats.cpp +make_glx: $(GLX_LIB) + +$(GLX_LIB): $(GLX_OBJECTS) + $(LD) $(LIBS) $(GLXLIBS) -o $(GLX_LIB) $(GLX_OBJECTS) + +glx.o: glx.c + $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx.c + +glx_structs.o: glx_structs.c + $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_structs.c + +glx_stats.o: glx_stats.c glx_stats.h + $(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_stats.c + + install: all cp *.so $(OUTPUT_DIR) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os.c index 94f1bafa59..e39c331bcb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os.c @@ -315,6 +315,18 @@ fail: } #endif +#ifndef NO__1XCreateColormap +JNIEXPORT jint JNICALL OS_NATIVE(_1XCreateColormap) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, _1XCreateColormap_FUNC); + rc = (jint)XCreateColormap(arg0, arg1, arg2, arg3); + OS_NATIVE_EXIT(env, that, _1XCreateColormap_FUNC); + return rc; +} +#endif + #ifndef NO__1XCreateFontCursor JNIEXPORT jint JNICALL OS_NATIVE(_1XCreateFontCursor) (JNIEnv *env, jclass that, jint arg0, jint arg1) @@ -767,6 +779,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1XFree) } #endif +#ifndef NO__1XFreeColormap +JNIEXPORT jint JNICALL OS_NATIVE(_1XFreeColormap) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, _1XFreeColormap_FUNC); + rc = (jint)XFreeColormap(arg0, arg1); + OS_NATIVE_EXIT(env, that, _1XFreeColormap_FUNC); + return rc; +} +#endif + #ifndef NO__1XFreeColors JNIEXPORT jint JNICALL OS_NATIVE(_1XFreeColors) (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3, jint arg4) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.c index dd4f01e2fb..0ddf82a86d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.c @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 459; -int OS_nativeFunctionCallCount[459]; +int OS_nativeFunctionCount = 461; +int OS_nativeFunctionCallCount[461]; char * OS_nativeFunctionNames[] = { "CODESET", "FD_1ISSET", @@ -43,6 +43,7 @@ char * OS_nativeFunctionNames[] = { "_1XCopyArea", "_1XCopyPlane", "_1XCreateBitmapFromData", + "_1XCreateColormap", "_1XCreateFontCursor", "_1XCreateGC", "_1XCreateImage", @@ -80,6 +81,7 @@ char * OS_nativeFunctionNames[] = { "_1XFlush", "_1XFontsOfFontSet", "_1XFree", + "_1XFreeColormap", "_1XFreeColors", "_1XFreeCursor", "_1XFreeFont", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.h index f34bdce37e..f9719ef8cc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/os_stats.h @@ -47,6 +47,7 @@ typedef enum { _1XCopyArea_FUNC, _1XCopyPlane_FUNC, _1XCreateBitmapFromData_FUNC, + _1XCreateColormap_FUNC, _1XCreateFontCursor_FUNC, _1XCreateGC_FUNC, _1XCreateImage_FUNC, @@ -84,6 +85,7 @@ typedef enum { _1XFlush_FUNC, _1XFontsOfFontSet_FUNC, _1XFree_FUNC, + _1XFreeColormap_FUNC, _1XFreeColors_FUNC, _1XFreeCursor_FUNC, _1XFreeFont_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java index cba80c6663..d1f519b626 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java @@ -52,6 +52,7 @@ public class OS extends Platform { /** Constants */ public static final int Above = 0; public static final int AllPlanes = 0xFFFFFFFF; + public static final int AllocNone = 0; public static final int Below = 1; public static final int Button1Mask = (1<<8); public static final int Button2Mask = (1<<9); @@ -68,6 +69,7 @@ public class OS extends Platform { public static final int Button5MotionMask = 1 << 12; public static final int CWBackPixmap = 0x1; public static final int CWBitGravity = 0x10; + public static final int CWColormap = 1 << 13; public static final int CWCursor = 0x4000; public static final int CWDontPropagate = 0x1000; public static final int CWEventMask = 0x800; @@ -575,6 +577,7 @@ public class OS extends Platform { public static final int XmNverifyBell = malloc ("verifyBell", 1); public static final int XmNverticalScrollBar = malloc ("verticalScrollBar", 4); public static final int XmNvisibleItemCount = malloc ("visibleItemCount", 4); + public static final int XmNvisual = malloc ("visual", 4); public static final int XmNUMERIC = 0x3; public static final int XmNwidth = malloc ("width", 2); public static final int XmNwordWrap = malloc ("wordWrap", 1); @@ -946,6 +949,15 @@ public static final int XCreateBitmapFromData(int display, int drawable, byte[] lock.unlock(); } } +public static final native int _XCreateColormap(int display, int window, int visual, int alloc); +public static final int XCreateColormap(int display, int window, int visual, int alloc) { + lock.lock(); + try { + return _XCreateColormap(display, window, visual, alloc); + } finally { + lock.unlock(); + } +} public static final native int _XCreateFontCursor(int display, int shape); public static final int XCreateFontCursor(int display, int shape) { lock.lock(); @@ -1279,6 +1291,15 @@ public static final int XFree(int address) { lock.unlock(); } } +public static final native int _XFreeColormap(int display, int colormap); +public static final int XFreeColormap(int display, int colormap) { + lock.lock(); + try { + return _XFreeColormap(display, colormap); + } finally { + lock.unlock(); + } +} public static final native int _XFreeColors(int display, int colormap, int[] pixels, int npixels, int planes); public static final int XFreeColors(int display, int colormap, int[] pixels, int npixels, int planes) { lock.lock(); diff --git a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF index e780d553bf..277be6e11a 100644 --- a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Export-Package: org.eclipse.swt.events, org.eclipse.swt.graphics, org.eclipse.swt.layout, + org.eclipse.swt.opengl, org.eclipse.swt.printing, org.eclipse.swt.program, org.eclipse.swt.widgets, -- cgit