diff options
author | Sven Gothel <[email protected]> | 2009-03-16 14:38:27 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-03-16 14:38:27 +0000 |
commit | 24fcece997ba911b0270033a357bbd83258d4f1a (patch) | |
tree | 4d01034154734897724d6a3b7738bf22693a8d36 /src/native/jogl | |
parent | 9517d52c18bfa93d78e03f4c212757eda421afb6 (diff) |
JOGL refactoring:
Refactored JOGL into 3 independent components.
1 NWI - Native windowing interface
Abstracts the the general NativeWindow interface and it's factory,
incl the basic JAWT and Xlib toolkit.
The latter was motivated to clean up the JOGL workspace,
and to allow other to reuse this part.
The generic core is nwi.core.jar, the AWT add-on is nwi.awt.jar.
2 JOGL - The OpenGL mapping
Further cleanup of the SPEC.
All non OpenGL toolkits are relocated to NWI and NEWT.
There is still openmax and the windows audio layer ..
Another cleanup of the fixed function pipeline emulation.
Moved utilities and implementations where they belong ..
Removed GLUnsupportedException.
Misc .. changes
3 NEWT - The new windowing toolkit
The generic NEWT, newt.core.jar.
The JOGL and AWT modules are seperate, newt.ogl.jar newt.awt.jar.
Their build can be switched off.
The modules source and builds resides in their own directory.
Because of their nature, they share the stub_includes, etc.
Each module has it's own ant build script
- build-nwi.xml
- build-jogl.xml
- build-newt.xml
They can be build at once using build.xml as ususal,
which just invokes the seperate build tasks.
if rootrel.build=build, then the build location is
jogl/build-nwi
jogl/build-jogl
jogl/build-newt
and the sources are under
jogl/src/nwi
jogl/src/jogl
jogl/src/newt
Tested: jogl-demos, d4; Linux, MacOsX; Nvidia
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1868 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/native/jogl')
-rw-r--r-- | src/native/jogl/ContextUpdater.h | 40 | ||||
-rw-r--r-- | src/native/jogl/ContextUpdater.m | 83 | ||||
-rwxr-xr-x | src/native/jogl/EGLDrawableFactory.c | 319 | ||||
-rw-r--r-- | src/native/jogl/InternalBufferUtils.c | 78 | ||||
-rw-r--r-- | src/native/jogl/JAWT_DrawingSurfaceInfo.c | 65 | ||||
-rw-r--r-- | src/native/jogl/MacOSXWindowSystemInterface.m | 702 | ||||
-rwxr-xr-x | src/native/jogl/Mixer.cpp | 199 | ||||
-rw-r--r-- | src/native/jogl/Xinerama.c | 316 | ||||
-rw-r--r-- | src/native/jogl/Xinerama.h | 76 | ||||
-rw-r--r-- | src/native/jogl/XineramaHelper.c | 126 | ||||
-rw-r--r-- | src/native/jogl/extutil.h | 222 | ||||
-rw-r--r-- | src/native/jogl/panoramiXext.h | 54 | ||||
-rw-r--r-- | src/native/jogl/panoramiXproto.h | 196 |
13 files changed, 0 insertions, 2476 deletions
diff --git a/src/native/jogl/ContextUpdater.h b/src/native/jogl/ContextUpdater.h deleted file mode 100644 index e8b757fac..000000000 --- a/src/native/jogl/ContextUpdater.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - -Listens to NSViewGlobalFrameDidChangeNotification - -This notification is sent whenever an NSView that has an attached NSSurface changes size or changes screens (thus potentially changing graphics hardware drivers.) - -*/ - -#import <Cocoa/Cocoa.h> -#import <Foundation/Foundation.h> -#import <AppKit/NSView.h> -#import <OpenGL/OpenGL.h> -#import <OpenGL/gl.h> - -//#define DEBUG_GL_LOCKS - -#ifdef DEBUG_GL_LOCKS - #define LOCK_GL(func, line) [ContextUpdater lockInFunction:func atLine:line]; - #define UNLOCK_GL(func, line) [ContextUpdater unlockInFunction:func atLine:line]; -#else - #define LOCK_GL(func, line) [ContextUpdater lock]; - #define UNLOCK_GL(func, line) [ContextUpdater unlock]; -#endif - -// gznote: OpenGL NOT thread safe - need to sync on update and paints - -@interface ContextUpdater : NSObject -{ -} - -+ (void) lock; -+ (void) lockInFunction:(char *)func atLine:(int)line; -+ (void) unlock; -+ (void) unlockInFunction:(char *)func atLine:(int)line; - -- (void) registerFor:(NSOpenGLContext *)context with: (NSView *)window; - -- (void) update:(NSNotification *)notification; - -@end diff --git a/src/native/jogl/ContextUpdater.m b/src/native/jogl/ContextUpdater.m deleted file mode 100644 index 587782c98..000000000 --- a/src/native/jogl/ContextUpdater.m +++ /dev/null @@ -1,83 +0,0 @@ -#import "ContextUpdater.h" -#import <pthread.h> - -@implementation ContextUpdater -{ -} - -static NSOpenGLContext *theContext; -static pthread_mutex_t resourceLock = PTHREAD_MUTEX_INITIALIZER; - -static void printLockDebugInfo(char *message, char *func, int line) -{ - fprintf(stderr, "%s in function: \"%s\" at line: %d\n", message, func, line); - fflush(stderr); -} - -+ (void) lock -{ - if (theContext != NULL) - { - pthread_mutex_lock(&resourceLock); - } -} - -+ (void) lockInFunction:(char *)func atLine:(int)line -{ - if (theContext != NULL) - { - printLockDebugInfo("locked ", func, line); - [self lock]; - } -} - -+ (void) unlock -{ - if (theContext != NULL) - { - pthread_mutex_unlock(&resourceLock); - } -} - -+ (void) unlockInFunction:(char *)func atLine:(int)line -{ - if (theContext != NULL) - { - printLockDebugInfo("unlocked", func, line); - [self unlock]; - } -} - -- (void) registerFor:(NSOpenGLContext *)context with: (NSView *)view -{ - if (view != NULL) - { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update:) name:NSViewGlobalFrameDidChangeNotification object: view]; - theContext = context; - } -} - -- (void) update:(NSNotification *)notification -{ - [ContextUpdater lock]; - - [theContext update]; - - [ContextUpdater unlock]; -} - -- (id) init -{ - theContext = NULL; - - return [super init]; -} - -- (void) dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [super dealloc]; -} - -@end
\ No newline at end of file diff --git a/src/native/jogl/EGLDrawableFactory.c b/src/native/jogl/EGLDrawableFactory.c deleted file mode 100755 index 41e0f67e1..000000000 --- a/src/native/jogl/EGLDrawableFactory.c +++ /dev/null @@ -1,319 +0,0 @@ -#include <EGL/egl.h> -#include <KD/kd.h> -#include <KD/NV_extwindowprops.h> -#include "com_sun_opengl_impl_egl_EGLDrawableFactory.h" - -// FIXME: move the glViewport call up to Java -#include <GLES/gl.h> - -static EGLDisplay display = NULL; -static EGLSurface surface = NULL; -static EGLContext context = NULL; -static EGLConfig config = NULL; -static KDWindow* window = NULL; -static EGLNativeWindowType nativewin = NULL; -static EGLint lastWidth = 0; -static EGLint lastHeight = 0; - -// FIXME: need to move this up to Java to conditionalize between ES 1 and ES 2 -//static KDint nv_egl_renderable_flags = EGL_OPENGL_ES2_BIT; -static KDint nv_egl_renderable_flags = EGL_OPENGL_ES_BIT; -static KDint nv_egl_surface_flags = EGL_WINDOW_BIT; -static KDust jogPressUST = 0; - -typedef struct -{ - KDint index; - KDboolean wasPressed; - KDust pressTime; -} DeviceButtonState; -#define NVM_BTNS_MAX 5 -typedef enum -{ - NVM_BTN_JOGDIAL, - NVM_BTN_WIDGET, - NVM_BTN_BACK, - NVM_BTN_CAMHALF, - NVM_BTN_CAMFULL, -}; -DeviceButtonState conButtons[NVM_BTNS_MAX] = -{ - {KD_INPUT_JOGDIAL_SELECT, 0, 0}, - {KD_INPUT_BUTTONS_0+0, 0, 0}, - {KD_INPUT_BUTTONS_0+1, 0, 0}, - {KD_INPUT_BUTTONS_0+2, 0, 0}, - {KD_INPUT_BUTTONS_0+3, 0, 0}, -}; - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_initEGL - (JNIEnv *env, jobject unused) -{ - display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (display == EGL_NO_DISPLAY) { - kdLogMessage("Error - EGL get display failed\n"); - return JNI_FALSE; - } - if (!eglInitialize(display, 0, 0)) { - kdLogMessage("Error - EGL init failed\n"); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_chooseConfig - (JNIEnv *env, jobject unused) -{ - #define MAX_CONFIGS 64 - EGLConfig confs[MAX_CONFIGS]; - EGLint numConfigs; - EGLint fbAttrs[] = - { -/* - // FIXME - // OpenGL ES 2 settings - EGL_RENDERABLE_TYPE, nv_egl_renderable_flags, - EGL_DEPTH_SIZE, 16, - EGL_SURFACE_TYPE, nv_egl_surface_flags, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_ALPHA_SIZE, 0, - EGL_NONE -*/ - -/* - // FIXME - // OpenGL ES 1 settings - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_ALPHA_SIZE, EGL_DONT_CARE, - EGL_DEPTH_SIZE, 1, - EGL_STENCIL_SIZE, EGL_DONT_CARE, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, - EGL_NONE -*/ - - // FIXME - // OpenGL ES 1 settings - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, - EGL_DEPTH_SIZE, 16, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_ALPHA_SIZE, 0, - EGL_NONE - }; - - if (!(eglChooseConfig(display, fbAttrs, confs, MAX_CONFIGS, &numConfigs) && numConfigs)) { - kdLogMessage("Error - EGL choose config failed\n"); - return JNI_FALSE; - } - /* Use the first */ - config = confs[0]; - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_checkDisplay - (JNIEnv *env, jobject unused) -{ - if (display == NULL) { - kdLogMessage("Error - EGL get display returned null\n"); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_checkConfig - (JNIEnv *env, jobject unused) -{ - if (config == NULL) { - kdLogMessage("Error - EGL choose config returned null\n"); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_createWindow - (JNIEnv *env, jobject unused) -{ - window = kdCreateWindow(display, config, KD_NULL); - if (!window) { - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT void JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_setWindowVisible - (JNIEnv *env, jobject unused) -{ - KDboolean visible = KD_TRUE; - kdSetWindowPropertybv(window, - KD_WINDOWPROPERTY_VISIBILITY, &visible); -} - -JNIEXPORT void JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_setWindowFullscreen - (JNIEnv *env, jobject unused) -{ - KDboolean fullscreen = KD_TRUE; - kdSetWindowPropertybv(window, - KD_WINDOWPROPERTY_FULLSCREEN_NV, &fullscreen); -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_realizeWindow - (JNIEnv *env, jobject unused) -{ - if (kdRealizeWindow(window, &nativewin) != 0) { - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_createSurface - (JNIEnv *env, jobject unused) -{ - surface = eglCreateWindowSurface(display, - config, nativewin, 0); - if (!surface) - { - kdLogMessage("Error - EGL create window surface failed\n"); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_createContext - (JNIEnv *env, jobject unused) -{ - /*a - static EGLint contextAttrs[] = - { - // FIXME - // OpenGL ES 2 settings - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - */ - - const EGLint contextAttrs[] = - { - // FIXME - // OpenGL ES 1 settings - EGL_CONTEXT_CLIENT_VERSION, 1, - EGL_NONE - }; - - context = eglCreateContext(display, - config, 0, contextAttrs); - if (!context) - { - kdLogMessage("Error - EGL create context failed\n"); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_makeCurrent - (JNIEnv *env, jobject unused) -{ - if (!eglMakeCurrent(display, surface, surface, context)) - { - kdLogMessage("Error - EGL make current failed\n"); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT void JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_updateWindowSize - (JNIEnv *env, jobject unused) -{ - EGLint drawWidth; - EGLint drawHeight; - - eglQuerySurface(display, surface, EGL_WIDTH, &drawWidth); - eglQuerySurface(display, surface, EGL_HEIGHT, &drawHeight); - if ((lastWidth != drawWidth) || (lastHeight != drawHeight)) - { - glViewport(0, 0, drawWidth, drawHeight); - lastWidth = drawWidth; - lastHeight = drawHeight; - } -} - -JNIEXPORT void JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_swapBuffers0 - (JNIEnv *env, jobject unused) -{ - eglSwapBuffers(display, surface); -} - -JNIEXPORT jboolean JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_shouldExit - (JNIEnv *env, jobject unused) -{ - const KDEvent* ev = NULL; - do { - ev = kdWaitEvent(0); - if (ev != 0) { - switch (ev->type) { - case KD_EVENT_WINDOW_CLOSE: - case KD_EVENT_QUIT: - return JNI_TRUE; - default: - break; - /* - case KD_EVENT_INPUT: - { - if (!s_runningInLauncher) - { - int btn; - for (btn=0; btn<NVM_BTNS_MAX; btn++) - { - if (InputDown(ev, conButtons[btn].index)) - { - if (!conButtons[btn].wasPressed) - { - conButtons[btn].pressTime = ev->timestamp; - conButtons[btn].wasPressed = KD_TRUE; - } - } - else - { - conButtons[btn].wasPressed = KD_FALSE; - } - } - } - break; - } - */ - } - } - } while (ev != 0); - return JNI_FALSE; -} - -JNIEXPORT void JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_shutdown - (JNIEnv *env, jobject unused) -{ - if (context) { - eglMakeCurrent(display, - EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglDestroyContext(display, context); - context = EGL_NO_CONTEXT; - } - if (surface) { - eglDestroySurface(display, surface); - surface = EGL_NO_SURFACE; - } - kdDestroyWindow(window); - if (display) { - eglTerminate(display); - display = EGL_NO_DISPLAY; - } -} - -JNIEXPORT jint JNICALL Java_com_sun_opengl_impl_egl_EGLDrawableFactory_getDirectBufferAddress - (JNIEnv *env, jobject unused, jobject buffer) -{ - return (jint) (*env)->GetDirectBufferAddress(env, buffer); -} diff --git a/src/native/jogl/InternalBufferUtils.c b/src/native/jogl/InternalBufferUtils.c deleted file mode 100644 index 4b2001a34..000000000 --- a/src/native/jogl/InternalBufferUtils.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -#include <jni.h> - -#ifdef _WIN32 - #ifdef _MSC_VER - /* This typedef is apparently needed for Microsoft compilers before VC8, - and on Windows CE */ - #if (_MSC_VER < 1400) || defined(UNDER_CE) - #ifdef _WIN64 - typedef long long intptr_t; - #else - typedef int intptr_t; - #endif - #endif - #else - #include <inttypes.h> - #endif -#else - #include <inttypes.h> -#endif - -JNIEXPORT jobject JNICALL -Java_com_sun_opengl_impl_InternalBufferUtils_newDirectByteBuffer(JNIEnv* env, jclass unused, jlong address, jint capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) address, capacity); -} - -#if defined(__sun) || defined(_HPUX) -#include <dlfcn.h> - -/* HP-UX doesn't define RTLD_DEFAULT. */ -#if defined(_HPUX) && !defined(RTLD_DEFAULT) -#define RTLD_DEFAULT NULL -#endif - -/* Sun's GLX implementation doesn't have glXGetProcAddressARB (or - glXGetProcAddress) so we implement it here */ -void (*glXGetProcAddressARB(const char *procname))() { - return (void (*)()) dlsym(RTLD_DEFAULT, procname); -} -#endif /* __ sun || _HPUX */ diff --git a/src/native/jogl/JAWT_DrawingSurfaceInfo.c b/src/native/jogl/JAWT_DrawingSurfaceInfo.c deleted file mode 100644 index db933a50e..000000000 --- a/src/native/jogl/JAWT_DrawingSurfaceInfo.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -#include <jawt_md.h> - -#ifdef WIN32 - #define PLATFORM_DSI_SIZE sizeof(JAWT_Win32DrawingSurfaceInfo) -#elif defined(linux) || defined(__sun) || defined(__FreeBSD__) || defined(_HPUX) - #define PLATFORM_DSI_SIZE sizeof(JAWT_X11DrawingSurfaceInfo) -#elif defined(macosx) - #define PLATFORM_DSI_SIZE sizeof(JAWT_MacOSXDrawingSurfaceInfo) -#else - ERROR: port JAWT_DrawingSurfaceInfo.c to your platform -#endif - -JNIEXPORT jobject JNICALL -Java_com_sun_opengl_impl_jawt_JAWT_1DrawingSurfaceInfo_platformInfo0(JNIEnv* env, jobject unused, jobject jthis0) { - JAWT_DrawingSurfaceInfo* dsi; - dsi = (*env)->GetDirectBufferAddress(env, jthis0); - if (dsi == NULL) { - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Argument \"jthis0\" was not a direct buffer"); - return NULL; - } - if (dsi->platformInfo == NULL) { - return NULL; - } - return (*env)->NewDirectByteBuffer(env, dsi->platformInfo, PLATFORM_DSI_SIZE); -} diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m deleted file mode 100644 index 350f6152f..000000000 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ /dev/null @@ -1,702 +0,0 @@ -/* Note: usage of AvailabilityMacros.h to detect whether we're - building on OS X 10.3 does not work because the header #defines - MAC_OS_X_VERSION_10_4 even though the machine is a 10.3 machine - -#include <AvailabilityMacros.h> - -#ifndef MAC_OS_X_VERSION_10_3 - #error building JOGL requires Mac OS X 10.3 or greater -#endif - -#ifndef MAC_OS_X_VERSION_10_4 - #define NSOpenGLPFAColorFloat kCGLPFAColorFloat - #define kCGLNoError 0 -#endif -*/ - -#import <Cocoa/Cocoa.h> -#import <OpenGL/gl.h> -#import <OpenGL/CGLTypes.h> -#import <jni.h> -#import "ContextUpdater.h" - -#import "macosx-window-system.h" - -// see MacOSXPbufferGLContext.java createPbuffer -#define USE_GL_TEXTURE_RECTANGLE_EXT - -#ifdef USE_GL_TEXTURE_RECTANGLE_EXT - #ifndef GL_TEXTURE_RECTANGLE_EXT - #define GL_TEXTURE_RECTANGLE_EXT 0x84F5 - #endif -#endif - -// Workarounds for compiling on 10.3 -#ifndef kCGLRGBA16161616Bit -#define kCGLRGBA16161616Bit 0x00800000 /* 64 argb bit/pixel, R=63:48, G=47:32, B=31:16, A=15:0 */ -#define kCGLRGBFloat64Bit 0x01000000 /* 64 rgb bit/pixel, half float */ -#define kCGLRGBAFloat64Bit 0x02000000 /* 64 argb bit/pixel, half float */ -#define kCGLRGBFloat128Bit 0x04000000 /* 128 rgb bit/pixel, ieee float */ -#define kCGLRGBAFloat128Bit 0x08000000 /* 128 argb bit/pixel, ieee float */ -#define kCGLRGBFloat256Bit 0x10000000 /* 256 rgb bit/pixel, ieee double */ -#define kCGLRGBAFloat256Bit 0x20000000 /* 256 argb bit/pixel, ieee double */ -#endif - -struct _RendererInfo -{ - long id; // kCGLRPRendererID - long displayMask; // kCGLRPDisplayMask - - long accelerated; // kCGLRPAccelerated - - long window; // kCGLRPWindow - long fullscreen; // kCGLRPFullScreen - long multiscreen; // kCGLRPMultiScreen - long offscreen; // kCGLRPOffScreen - long floatPixels; // see kCGLRPColorModes - long stereo; // kCGLRPBufferModes - - long auxBuffers; // kCGLRPMaxAuxBuffers - long sampleBuffers; // kCGLRPMaxSampleBuffers - long samples; // kCGLRPMaxSamples - long samplesModes; // kCGLRPSampleModes - long multiSample; // see kCGLRPSampleModes - long superSample; // see kCGLRPSampleModes - long alphaSample; // kCGLRPSampleAlpha - - long colorModes; // kCGLRPColorModes - long colorRGBSizeMAX; - long colorASizeMAX; - long colorFloatRGBSizeMAX; - long colorFloatASizeMAX; - long colorFloatRGBSizeMIN; - long colorFloatASizeMIN; - long colorModesCount; - long colorFloatModesCount; - long depthModes; // kCGLRPDepthModes - long depthSizeMAX; - long depthModesCount; - long stencilModes; // kCGLRPStencilModes - long stencilSizeMAX; - long stencilModesCount; - long accumModes; // kCGLRPAccumModes - long accumRGBSizeMAX; - long accumASizeMAX; - long accumModesCount; -} -typedef RendererInfo; - -RendererInfo *gRenderers = NULL; -long gRenderersCount = 0; - -long depthModes[] = { - kCGL0Bit, - kCGL1Bit, - kCGL2Bit, - kCGL3Bit, - kCGL4Bit, - kCGL5Bit, - kCGL6Bit, - kCGL8Bit, - kCGL10Bit, - kCGL12Bit, - kCGL16Bit, - kCGL24Bit, - kCGL32Bit, - kCGL48Bit, - kCGL64Bit, - kCGL96Bit, - kCGL128Bit, - 0 - }; -long depthModesBits[] = {0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 24, 32, 48, 64, 96, 128}; -long colorModes[] = { - kCGLRGB444Bit, - kCGLARGB4444Bit, - kCGLRGB444A8Bit, - kCGLRGB555Bit, - kCGLARGB1555Bit, - kCGLRGB555A8Bit, - kCGLRGB565Bit, - kCGLRGB565A8Bit, - kCGLRGB888Bit, - kCGLARGB8888Bit, - kCGLRGB888A8Bit, - kCGLRGB101010Bit, - kCGLARGB2101010Bit, - kCGLRGB101010_A8Bit, - kCGLRGB121212Bit, - kCGLARGB12121212Bit, - kCGLRGB161616Bit, - kCGLRGBA16161616Bit, - kCGLRGBFloat64Bit, - kCGLRGBAFloat64Bit, - kCGLRGBFloat128Bit, - kCGLRGBAFloat128Bit, - kCGLRGBFloat256Bit, - kCGLRGBAFloat256Bit, - 0 - }; -long colorModesBitsRGB[] = {4, 4, 4, 5, 5, 5, 5, 5, 8, 8, 8, 10, 10, 10, 12, 12, 16, 16, 16, 16, 32, 32, 64, 64}; -long colorModesBitsA[] = {0, 4, 8, 0, 1, 8, 0, 8, 0, 8, 8, 0, 2, 8, 0, 12, 0, 16, 0, 16, 0, 32, 0, 64}; - -void getRendererInfo() -{ - if (gRenderersCount == 0) - { - CGLRendererInfoObj info; - CGLError err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), &info, &gRenderersCount); - if (err == 0 /* kCGLNoError */) - { - // how many renderers are available? - CGLDescribeRenderer(info, 0, kCGLRPRendererCount, &gRenderersCount); - - // allocate our global renderers info - gRenderers = (RendererInfo*)malloc(gRenderersCount*sizeof(RendererInfo)); - memset(gRenderers, 0x00, gRenderersCount*sizeof(RendererInfo)); - - // iterate through the renderers checking for their features - long j; - for (j=0; j<gRenderersCount; j++) - { - RendererInfo *renderer = &gRenderers[j]; - int i; - - CGLDescribeRenderer(info, j, kCGLRPRendererID, &(renderer->id)); - CGLDescribeRenderer(info, j, kCGLRPDisplayMask, &(renderer->displayMask)); - - CGLDescribeRenderer(info, j, kCGLRPAccelerated, &(renderer->accelerated)); - - CGLDescribeRenderer(info, j, kCGLRPWindow, &(renderer->window)); - CGLDescribeRenderer(info, j, kCGLRPFullScreen, &(renderer->fullscreen)); - CGLDescribeRenderer(info, j, kCGLRPMultiScreen, &(renderer->multiscreen)); - CGLDescribeRenderer(info, j, kCGLRPOffScreen, &(renderer->offscreen)); - CGLDescribeRenderer(info, j, kCGLRPColorModes, &(renderer->floatPixels)); - if ((renderer->floatPixels >= kCGLRGBFloat64Bit) != 0) - { - renderer->floatPixels = 1; - } - else - { - renderer->floatPixels = 0; - } - CGLDescribeRenderer(info, j, kCGLRPBufferModes, &(renderer->stereo)); - if ((renderer->stereo & kCGLStereoscopicBit) != 0) - { - renderer->stereo = 1; - } - else - { - renderer->stereo = 0; - } - - CGLDescribeRenderer(info, j, kCGLRPMaxAuxBuffers, &(renderer->auxBuffers)); - CGLDescribeRenderer(info, j, kCGLRPMaxSampleBuffers, &(renderer->sampleBuffers)); - CGLDescribeRenderer(info, j, kCGLRPMaxSamples, &(renderer->samples)); - // The following queries are only legal on 10.4 - // FIXME: should figure out a way to enable them dynamically -#ifdef kCGLRPSampleModes - CGLDescribeRenderer(info, j, kCGLRPSampleModes, &(renderer->samplesModes)); - if ((renderer->samplesModes & kCGLSupersampleBit) != 0) - { - renderer->multiSample = 1; - } - if ((renderer->samplesModes & kCGLMultisampleBit) != 0) - { - renderer->superSample = 1; - } - CGLDescribeRenderer(info, j, kCGLRPSampleAlpha, &(renderer->alphaSample)); -#endif - CGLDescribeRenderer(info, j, kCGLRPColorModes, &(renderer->colorModes)); - i=0; - int floatPixelFormatInitialized = 0; - while (colorModes[i] != 0) - { - if ((renderer->colorModes & colorModes[i]) != 0) - { - // non-float color model - if (colorModes[i] < kCGLRGBFloat64Bit) - { - // look for max color and alpha values - prefer color models that have alpha - if ((colorModesBitsRGB[i] >= renderer->colorRGBSizeMAX) && (colorModesBitsA[i] >= renderer->colorASizeMAX)) - { - renderer->colorRGBSizeMAX = colorModesBitsRGB[i]; - renderer->colorASizeMAX = colorModesBitsA[i]; - } - renderer->colorModesCount++; - } - // float-color model - if (colorModes[i] >= kCGLRGBFloat64Bit) - { - if (floatPixelFormatInitialized == 0) - { - floatPixelFormatInitialized = 1; - - renderer->colorFloatASizeMAX = colorModesBitsA[i]; - renderer->colorFloatRGBSizeMAX = colorModesBitsRGB[i]; - renderer->colorFloatASizeMIN = colorModesBitsA[i]; - renderer->colorFloatRGBSizeMIN = colorModesBitsRGB[i]; - } - // look for max color and alpha values - prefer color models that have alpha - if ((colorModesBitsRGB[i] >= renderer->colorFloatRGBSizeMAX) && (colorModesBitsA[i] >= renderer->colorFloatASizeMAX)) - { - renderer->colorFloatRGBSizeMAX = colorModesBitsRGB[i]; - renderer->colorFloatASizeMAX = colorModesBitsA[i]; - } - // find min color - if (colorModesBitsA[i] < renderer->colorFloatASizeMIN) - { - renderer->colorFloatASizeMIN = colorModesBitsA[i]; - } - // find min alpha color - if (colorModesBitsA[i] < renderer->colorFloatRGBSizeMIN) - { - renderer->colorFloatRGBSizeMIN = colorModesBitsRGB[i]; - } - renderer->colorFloatModesCount++; - } - } - i++; - } - CGLDescribeRenderer(info, j, kCGLRPDepthModes, &(renderer->depthModes)); - i=0; - while (depthModes[i] != 0) - { - if ((renderer->depthModes & depthModes[i]) != 0) - { - renderer->depthSizeMAX = depthModesBits[i]; - renderer->depthModesCount++; - } - i++; - } - CGLDescribeRenderer(info, j, kCGLRPStencilModes, &(renderer->stencilModes)); - i=0; - while (depthModes[i] != 0) - { - if ((renderer->stencilModes & depthModes[i]) != 0) - { - renderer->stencilSizeMAX = depthModesBits[i]; - renderer->stencilModesCount++; - } - i++; - } - CGLDescribeRenderer(info, j, kCGLRPAccumModes, &(renderer->accumModes)); - i=0; - while (colorModes[i] != 0) - { - if ((renderer->accumModes & colorModes[i]) != 0) - { - if ((colorModesBitsRGB[i] >= renderer->accumRGBSizeMAX) && (colorModesBitsA[i] >= renderer->accumASizeMAX)) - { - renderer->accumRGBSizeMAX = colorModesBitsRGB[i]; - renderer->accumASizeMAX = colorModesBitsA[i]; - } - renderer->accumModesCount++; - } - i++; - } - } - } - CGLDestroyRendererInfo (info); - } - -#if 0 - fprintf(stderr, "gRenderersCount=%ld\n", gRenderersCount); - int j; - for (j=0; j<gRenderersCount; j++) - { - RendererInfo *renderer = &gRenderers[j]; - fprintf(stderr, " id=%ld\n", renderer->id); - fprintf(stderr, " displayMask=%ld\n", renderer->displayMask); - - fprintf(stderr, " accelerated=%ld\n", renderer->accelerated); - - fprintf(stderr, " window=%ld\n", renderer->window); - fprintf(stderr, " fullscreen=%ld\n", renderer->fullscreen); - fprintf(stderr, " multiscreen=%ld\n", renderer->multiscreen); - fprintf(stderr, " offscreen=%ld\n", renderer->offscreen); - fprintf(stderr, " floatPixels=%ld\n", renderer->floatPixels); - fprintf(stderr, " stereo=%ld\n", renderer->stereo); - - fprintf(stderr, " auxBuffers=%ld\n", renderer->auxBuffers); - fprintf(stderr, " sampleBuffers=%ld\n", renderer->sampleBuffers); - fprintf(stderr, " samples=%ld\n", renderer->samples); - fprintf(stderr, " samplesModes=%ld\n", renderer->samplesModes); - fprintf(stderr, " multiSample=%ld\n", renderer->superSample); - fprintf(stderr, " superSample=%ld\n", renderer->superSample); - fprintf(stderr, " alphaSample=%ld\n", renderer->alphaSample); - - fprintf(stderr, " colorModes=%ld\n", renderer->colorModes); - fprintf(stderr, " colorRGBSizeMAX=%ld\n", renderer->colorRGBSizeMAX); - fprintf(stderr, " colorASizeMAX=%ld\n", renderer->colorASizeMAX); - fprintf(stderr, " colorFloatRGBSizeMAX=%ld\n", renderer->colorFloatRGBSizeMAX); - fprintf(stderr, " colorFloatASizeMAX=%ld\n", renderer->colorFloatASizeMAX); - fprintf(stderr, " colorFloatRGBSizeMIN=%ld\n", renderer->colorFloatRGBSizeMIN); - fprintf(stderr, " colorFloatASizeMIN=%ld\n", renderer->colorFloatASizeMIN); - fprintf(stderr, " colorModesCount=%ld\n", renderer->colorModesCount); - fprintf(stderr, " colorFloatModesCount=%ld\n", renderer->colorFloatModesCount); - fprintf(stderr, " depthModes=%ld\n", renderer->depthModes); - fprintf(stderr, " depthSizeMAX=%ld\n", renderer->depthSizeMAX); - fprintf(stderr, " depthModesCount=%ld\n", renderer->depthModesCount); - fprintf(stderr, " stencilModes=%ld\n", renderer->stencilModes); - fprintf(stderr, " stencilSizeMAX=%ld\n", renderer->stencilSizeMAX); - fprintf(stderr, " stencilModesCount=%ld\n", renderer->stencilModesCount); - fprintf(stderr, " accumModes=%ld\n", renderer->accumModes); - fprintf(stderr, " accumRGBSizeMAX=%ld\n", renderer->accumRGBSizeMAX); - fprintf(stderr, " accumASizeMAX=%ld\n", renderer->accumASizeMAX); - fprintf(stderr, " accumModesCount=%ld\n", renderer->accumModesCount); - fprintf(stderr, "\n"); - } -#endif -} - -long validateParameter(NSOpenGLPixelFormatAttribute attribute, long value) -{ - int i; - for (i=0; i<gRenderersCount; i++) { - RendererInfo* renderer = &gRenderers[i]; - if (renderer->accelerated != 0) { - switch (attribute) { - case NSOpenGLPFAStereo: - return renderer->stereo; - - case NSOpenGLPFAStencilSize: - return MIN(value, renderer->stencilSizeMAX); - - default: - break; - } - } - } - - return value; -} - -void* createPixelFormat(int* iattrs, int niattrs, int* ivalues) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - getRendererInfo(); - - // http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenGLPixelFormat.html - NSOpenGLPixelFormatAttribute attribs[256]; - - int idx = 0; - int i; - for (i = 0; i < niattrs; i++) { - int attr = iattrs[i]; - switch (attr) { - case NSOpenGLPFAPixelBuffer: - if (ivalues[i] != 0) { - attribs[idx++] = NSOpenGLPFAPixelBuffer; - } - break; - - case kCGLPFAColorFloat: - if (ivalues[i] != 0) { - attribs[idx++] = kCGLPFAColorFloat; - } - break; - - case NSOpenGLPFADoubleBuffer: - if (ivalues[i] != 0) { - attribs[idx++] = NSOpenGLPFADoubleBuffer; - } - break; - - case NSOpenGLPFAStereo: - if (ivalues[i] != 0 && (validateParameter(NSOpenGLPFAStereo, 0 /* dummy */) != 0)) { - attribs[idx++] = NSOpenGLPFAStereo; - } - break; - - case NSOpenGLPFAColorSize: - case NSOpenGLPFAAlphaSize: - case NSOpenGLPFADepthSize: - case NSOpenGLPFAAccumSize: - case NSOpenGLPFASampleBuffers: - case NSOpenGLPFASamples: - attribs[idx++] = attr; - attribs[idx++] = ivalues[i]; - break; - - case NSOpenGLPFAStencilSize: - attribs[idx++] = attr; - attribs[idx++] = validateParameter(NSOpenGLPFAStencilSize, ivalues[i]); - break; - - default: - // Need better way to signal to caller - return nil; - } - } - - // Zero-terminate - attribs[idx++] = 0; - - NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; - if (fmt == nil) { - // should we fallback to defaults or not? - fmt = [NSOpenGLView defaultPixelFormat]; - } - - [pool release]; - return fmt; -} - -void queryPixelFormat(void* pixelFormat, int* iattrs, int niattrs, int* ivalues) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSOpenGLPixelFormat* fmt = (NSOpenGLPixelFormat*) pixelFormat; - long tmp; - // FIXME: think about how specifying this might affect the API - int virtualScreen = 0; - - int i; - for (i = 0; i < niattrs; i++) { - [fmt getValues: &tmp - forAttribute: (NSOpenGLPixelFormatAttribute) iattrs[i] - forVirtualScreen: virtualScreen]; - ivalues[i] = (int) tmp; - } - [pool release]; -} - -void deletePixelFormat(void* pixelFormat) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSOpenGLPixelFormat* fmt = (NSOpenGLPixelFormat*) pixelFormat; - [fmt release]; - [pool release]; -} - -void* createContext(void* shareContext, - void* view, - void* pixelFormat, - int* viewNotReady) -{ - getRendererInfo(); - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NSView *nsView = (NSView*)view; - - if (nsView != NULL) - { - Bool viewReady = true; - - if ([nsView lockFocusIfCanDraw] == NO) - { - viewReady = false; - } - else - { - NSRect frame = [nsView frame]; - if ((frame.size.width == 0) || (frame.size.height == 0)) - { - [nsView unlockFocus]; - viewReady = false; - } - } - - if (!viewReady) - { - if (viewNotReady != NULL) - { - *viewNotReady = 1; - } - - // the view is not ready yet - [pool release]; - return NULL; - } - } - - NSOpenGLContext* nsContext = [[NSOpenGLContext alloc] - initWithFormat: (NSOpenGLPixelFormat*) pixelFormat - shareContext: (NSOpenGLContext*) shareContext]; - - if (nsContext != nil) { - if (nsView != nil) { - [nsContext setView:nsView]; - [nsView unlockFocus]; - } - } - - [pool release]; - return nsContext; -} - -Bool makeCurrentContext(void* context) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [nsContext makeCurrentContext]; - [pool release]; - return true; -} - -Bool clearCurrentContext(void* context) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [NSOpenGLContext clearCurrentContext]; - [pool release]; - return true; -} - -Bool deleteContext(void* context) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [nsContext clearDrawable]; - [nsContext release]; - [pool release]; - return true; -} - -Bool flushBuffer(void* context) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [nsContext flushBuffer]; - [pool release]; - return true; -} - -void setContextOpacity(void* context, int opacity) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - - [nsContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity]; -} - -void updateContext(void* context) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [nsContext update]; - [pool release]; -} - -void copyContext(void* destContext, void* srcContext, int mask) { - NSOpenGLContext *src = (NSOpenGLContext*) srcContext; - NSOpenGLContext *dst = (NSOpenGLContext*) destContext; - [dst copyAttributesFromContext: src withMask: mask]; -} - -void* updateContextRegister(void* context, void* view) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - NSView *nsView = (NSView*)view; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - ContextUpdater *contextUpdater = [[ContextUpdater alloc] init]; - [contextUpdater registerFor:nsContext with:nsView]; - [pool release]; - return NULL; -} - -void updateContextUnregister(void* context, void* view, void* updater) { - ContextUpdater *contextUpdater = (ContextUpdater *)updater; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [contextUpdater release]; - [pool release]; -} - -void* createPBuffer(int renderTarget, int internalFormat, int width, int height) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc] - initWithTextureTarget:renderTarget - textureInternalFormat:internalFormat - textureMaxMipMapLevel:0 - pixelsWide:width - pixelsHigh:height]; - [pool release]; - return pBuffer; -} - -Bool destroyPBuffer(void* context, void* buffer) { - /* FIXME: not clear whether we need to perform the clearDrawable below */ - /* FIXME: remove the context argument -- don't need it any more */ - /* NSOpenGLContext *nsContext = (NSOpenGLContext*)context; */ - NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - /* - if (nsContext != NULL) { - [nsContext clearDrawable]; - } - */ - [pBuffer release]; - [pool release]; - - return true; -} - -void setContextPBuffer(void* context, void* buffer) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [nsContext setPixelBuffer: pBuffer - cubeMapFace: 0 - mipMapLevel: 0 - currentVirtualScreen: [nsContext currentVirtualScreen]]; - [pool release]; -} - -void setContextTextureImageToPBuffer(void* context, void* buffer, int colorBuffer) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - NSOpenGLPixelBuffer *pBuffer = (NSOpenGLPixelBuffer*)buffer; - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [nsContext setTextureImageToPixelBuffer: pBuffer - colorBuffer: (unsigned long) colorBuffer]; - [pool release]; -} - -#include <mach-o/dyld.h> -Bool imagesInitialized = false; -static char libGLStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"; -static char libGLUStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"; -static const struct mach_header *libGLImage; -static const struct mach_header *libGLUImage; -void* getProcAddress(const char *procname) { - if (imagesInitialized == false) { - imagesInitialized = true; - unsigned long options = NSADDIMAGE_OPTION_RETURN_ON_ERROR; - libGLImage = NSAddImage(libGLStr, options); - libGLUImage = NSAddImage(libGLUStr, options); - } - - unsigned long options = NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR; - char underscoreName[512] = "_"; - strcat(underscoreName, procname); - - if (NSIsSymbolNameDefinedInImage(libGLImage, underscoreName) == YES) { - NSSymbol sym = NSLookupSymbolInImage(libGLImage, underscoreName, options); - return NSAddressOfSymbol(sym); - } - - if (NSIsSymbolNameDefinedInImage(libGLUImage, underscoreName) == YES) { - NSSymbol sym = NSLookupSymbolInImage(libGLUImage, underscoreName, options); - return NSAddressOfSymbol(sym); - } - - if (NSIsSymbolNameDefinedWithHint(underscoreName, "GL")) { - NSSymbol sym = NSLookupAndBindSymbol(underscoreName); - return NSAddressOfSymbol(sym); - } - - return NULL; -} - -void setSwapInterval(void* context, int interval) { - NSOpenGLContext *nsContext = (NSOpenGLContext*)context; - long swapInterval = interval; - [nsContext setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; -} - -Bool setGammaRamp(int tableSize, float* redRamp, float* greenRamp, float* blueRamp) { - CGDisplayErr err = CGSetDisplayTransferByTable(kCGDirectMainDisplay, tableSize, redRamp, greenRamp, blueRamp); - return (err == CGDisplayNoErr); -} - -void resetGammaRamp() { - CGDisplayRestoreColorSyncSettings(); -} diff --git a/src/native/jogl/Mixer.cpp b/src/native/jogl/Mixer.cpp deleted file mode 100755 index 8843c00ec..000000000 --- a/src/native/jogl/Mixer.cpp +++ /dev/null @@ -1,199 +0,0 @@ -#include <windows.h> -#include <stdlib.h> -#include <mmsystem.h> -#include <mmreg.h> -#include "com_sun_javafx_audio_windows_waveout_Mixer.h" - -static HANDLE event = NULL; -static HWAVEOUT output = NULL; -// We use only two buffers to keep latency down -#define NUM_BUFFERS 2 -//#define NUM_BUFFERS 4 -// This is about 20 ms of data for WAVE_FORMAT_PCM: -// (44100 samples / sec) * (20 ms / 1000 ms) * (2 bytes / sample) * (2 channels) -//#define BUFFER_SIZE 3528 - -// This is about 50 ms of data for WAVE_FORMAT_PCM: -// (44100 samples / sec) * (50 ms / 1000 ms) * (2 bytes / sample) * (1 channel) -//#define BUFFER_SIZE 4410 - -// This is about 200 ms of data for WAVE_FORMAT_PCM: -// (44100 samples / sec) * (200 ms / 1000 ms) * (2 bytes / sample) * (1 channel) -//#define BUFFER_SIZE 17640 - -// This is about 200 ms of data for WAVE_FORMAT_PCM: -// (44100 samples / sec) * (200 ms / 1000 ms) * (2 bytes / sample) * (2 channel) -//#define BUFFER_SIZE 35280 - -// This is about 1000 ms of data for WAVE_FORMAT_PCM: -// (44100 samples / sec) * (1000 ms / 1000 ms) * (2 bytes / sample) * (1 channel) -//#define BUFFER_SIZE 88200 - -// This is about 50 ms of data for WAVE_FORMAT_PCM: -// (44100 samples / sec) * (50 ms / 1000 ms) * (2 bytes / sample) * (2 channels) -//#define BUFFER_SIZE 8820 - -// This is about 50 ms of data for WAVE_FORMAT_IEEE_FLOAT: -// (44100 samples / sec) * (50 ms / 1000 ms) * (4 bytes / sample) * (2 channels) -//#define BUFFER_SIZE 17640 - -// This is about 200 ms of data for WAVE_FORMAT_PCM: -// (11025 samples / sec) * (200 ms / 1000 ms) * (2 bytes / sample) * (2 channel) -#define BUFFER_SIZE 8820 - -//#define BUFFER_SIZE 8192 -static WAVEHDR** buffers = NULL; - -void CALLBACK playbackCallback(HWAVEOUT output, - UINT msg, - DWORD_PTR userData, - DWORD_PTR param1, - DWORD_PTR param2) -{ - if (msg == WOM_DONE) { - WAVEHDR* hdr = (WAVEHDR*) param1; - hdr->dwFlags |= WHDR_DONE; - SetEvent(event); - } -} - -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_initializeWaveOut - (JNIEnv *env, jclass unused, jlong eventObject) -{ - event = (HANDLE) eventObject; - - // Note the hard requirements on the RawSoundConverter's output format - WAVEFORMATEX format; - format.wFormatTag = WAVE_FORMAT_PCM; - // format.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; - format.nChannels = 2; - // format.nChannels = 1; - // format.nSamplesPerSec = 44100; - format.nSamplesPerSec = 11025; - format.wBitsPerSample = 16; - // format.wBitsPerSample = 32; - format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; - format.nAvgBytesPerSec = format.nBlockAlign * format.nSamplesPerSec; - format.cbSize = 0; - MMRESULT res = waveOutOpen(&output, - WAVE_MAPPER, - &format, - /* NULL, */ (DWORD_PTR) &playbackCallback, - NULL, // No user data right now - /* CALLBACK_NULL */ CALLBACK_FUNCTION); - if (res != MMSYSERR_NOERROR) { - return JNI_FALSE; - } - - buffers = (WAVEHDR**) calloc(NUM_BUFFERS, sizeof(WAVEHDR)); - for (int i = 0; i < NUM_BUFFERS; i++) { - char* data = (char*) calloc(BUFFER_SIZE, 1); - WAVEHDR* hdr = (WAVEHDR*) calloc(1, sizeof(WAVEHDR)); - hdr->lpData = data; - hdr->dwBufferLength = BUFFER_SIZE; - hdr->dwFlags |= WHDR_DONE; - buffers[i] = hdr; - } - - return JNI_TRUE; -} - -JNIEXPORT void JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_shutdownWaveOut - (JNIEnv *env, jclass unused) -{ - // writeString("Pausing\n"); - waveOutPause(output); - // writeString("Resetting\n"); - waveOutReset(output); - // writeString("Closing output\n"); - waveOutClose(output); -} - -JNIEXPORT jlong JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_getNextMixerBuffer - (JNIEnv *env, jclass unused) -{ - WAVEHDR* hdr = NULL; - for (int i = 0; i < NUM_BUFFERS; i++) { - if (buffers[i] != NULL && ((buffers[i]->dwFlags & WHDR_DONE) != 0)) { - hdr = buffers[i]; - hdr->dwFlags &= ~WHDR_DONE; - break; - } - } - return (jlong) hdr; -} - -JNIEXPORT jobject JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_getMixerBufferData - (JNIEnv *env, jclass unused, jlong mixerBuffer) -{ - WAVEHDR* hdr = (WAVEHDR*) mixerBuffer; - return env->NewDirectByteBuffer(hdr->lpData, hdr->dwBufferLength); -} - -JNIEXPORT jlong JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_getMixerBufferDataAddress - (JNIEnv *env, jclass unused, jlong mixerBuffer) -{ - WAVEHDR* hdr = (WAVEHDR*) mixerBuffer; - return (jlong) hdr->lpData; -} - -JNIEXPORT jint JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_getMixerBufferDataCapacity - (JNIEnv *env, jclass unused, jlong mixerBuffer) -{ - WAVEHDR* hdr = (WAVEHDR*) mixerBuffer; - return (jint) hdr->dwBufferLength; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_prepareMixerBuffer - (JNIEnv *env, jclass unused, jlong mixerBuffer) -{ - MMRESULT res = waveOutPrepareHeader(output, - (WAVEHDR*) mixerBuffer, - sizeof(WAVEHDR)); - if (res == MMSYSERR_NOERROR) { - return JNI_TRUE; - } - return JNI_FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_writeMixerBuffer - (JNIEnv *env, jclass unused, jlong mixerBuffer) -{ - MMRESULT res = waveOutWrite(output, - (WAVEHDR*) mixerBuffer, - sizeof(WAVEHDR)); - if (res == MMSYSERR_NOERROR) { - waveOutRestart(output); - - return JNI_TRUE; - } - return JNI_FALSE; -} - -JNIEXPORT jlong JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_CreateEvent - (JNIEnv *env, jclass unused) -{ - return (jlong) CreateEvent(NULL, FALSE, TRUE, NULL); -} - -JNIEXPORT jboolean JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_WaitForSingleObject - (JNIEnv *env, jclass unused, jlong eventObject) -{ - DWORD res = WaitForSingleObject((HANDLE) eventObject, INFINITE); - if (res == WAIT_OBJECT_0) { - return JNI_TRUE; - } - return JNI_FALSE; -} - -JNIEXPORT void JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_SetEvent - (JNIEnv *env, jclass unused, jlong eventObject) -{ - SetEvent((HANDLE) eventObject); -} - -JNIEXPORT void JNICALL Java_com_sun_javafx_audio_windows_waveout_Mixer_CloseHandle - (JNIEnv *env, jclass unused, jlong eventObject) -{ - CloseHandle((HANDLE) eventObject); -} diff --git a/src/native/jogl/Xinerama.c b/src/native/jogl/Xinerama.c deleted file mode 100644 index 98dcfe095..000000000 --- a/src/native/jogl/Xinerama.c +++ /dev/null @@ -1,316 +0,0 @@ -/* $TOG: XPanoramiX.c /main/2 1997/11/16 08:45:41 kaleb $ */ -/**************************************************************** -* * -* Copyright (c) Digital Equipment Corporation, 1991, 1997 * -* * -* All Rights Reserved. Unpublished rights reserved under * -* the copyright laws of the United States. * -* * -* The software contained on this media is proprietary to * -* and embodies the confidential technology of Digital * -* Equipment Corporation. Possession, use, duplication or * -* dissemination of the software and media is authorized only * -* pursuant to a valid written license from Digital Equipment * -* Corporation. * -* * -* RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure * -* by the U.S. Government is subject to restrictions as set * -* forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, * -* or in FAR 52.227-19, as applicable. * -* * -*****************************************************************/ -/* $XFree86: xc/lib/Xinerama/Xinerama.c,v 1.1 2000/02/27 23:10:04 mvojkovi Exp $ */ - -#ifndef __linux__ - #error This file should only be built under Linux -#endif - -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xlibint.h> -#include <X11/Xutil.h> -/* #include "Xext.h" */ /* in ../include */ -#include "extutil.h" /* in ../include */ -#include "panoramiXext.h" -#include "panoramiXproto.h" /* in ../include */ -#include "Xinerama.h" - - -static XExtensionInfo _panoramiX_ext_info_data; -static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data; -static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME; - -#define PanoramiXCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, panoramiX_extension_name, val) -#define PanoramiXSimpleCheckExtension(dpy,i) \ - XextSimpleCheckExtension (dpy, i, panoramiX_extension_name) - -static int close_display(); -static /* const */ XExtensionHooks panoramiX_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info, - panoramiX_extension_name, - &panoramiX_extension_hooks, - 0, NULL) - -static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info) - - - -/**************************************************************************** - * * - * PanoramiX public interfaces * - * * - ****************************************************************************/ - -Bool XPanoramiXQueryExtension ( - Display *dpy, - int *event_basep, - int *error_basep -) -{ - XExtDisplayInfo *info = find_display (dpy); - - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - return True; - } else { - return False; - } -} - - -Status XPanoramiXQueryVersion( - Display *dpy, - int *major_versionp, - int *minor_versionp -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXQueryVersionReply rep; - register xPanoramiXQueryVersionReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXQueryVersion; - req->clientMajor = PANORAMIX_MAJOR_VERSION; - req->clientMinor = PANORAMIX_MINOR_VERSION; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - *major_versionp = rep.majorVersion; - *minor_versionp = rep.minorVersion; - UnlockDisplay (dpy); - SyncHandle (); - return 1; -} - -XPanoramiXInfo *XPanoramiXAllocInfo(void) -{ - return (XPanoramiXInfo *) Xmalloc (sizeof (XPanoramiXInfo)); -} - -Status XPanoramiXGetState ( - Display *dpy, - Drawable drawable, - XPanoramiXInfo *panoramiX_info -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXGetStateReply rep; - register xPanoramiXGetStateReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXGetState, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetState; - req->window = drawable; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - UnlockDisplay (dpy); - SyncHandle (); - panoramiX_info->window = rep.window; - panoramiX_info->State = rep.state; - return 1; -} - -Status XPanoramiXGetScreenCount ( - Display *dpy, - Drawable drawable, - XPanoramiXInfo *panoramiX_info -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXGetScreenCountReply rep; - register xPanoramiXGetScreenCountReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXGetScreenCount, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetScreenCount; - req->window = drawable; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - UnlockDisplay (dpy); - SyncHandle (); - panoramiX_info->window = rep.window; - panoramiX_info->ScreenCount = rep.ScreenCount; - return 1; -} - -Status XPanoramiXGetScreenSize ( - Display *dpy, - Drawable drawable, - int screen_num, - XPanoramiXInfo *panoramiX_info -) -{ - XExtDisplayInfo *info = find_display (dpy); - xPanoramiXGetScreenSizeReply rep; - register xPanoramiXGetScreenSizeReq *req; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (PanoramiXGetScreenSize, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetScreenSize; - req->window = drawable; - req->screen = screen_num; /* need to define */ - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return 0; - } - UnlockDisplay (dpy); - SyncHandle (); - panoramiX_info->window = rep.window; - panoramiX_info->screen = rep.screen; - panoramiX_info->width = rep.width; - panoramiX_info->height = rep.height; - return 1; -} - -/*******************************************************************\ - Alternate interface to make up for shortcomings in the original, - namely, the omission of the screen origin. The new interface is - in the "Xinerama" namespace instead of "PanoramiX". -\*******************************************************************/ - -Bool XineramaQueryExtension ( - Display *dpy, - int *event_base, - int *error_base -) -{ - return XPanoramiXQueryExtension(dpy, event_base, error_base); -} - -Status XineramaQueryVersion( - Display *dpy, - int *major, - int *minor -) -{ - return XPanoramiXQueryVersion(dpy, major, minor); -} - -Bool XineramaIsActive(Display *dpy) -{ - xXineramaIsActiveReply rep; - xXineramaIsActiveReq *req; - XExtDisplayInfo *info = find_display (dpy); - - if(!XextHasExtension(info)) - return False; /* server doesn't even have the extension */ - - LockDisplay (dpy); - GetReq (XineramaIsActive, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_XineramaIsActive; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - UnlockDisplay (dpy); - SyncHandle (); - return rep.state; -} - -#include <stdio.h> - -XineramaScreenInfo * -XineramaQueryScreens( - Display *dpy, - int *number -) -{ - XExtDisplayInfo *info = find_display (dpy); - xXineramaQueryScreensReply rep; - xXineramaQueryScreensReq *req; - XineramaScreenInfo *scrnInfo = NULL; - - PanoramiXCheckExtension (dpy, info, 0); - - LockDisplay (dpy); - GetReq (XineramaQueryScreens, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_XineramaQueryScreens; - if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); - return NULL; - } - - if(rep.number) { - if((scrnInfo = Xmalloc(sizeof(XineramaScreenInfo) * rep.number))) { - xXineramaScreenInfo scratch; - CARD32 i; - - for(i = 0; i < rep.number; i++) { - _XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo); - scrnInfo[i].screen_number = i; - scrnInfo[i].x_org = scratch.x_org; - scrnInfo[i].y_org = scratch.y_org; - scrnInfo[i].width = scratch.width; - scrnInfo[i].height = scratch.height; - } - - *number = rep.number; - } else - _XEatData(dpy, rep.length << 2); - } - - UnlockDisplay (dpy); - SyncHandle (); - return scrnInfo; -} diff --git a/src/native/jogl/Xinerama.h b/src/native/jogl/Xinerama.h deleted file mode 100644 index 7177f5131..000000000 --- a/src/native/jogl/Xinerama.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright (C) 1994-2001 The XFree86 Project, Inc. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Soft- -ware"), to deal in the Software without restriction, including without -limitation the rights to use, copy, modify, merge, publish, distribute, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, provided that the above copyright -notice(s) and this permission notice appear in all copies of the Soft- -ware and that both the above copyright notice(s) and this permission -notice appear in supporting documentation. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- -ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY -RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN -THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- -QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- -MANCE OF THIS SOFTWARE. - -Except as contained in this notice, the name of a copyright holder shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization of -the copyright holder. -*/ - -/* $XFree86: xc/include/extensions/Xinerama.h,v 3.2 2000/03/01 01:04:20 dawes Exp $ */ - -#ifdef __linux__ - -#ifndef _Xinerama_h -#define _Xinerama_h - -typedef struct { - int screen_number; - short x_org; - short y_org; - short width; - short height; -} XineramaScreenInfo; - -Bool XineramaQueryExtension ( - Display *dpy, - int *event_base, - int *error_base -); - -Status XineramaQueryVersion( - Display *dpy, - int *major, - int *minor -); - -Bool XineramaIsActive(Display *dpy); - - -/* - Returns the number of heads and a pointer to an array of - structures describing the position and size of the individual - heads. Returns NULL and number = 0 if Xinerama is not active. - - Returned array should be freed with XFree(). -*/ - -XineramaScreenInfo * -XineramaQueryScreens( - Display *dpy, - int *number -); - -#endif /* _Xinerama_h */ - -#endif /* __linux__ */ diff --git a/src/native/jogl/XineramaHelper.c b/src/native/jogl/XineramaHelper.c deleted file mode 100644 index 09ad0b706..000000000 --- a/src/native/jogl/XineramaHelper.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - */ - -/* This file contains a helper routine to be called by Java code to - determine whether the Xinerama extension is in use and therefore to - treat the multiple AWT screens as one large screen. */ - -#include <inttypes.h> -#include <X11/Xlib.h> - -#ifdef __sun - -typedef Status XineramaGetInfoFunc(Display* display, int screen_number, - XRectangle* framebuffer_rects, unsigned char* framebuffer_hints, - int* num_framebuffers); -typedef Status XineramaGetCenterHintFunc(Display* display, int screen_number, - int* x, int* y); - -XineramaGetCenterHintFunc* XineramaSolarisCenterFunc = NULL; -#include <dlfcn.h> - -#elif defined(__linux__) - -#include "Xinerama.h" - -#endif - -Bool XineramaEnabled(Display* display) { -#ifdef __sun - -#define MAXFRAMEBUFFERS 16 - char* XinExtName = "XINERAMA"; - int32_t major_opcode, first_event, first_error; - Bool gotXinExt = False; - void* libHandle = 0; - unsigned char fbhints[MAXFRAMEBUFFERS]; - XRectangle fbrects[MAXFRAMEBUFFERS]; - int locNumScr = 0; - Bool usingXinerama = False; - - char* XineramaLibName= "libXext.so"; - char* XineramaGetInfoName = "XineramaGetInfo"; - char* XineramaGetCenterHintName = "XineramaGetCenterHint"; - XineramaGetInfoFunc* XineramaSolarisFunc = NULL; - - gotXinExt = XQueryExtension(display, XinExtName, &major_opcode, - &first_event, &first_error); - - if (gotXinExt) { - /* load library, load and run XineramaGetInfo */ - libHandle = dlopen(XineramaLibName, RTLD_LAZY | RTLD_GLOBAL); - if (libHandle != 0) { - XineramaSolarisFunc = (XineramaGetInfoFunc*)dlsym(libHandle, XineramaGetInfoName); - XineramaSolarisCenterFunc = - (XineramaGetCenterHintFunc*)dlsym(libHandle, - XineramaGetCenterHintName); - if (XineramaSolarisFunc != NULL) { - if ((*XineramaSolarisFunc)(display, 0, &fbrects[0], - &fbhints[0], &locNumScr) != 0) { - - usingXinerama = True; - } - } - dlclose(libHandle); - } - } - return usingXinerama; - -#elif defined(__linux__) - - char* XinExtName = "XINERAMA"; - int32_t major_opcode, first_event, first_error; - Bool gotXinExt = False; - int32_t locNumScr = 0; - - XineramaScreenInfo *xinInfo; - - gotXinExt = XQueryExtension(display, XinExtName, &major_opcode, - &first_event, &first_error); - - if (gotXinExt) { - xinInfo = XineramaQueryScreens(display, &locNumScr); - if (xinInfo != NULL) { - return True; - } - } - return False; - -#else - return False; -#endif -} diff --git a/src/native/jogl/extutil.h b/src/native/jogl/extutil.h deleted file mode 100644 index f0d3b59c3..000000000 --- a/src/native/jogl/extutil.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * $Xorg: extutil.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $ - * -Copyright 1989, 1998 The Open Group - -All Rights Reserved. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - * - * Author: Jim Fulton, MIT The Open Group - * - * Xlib Extension-Writing Utilities - * - * This package contains utilities for writing the client API for various - * protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND - * ARE SUBJECT TO CHANGE! - */ -/* $XFree86: xc/include/extensions/extutil.h,v 1.5 2001/01/17 17:53:20 dawes Exp $ */ - -#ifdef __linux__ - -#ifndef _EXTUTIL_H_ -#define _EXTUTIL_H_ - -/* - * We need to keep a list of open displays since the Xlib display list isn't - * public. We also have to per-display info in a separate block since it isn't - * stored directly in the Display structure. - */ -typedef struct _XExtDisplayInfo { - struct _XExtDisplayInfo *next; /* keep a linked list */ - Display *display; /* which display this is */ - XExtCodes *codes; /* the extension protocol codes */ - XPointer data; /* extra data for extension to use */ -} XExtDisplayInfo; - -typedef struct _XExtensionInfo { - XExtDisplayInfo *head; /* start of list */ - XExtDisplayInfo *cur; /* most recently used */ - int ndisplays; /* number of displays */ -} XExtensionInfo; - -typedef struct _XExtensionHooks { - int (*create_gc)( -#if NeedNestedPrototypes - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -#endif -); - int (*copy_gc)( -#if NeedNestedPrototypes - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -#endif -); - int (*flush_gc)( -#if NeedNestedPrototypes - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -#endif -); - int (*free_gc)( -#if NeedNestedPrototypes - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -#endif -); - int (*create_font)( -#if NeedNestedPrototypes - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -#endif -); - int (*free_font)( -#if NeedNestedPrototypes - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -#endif -); - int (*close_display)( -#if NeedNestedPrototypes - Display* /* display */, - XExtCodes* /* codes */ -#endif -); - Bool (*wire_to_event)( -#if NeedNestedPrototypes - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ -#endif -); - Status (*event_to_wire)( -#if NeedNestedPrototypes - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ -#endif -); - int (*error)( -#if NeedNestedPrototypes - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ -#endif -); - char *(*error_string)( -#if NeedNestedPrototypes - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ -#endif -); -} XExtensionHooks; - -extern XExtensionInfo *XextCreateExtension( -#if NeedFunctionPrototypes - void -#endif -); -extern void XextDestroyExtension( -#if NeedFunctionPrototypes - XExtensionInfo* /* info */ -#endif -); -extern XExtDisplayInfo *XextAddDisplay( -#if NeedFunctionPrototypes - XExtensionInfo* /* extinfo */, - Display* /* dpy */, - char* /* ext_name */, - XExtensionHooks* /* hooks */, - int /* nevents */, - XPointer /* data */ -#endif -); -extern int XextRemoveDisplay( -#if NeedFunctionPrototypes - XExtensionInfo* /* extinfo */, - Display* /* dpy */ -#endif -); -extern XExtDisplayInfo *XextFindDisplay( -#if NeedFunctionPrototypes - XExtensionInfo* /* extinfo */, - Display* /* dpy */ -#endif -); - -#define XextHasExtension(i) ((i) && ((i)->codes)) -#define XextCheckExtension(dpy,i,name,val) \ - if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } -#define XextSimpleCheckExtension(dpy,i,name) \ - if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; } - - -/* - * helper macros to generate code that is common to all extensions; caller - * should prefix it with static if extension source is in one file; this - * could be a utility function, but have to stack 6 unused arguments for - * something that is called many, many times would be bad. - */ -#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \ -XExtDisplayInfo *proc (Display *dpy) \ -{ \ - XExtDisplayInfo *dpyinfo; \ - if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \ - if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \ - dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \ - return dpyinfo; \ -} - -#define XEXT_FIND_DISPLAY_PROTO(proc) \ - XExtDisplayInfo *proc(Display *dpy) - -#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \ -int proc (Display *dpy, XExtCodes *codes) \ -{ \ - return XextRemoveDisplay (extinfo, dpy); \ -} - -#define XEXT_CLOSE_DISPLAY_PROTO(proc) \ - int proc(Display *dpy, XExtCodes *codes) - -#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \ -char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \ -{ \ - code -= codes->first_error; \ - if (code >= 0 && code < nerr) { \ - char tmp[256]; \ - sprintf (tmp, "%s.%d", extname, code); \ - XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \ - return buf; \ - } \ - return (char *)0; \ -} - -#define XEXT_ERROR_STRING_PROTO(proc) \ - char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n) -#endif - -#endif /* __linux__ */ diff --git a/src/native/jogl/panoramiXext.h b/src/native/jogl/panoramiXext.h deleted file mode 100644 index 11267d0c1..000000000 --- a/src/native/jogl/panoramiXext.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $Xorg: panoramiXext.h,v 1.4 2000/08/18 04:05:45 coskrey Exp $ */ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ -/* - * PanoramiX definitions - */ -/* $XFree86: xc/include/extensions/panoramiXext.h,v 3.6 2001/01/17 17:53:22 dawes Exp $ */ - -#ifdef __linux__ - -/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ - -#define PANORAMIX_MAJOR_VERSION 1 /* current version number */ -#define PANORAMIX_MINOR_VERSION 1 - -typedef struct { - Window window; /* PanoramiX window - may not exist */ - int screen; - int State; /* PanroamiXOff, PanoramiXOn */ - int width; /* width of this screen */ - int height; /* height of this screen */ - int ScreenCount; /* real physical number of screens */ - XID eventMask; /* selected events for this client */ -} XPanoramiXInfo; - -extern XPanoramiXInfo *XPanoramiXAllocInfo ( -#if NeedFunctionPrototypes - void -#endif -); - -#endif /* __linux__*/ diff --git a/src/native/jogl/panoramiXproto.h b/src/native/jogl/panoramiXproto.h deleted file mode 100644 index 1a66940f7..000000000 --- a/src/native/jogl/panoramiXproto.h +++ /dev/null @@ -1,196 +0,0 @@ -/* $Xorg: panoramiXproto.h,v 1.4 2000/08/18 04:05:45 coskrey Exp $ */ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ -/* $XFree86: xc/include/extensions/panoramiXproto.h,v 3.6 2001/01/17 17:53:22 dawes Exp $ */ - -#ifdef __linux__ - -/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ - -#ifndef _PANORAMIXPROTO_H_ -#define _PANORAMIXPROTO_H_ - -#define PANORAMIX_PROTOCOL_NAME "XINERAMA" - -#define X_PanoramiXQueryVersion 0 -#define X_PanoramiXGetState 1 -#define X_PanoramiXGetScreenCount 2 -#define X_PanoramiXGetScreenSize 3 - -#define X_XineramaIsActive 4 -#define X_XineramaQueryScreens 5 - -typedef struct _PanoramiXQueryVersion { - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXQueryVersion */ - CARD16 length B16; - CARD8 clientMajor; - CARD8 clientMinor; - CARD16 unused B16; -} xPanoramiXQueryVersionReq; - -#define sz_xPanoramiXQueryVersionReq 8 - -typedef struct { - CARD8 type; /* must be X_Reply */ - CARD8 pad1; /* unused */ - CARD16 sequenceNumber B16; /* last sequence number */ - CARD32 length B32; /* 0 */ - CARD16 majorVersion B16; - CARD16 minorVersion B16; - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ - CARD32 pad4 B32; /* unused */ - CARD32 pad5 B32; /* unused */ - CARD32 pad6 B32; /* unused */ -} xPanoramiXQueryVersionReply; - -#define sz_xPanoramiXQueryVersionReply 32 - - -typedef struct _PanoramiXGetState { - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXGetState */ - CARD16 length B16; - CARD32 window B32; -} xPanoramiXGetStateReq; -#define sz_xPanoramiXGetStateReq 8 - -typedef struct { - BYTE type; - BYTE state; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 window B32; - CARD32 pad1 B32; /* unused */ - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ - CARD32 pad4 B32; /* unused */ - CARD32 pad5 B32; /* unused */ -} xPanoramiXGetStateReply; - -#define sz_panoramiXGetStateReply 32 - -typedef struct _PanoramiXGetScreenCount { - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXGetScreenCount */ - CARD16 length B16; - CARD32 window B32; -} xPanoramiXGetScreenCountReq; -#define sz_xPanoramiXGetScreenCountReq 8 - -typedef struct { - BYTE type; - BYTE ScreenCount; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 window B32; - CARD32 pad1 B32; /* unused */ - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ - CARD32 pad4 B32; /* unused */ - CARD32 pad5 B32; /* unused */ -} xPanoramiXGetScreenCountReply; -#define sz_panoramiXGetScreenCountReply 32 - -typedef struct _PanoramiXGetScreenSize { - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXGetState */ - CARD16 length B16; - CARD32 window B32; - CARD32 screen B32; -} xPanoramiXGetScreenSizeReq; -#define sz_xPanoramiXGetScreenSizeReq 12 - -typedef struct { - BYTE type; - CARD8 pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 width B32; - CARD32 height B32; - CARD32 window B32; - CARD32 screen B32; - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ -} xPanoramiXGetScreenSizeReply; -#define sz_panoramiXGetScreenSizeReply 32 - -/************ Alternate protocol ******************/ - -typedef struct { - CARD8 reqType; - CARD8 panoramiXReqType; - CARD16 length B16; -} xXineramaIsActiveReq; -#define sz_xXineramaIsActiveReq 4 - -typedef struct { - BYTE type; - CARD8 pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 state B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXineramaIsActiveReply; -#define sz_XineramaIsActiveReply 32 - - -typedef struct { - CARD8 reqType; - CARD8 panoramiXReqType; - CARD16 length B16; -} xXineramaQueryScreensReq; -#define sz_xXineramaQueryScreensReq 4 - -typedef struct { - BYTE type; - CARD8 pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 number B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXineramaQueryScreensReply; -#define sz_XineramaQueryScreensReply 32 - -typedef struct { - INT16 x_org B16; - INT16 y_org B16; - CARD16 width B16; - CARD16 height B16; -} xXineramaScreenInfo; -#define sz_XineramaScreenInfo 8 - -#endif - -#endif /* __linux__ */ |