[kaffe] JSDL works well under Kaffe

jserv at linux2.cc.ntu.edu.tw jserv at linux2.cc.ntu.edu.tw
Wed Mar 17 23:53:03 PST 2004


Hello all devlopers,

  I just let JSDL (Java binding for SDL [1]) run under Kaffe, and it
works vey well. But I also mentioned that the JNI implemented in Kaffe
is a bit poor, and lacks some entries needed by JSDL:

  - (*env)->DeleteWeakGlobalRef(env,objCallback)
  - (*env)->GetStringUTFRegion(env,s,0,lenString,str)

So that I have to comment the calls of the above to get JSDL compiled.
I took some screenshots for JSDL running under Kaffe 1.1.x-cvs:

  http://jserv.sayya.org/kaffe/screenshots/jsdl-kaffe.png
  http://jserv.sayya.org/kaffe/screenshots/jsdl-kaffe2.png
  http://jserv.sayya.org/kaffe/screenshots/jsdl-kaffe3.png
  http://jserv.sayya.org/kaffe/screenshots/jsdl-kaffe4.png

What I modified JSDL is attached in the mail, and I hope it would be
useful.

cheers,
Jim Huang <jimchyun at ccns.ncku.edu.tw> 

  [1] http://jsdl.sourceforge.net/
-------------- next part --------------
diff -urN jsdl/sdl/jni/compilejni.sh jsdl-kaffe/sdl/jni/compilejni.sh
--- jsdl/sdl/jni/compilejni.sh	2002-09-27 06:26:41.000000000 +0800
+++ jsdl-kaffe/sdl/jni/compilejni.sh	2004-03-18 14:12:36.000000000 +0800
@@ -1,20 +1,25 @@
 #!/bin/sh -x
 
 EXTERNAL_LIBS=/usr
-JDK_HOME=/usr/java/j2sdk1.4.0_01
+JDK_HOME=/opt
 
-SDL_DIR=/usr/include/SDL
-SMPEG_DIR=/usr/include/smpeg
-SDL_LIB_DIR=/usr/lib
-SDL_IMAGE_DIR=/usr/include/SDL
+SDL_DIR=`sdl-config --cflags`
+SDL_LIB_DIR=`sdl-config --libs`
+
+SMPEG_DIR=`smpeg-config --cflags`
+SMPEG_LIB_DIR=`smpeg-config --libs`
+
+SDL_IMAGE_DIR=`sdl-config --cflags`
 
-SMPEG_LIB_DIR=/usr/lib/smpeg
 # SFont support
 SFONT_INC_DIR=`pwd`
 SFONT_SRC_DIR=`pwd`
 
-gcc -DUSING_GCC -I$SDL_DIR -I${SDL_IMAGE_DIR} -I$SMPEG_DIR -I${SFONT_INC_DIR} -I${JDK_HOME}/include -I${JDK_HOME}/include/linux -I. -c *.c
+gcc -DUSING_GCC \
+	$SDL_DIR ${SDL_IMAGE_DIR} $SMPEG_DIR ${SFONT_INC_DIR} \
+	-I${JDK_HOME}/include -I${JDK_HOME}/include/linux -I. -c *.c
 
-gcc -DUSING_GCC  -shared -o libSDL4Java.so *.o -lSDL -lSDL_image -lsmpeg -L$SDL_LIB_DIR -L$SMPEG_LIB_DIR
+gcc -DUSING_GCC  -shared -o libSDL4Java.so *.o -lSDL_image \
+	$SDL_LIB_DIR $SMPEG_LIB_DIR
 
 mv *.so ../..
diff -urN jsdl/sdl/jni/SDLAudio.c jsdl-kaffe/sdl/jni/SDLAudio.c
--- jsdl/sdl/jni/SDLAudio.c	2001-05-28 01:12:17.000000000 +0800
+++ jsdl-kaffe/sdl/jni/SDLAudio.c	2004-03-18 15:04:54.000000000 +0800
@@ -64,7 +64,7 @@
  */
 JNIEXPORT void JNICALL Java_sdl_audio_SDLAudio_SDLCloseAudio(JNIEnv * env, jobject obj)
 {
-    (*env)->DeleteWeakGlobalRef(env,objCallback);
+    // FIXME: (*env)->DeleteWeakGlobalRef(env,objCallback);
     SDL_CloseAudio();
 }
 
diff -urN jsdl/sdl/jni/SDLMpeg.c jsdl-kaffe/sdl/jni/SDLMpeg.c
--- jsdl/sdl/jni/SDLMpeg.c	2001-05-28 01:12:17.000000000 +0800
+++ jsdl-kaffe/sdl/jni/SDLMpeg.c	2004-03-18 14:11:07.000000000 +0800
@@ -1,5 +1,5 @@
 #include "SDLMpeg.h"
-#include "smpeg.h"
+#include <smpeg.h>
 #include "Accessors.h"
 
 #ifdef WIN32
diff -urN jsdl/sdl/jni/SDLSFont.c jsdl-kaffe/sdl/jni/SDLSFont.c
--- jsdl/sdl/jni/SDLSFont.c	2002-07-23 09:21:18.000000000 +0800
+++ jsdl-kaffe/sdl/jni/SDLSFont.c	2004-03-18 15:08:58.000000000 +0800
@@ -47,7 +47,7 @@
     
     lenString = (*env)->GetStringLength(env,s);
     str = (char *)malloc(sizeof(char)*(lenString + 1));
-    (*env)->GetStringUTFRegion(env,s,0,lenString,str);
+    // FIXME: (*env)->GetStringUTFRegion(env,s,0,lenString,str);
 
     PutString(surface,x,y,str);
 
@@ -64,7 +64,7 @@
     char *str=NULL;
     lenString = (*env)->GetStringLength(env,s);
     str = (char *)malloc(sizeof(char)*(lenString + 1));
-    (*env)->GetStringUTFRegion(env,s,0,lenString,str);
+    // FIXME: (*env)->GetStringUTFRegion(env,s,0,lenString,str);
     
     return (jint)TextWidth(str);
 
@@ -89,7 +89,7 @@
     
     lenString = (*env)->GetStringLength(env,s);
     str = (char *)malloc(sizeof(char)*(lenString + 1));
-    (*env)->GetStringUTFRegion(env,s,0,lenString,str);
+    // FIXME: (*env)->GetStringUTFRegion(env,s,0,lenString,str);
 
 
     XCenteredString (surface,y,str);
@@ -113,7 +113,7 @@
     surface = ((JSDLSurface *)handle)->surface;
     lenString = (*env)->GetStringLength(env,s);
     str = (char *)malloc(sizeof(char)*(lenString + 1));
-    (*env)->GetStringUTFRegion(env,s,0,lenString,str);
+    // FIXME: (*env)->GetStringUTFRegion(env,s,0,lenString,str);
     
     SFont_Input(surface,x,y,width,str);
     DBG1("--JNI-- SDLSFont:getInputString Before setting m_INputString \n");
diff -urN jsdl/sdl/jni/SDLWindow.c jsdl-kaffe/sdl/jni/SDLWindow.c
--- jsdl/sdl/jni/SDLWindow.c	2001-05-28 01:12:17.000000000 +0800
+++ jsdl-kaffe/sdl/jni/SDLWindow.c	2004-03-18 15:09:21.000000000 +0800
@@ -22,8 +22,8 @@
     lenIcon = (*env)->GetStringLength(env,icon);
     strTitle = (char *)malloc(sizeof(char)*(lenTitle +1));
     strIcon = (char *)malloc(sizeof(char)*(lenIcon + 1));
-    (*env)->GetStringUTFRegion(env,icon,0,lenIcon,strIcon);
-    (*env)->GetStringUTFRegion(env,title,0,lenTitle,strTitle);
+    // FIXME: (*env)->GetStringUTFRegion(env,icon,0,lenIcon,strIcon);
+    // FIXME: (*env)->GetStringUTFRegion(env,title,0,lenTitle,strTitle);
 
     SDL_WM_SetCaption(strTitle,strIcon);
 


More information about the kaffe mailing list