*** empty log message ***
This commit is contained in:
parent
a16b6d1d38
commit
56a45b2cb4
|
@ -1,6 +1,7 @@
|
|||
SUBDIRS = common @native_build_dir@
|
||||
|
||||
lib_LTLIBRARIES = liblwjgl.la
|
||||
liblwjgl_la_LDFLAGS = -framework Carbon
|
||||
liblwjgl_la_SOURCES = dummy.cpp
|
||||
liblwjgl_la_LIBADD = common/libcommon.la @native_build_dir@/libnative.la
|
||||
liblwjgl_la_DEPENDENCIES = common/libcommon.la @native_build_dir@/libnative.la
|
||||
|
|
|
@ -30,6 +30,7 @@ AC_CANONICAL_HOST
|
|||
|
||||
case "$host_os" in
|
||||
darwin*) _BUILD_FLAGS="-D_AGL -fpascal-strings"
|
||||
LIBS="-framework Carbon -framework JavaVM"
|
||||
NATIVE_BUILD_DIR=macosx
|
||||
CXXFLAGS="$CXXFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS"
|
||||
CFLAGS="$CFLAGS $DEBUG_FLAGS -Wall $_BUILD_FLAGS"
|
||||
|
|
|
@ -4,8 +4,8 @@ libnative_la_SOURCES = $(NATIVE)
|
|||
INCLUDES = -I../common
|
||||
|
||||
NATIVE = \
|
||||
# org_lwjgl_Display.cpp \
|
||||
# org_lwjgl_Sys.cpp \
|
||||
org_lwjgl_Display.cpp \
|
||||
org_lwjgl_Sys.cpp \
|
||||
# org_lwjgl_input_Controller.cpp \
|
||||
# org_lwjgl_input_Keyboard.cpp \
|
||||
# org_lwjgl_input_Mouse.cpp \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
||||
* Copyright (c) 2002 Light Weight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -30,191 +30,24 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "org_lwjgl_Display.h"
|
||||
#include <JavaVM/jni.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
|
||||
static long _getDictLong (CFDictionaryRef refDict, CFStringRef key)
|
||||
{
|
||||
long int_value;
|
||||
|
||||
CFNumberRef number_value = (CFNumberRef) CFDictionaryGetValue(refDict, key);
|
||||
|
||||
if (!number_value)
|
||||
{
|
||||
// if can't get a number for the dictionary
|
||||
return -1; // fail
|
||||
}
|
||||
|
||||
if (!CFNumberGetValue(number_value, kCFNumberLongType, &int_value))
|
||||
{
|
||||
// or if cant convert it
|
||||
return -1; // fail
|
||||
}
|
||||
|
||||
return int_value; // otherwise return the long value
|
||||
}
|
||||
|
||||
static double _getDictDouble (CFDictionaryRef refDict, CFStringRef key)
|
||||
{
|
||||
double double_value;
|
||||
|
||||
CFNumberRef number_value = (CFNumberRef) CFDictionaryGetValue(refDict, key);
|
||||
|
||||
if (!number_value)
|
||||
{
|
||||
// if can't get a number for the dictionary
|
||||
return -1; // fail
|
||||
}
|
||||
|
||||
if (!CFNumberGetValue(number_value, kCFNumberDoubleType, &double_value)) // or if cant convert it
|
||||
{
|
||||
return -1; // fail
|
||||
}
|
||||
|
||||
return double_value; // otherwise return the long value
|
||||
}
|
||||
|
||||
jobjectArray GetAvailableDisplayModesOSX(JNIEnv * env)
|
||||
{
|
||||
CFIndex i, count;
|
||||
CFIndex availableModes = 0;
|
||||
CFArrayRef displayModes = NULL;
|
||||
int n = 0;
|
||||
|
||||
|
||||
displayModes = CGDisplayAvailableModes( kCGDirectMainDisplay );
|
||||
count = CFArrayGetCount( displayModes );
|
||||
|
||||
// get a count of the number of display modes on this machine with a bpp greater than 8
|
||||
//
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
CFDictionaryRef mode = static_cast<CFDictionaryRef>( CFArrayGetValueAtIndex( displayModes, i ) );
|
||||
long bpp = _getDictLong( mode, kCGDisplayBitsPerPixel );
|
||||
|
||||
if ( bpp > 8 )
|
||||
{
|
||||
availableModes ++;
|
||||
}
|
||||
}
|
||||
|
||||
// now that we have the count create the classes, and add 'em all - we'll remove dups in Java
|
||||
// Allocate an array of DisplayModes big enough
|
||||
jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode");
|
||||
jobjectArray ret = env->NewObjectArray( availableModes, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V");
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
CFDictionaryRef modeDict = static_cast<CFDictionaryRef>( CFArrayGetValueAtIndex( displayModes, i ) );
|
||||
long width = _getDictLong( modeDict, kCGDisplayWidth );
|
||||
long height = _getDictLong( modeDict, kCGDisplayHeight );
|
||||
long freq = (long)(_getDictDouble( modeDict, kCGDisplayRefreshRate ) + 0.5 );
|
||||
long bpp = _getDictLong( modeDict, kCGDisplayBitsPerPixel );
|
||||
|
||||
if ( bpp > 8 )
|
||||
{
|
||||
jobject displayMode;
|
||||
displayMode = env->NewObject(displayModeClass, displayModeConstructor,
|
||||
width, height,
|
||||
bpp, freq);
|
||||
|
||||
env->SetObjectArrayElement(ret, n++, displayMode);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: init
|
||||
* Signature: ()V
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* Mac OS X specific library for display handling.
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
#include <JavaVM/jni.h>
|
||||
#include "org_lwjgl_Display.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Display_init
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
if ( CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess )
|
||||
{
|
||||
printf("Unable to capture the display. Without capturing the display - this application cannot run");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the current display mode from the system
|
||||
//
|
||||
int width = CGDisplayPixelsWide( kCGDirectMainDisplay );
|
||||
int height = CGDisplayPixelsHigh( kCGDirectMainDisplay );
|
||||
int bpp = CGDisplayBitsPerPixel( kCGDirectMainDisplay );
|
||||
int freq = (int)_getDictDouble (CGDisplayCurrentMode ( kCGDirectMainDisplay ), kCGDisplayRefreshRate);
|
||||
|
||||
jclass jclass_DisplayMode = env->FindClass("org/lwjgl/DisplayMode");
|
||||
jmethodID ctor = env->GetMethodID(jclass_DisplayMode, "<init>", "(IIII)V");
|
||||
jobject newMode = env->NewObject(jclass_DisplayMode, ctor, width, height, bpp, freq);
|
||||
jfieldID fid_initialMode = env->GetStaticFieldID(clazz, "mode", "Lorg/lwjgl/DisplayMode;");
|
||||
env->SetStaticObjectField(clazz, fid_initialMode, newMode);
|
||||
env->DeleteLocalRef(newMode);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: setDisplayMode
|
||||
* Signature: (Lorg/lwjgl/DisplayMode;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode
|
||||
(JNIEnv * env, jclass clazz, jobject mode)
|
||||
{
|
||||
jclass cls_displayMode = env->FindClass("org/lwjgl/DisplayMode");
|
||||
jfieldID fid_width = env->GetFieldID(cls_displayMode, "width", "I");
|
||||
jfieldID fid_height = env->GetFieldID(cls_displayMode, "height", "I");
|
||||
jfieldID fid_bpp = env->GetFieldID(cls_displayMode, "bpp", "I");
|
||||
jfieldID fid_freq = env->GetFieldID(cls_displayMode, "freq", "I");
|
||||
|
||||
int width = env->GetIntField(mode, fid_width);
|
||||
int height = env->GetIntField(mode, fid_height);
|
||||
int bpp = env->GetIntField(mode, fid_bpp);
|
||||
int freq = env->GetIntField(mode, fid_freq);
|
||||
|
||||
CFDictionaryRef displayMode;
|
||||
displayMode = CGDisplayBestModeForParametersAndRefreshRate( kCGDirectMainDisplay,
|
||||
bpp,
|
||||
width, height,
|
||||
freq,
|
||||
NULL );
|
||||
CGDisplaySwitchToMode( kCGDirectMainDisplay, displayMode ) ;
|
||||
|
||||
// The change was successful but might not be the exact change we were expecting.
|
||||
// Now we'll construct a new DisplayMode instance and stash it back in the Display
|
||||
// class's mode instance variable.
|
||||
|
||||
jmethodID ctor = env->GetMethodID(cls_displayMode, "<init>", "(IIII)V");
|
||||
jobject newMode = env->NewObject(cls_displayMode, ctor, width, height, bpp, freq);
|
||||
jfieldID fid_initialMode = env->GetStaticFieldID(clazz, "mode", "Lorg/lwjgl/DisplayMode;");
|
||||
env->SetStaticObjectField(clazz, fid_initialMode, newMode);
|
||||
env->DeleteLocalRef(newMode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: resetDisplayMode
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
// the purpose of this method is to return the display mode to whatever it was before
|
||||
// the application takes over. OSX is smart enough to not require any of this
|
||||
// foolishness :)
|
||||
|
||||
//release the display that we captured so other applications will still work
|
||||
//
|
||||
CGReleaseAllDisplays();
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode(JNIEnv * env, jclass clazz, jobject mode) {
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -225,7 +58,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode
|
|||
JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
return GetAvailableDisplayModesOSX( env );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -241,27 +73,28 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getPlatform
|
|||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: getGammaRamp
|
||||
* Signature: ([I[I[I)Z
|
||||
* Method: getGammaRampLength
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_getGammaRamp
|
||||
(JNIEnv *, jclass, jintArray, jintArray, jintArray)
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getGammaRampLength
|
||||
(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: setGammaRamp
|
||||
* Signature: ([I[I[I)Z
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_setGammaRamp
|
||||
(JNIEnv *, jclass, jintArray, jintArray, jintArray)
|
||||
(JNIEnv *env, jclass clazz, jobject gamma_ramp_buffer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: resetDisplayMode
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode(JNIEnv *, jclass) {
|
||||
}
|
||||
|
|
|
@ -48,39 +48,6 @@ long int hires_timer_freq; // Hires timer frequency
|
|||
long int hires_timer_start; // Hires timer start
|
||||
long int hires_timer; // Hires timer current time
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: nGetNULLValue
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_nGetNULLValue
|
||||
(JNIEnv *, jclass)
|
||||
{
|
||||
return (jint)NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: getDirectBufferAddress
|
||||
* Signature: (Ljava/nio/Buffer;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_getDirectBufferAddress
|
||||
(JNIEnv * env, jclass clazz, jobject buf)
|
||||
{
|
||||
return (jint) env->GetDirectBufferAddress(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: createDirectBuffer
|
||||
* Signature: (II)Ljava/nio/ByteBuffer;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_Sys_createDirectBuffer
|
||||
(JNIEnv * env, jclass clazz, jint address, jint length)
|
||||
{
|
||||
return env->NewDirectByteBuffer((void *)address, length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: getTimerResolution
|
||||
|
@ -92,7 +59,7 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
|||
return hires_timer_freq;
|
||||
}
|
||||
|
||||
long queryTime(void) {
|
||||
static long queryTime(void) {
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, NULL) == -1) {
|
||||
#ifdef _DEBUG
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <JavaVM/jni.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "org_lwjgl_opengl_Window.h"
|
||||
|
||||
static WindowRef win_ref;
|
||||
|
||||
|
|
Loading…
Reference in New Issue