return (*env)->FindClass(env, "Lsdl/VideoInfo;");
}
-jint getSDL_SurfacePointer(JNIEnv *env, jobject surface){
+SDL_Surface* getSDL_SurfacePointer(JNIEnv *env, jobject surface){
jobject sdl_surface_obj = (*env)->GetObjectClass(env, surface);
jclass sdl_surface = getSDL_Surface(env);
jfieldID fld_pointer = (*env)->GetFieldID(env, sdl_surface, "pointer", "I");
jint pointer = (*env)->GetIntField(env, surface, fld_pointer);
- return pointer;
+ return (SDL_Surface*)pointer;
}
return driver_name;
}
-JNIEXPORT jobject JNICALL Java_sdl_SDL_listModes(JNIEnv *env, jobject obj){
+JNIEXPORT jobjectArray JNICALL Java_sdl_SDL_listModes(JNIEnv *env, jobject obj, jobject format, jint flags){
+
}
JNIEXPORT jint JNICALL Java_sdl_SDL_videoModeOK(JNIEnv *env, jobject obj, jint width, jint height, jint bpp, jlong flags){
jobject sdl_surface_obj = (*env)->GetObjectClass(env, surface);
jclass sdl_surface = getSDL_Surface(env);
jfieldID fld_pointer = (*env)->GetFieldID(env, sdl_surface, "pointer", "I");
- jint surface_pointer = (*env)->GetIntField(env, surface, fld_pointer);
+ SDL_Surface* surface_pointer = (SDL_Surface*)(*env)->GetIntField(env, surface, fld_pointer);
- return SDL_Flip((SDL_Surface*)surface_pointer);
+ return SDL_Flip(surface_pointer);
}
JNIEXPORT jint JNICALL Java_sdl_SDL_setColors(JNIEnv *env, jobject obj, jobject surface, jobjectArray colors, jint firstcolor, jint ncolors){
- jint surface_pointer = getSDL_SurfacePointer(env, surface);
+ SDL_Surface* surface_pointer = getSDL_SurfacePointer(env, surface);
jclass color_class = getSDL_Color(env);
jfieldID fld_r = (*env)->GetFieldID(env, color_class, "r", "I");
sdl_colors[i].g = color_g;
sdl_colors[i].b = color_b;
}
- return SDL_SetColors((SDL_Surface*)surface_pointer, sdl_colors, firstcolor, ncolors);
+ return SDL_SetColors(surface_pointer, sdl_colors, firstcolor, ncolors);
}
JNIEXPORT jint JNICALL Java_sdl_SDL_setPalette(JNIEnv *env, jobject obj, jobject surface, jint flags, jobjectArray colors, jint firstcolor, jint ncolors){
- jint surface_pointer = getSDL_SurfacePointer(env, surface);
+ SDL_Surface* surface_pointer = getSDL_SurfacePointer(env, surface);
jclass color_class = getSDL_Color(env);
jfieldID fld_r = (*env)->GetFieldID(env, color_class, "r", "I");
sdl_colors[i].b = color_b;
}
- return SDL_SetPalette((SDL_Surface*)surface_pointer, flags, sdl_colors, firstcolor, ncolors);
+ return SDL_SetPalette(surface_pointer, flags, sdl_colors, firstcolor, ncolors);
}
jobject sdl_surface_obj = (*env)->GetObjectClass(env, surface);
jclass sdl_surface = getSDL_Surface(env);
jfieldID fld_pointer = (*env)->GetFieldID(env, sdl_surface, "pointer", "I");
- jint surface_pointer = (*env)->GetIntField(env, surface, fld_pointer);
- return SDL_LockSurface((SDL_Surface*)surface_pointer);
+ SDL_Surface* surface_pointer = (SDL_Surface*)(*env)->GetIntField(env, surface, fld_pointer);
+ return SDL_LockSurface(surface_pointer);
}
JNIEXPORT void JNICALL Java_sdl_SDL_unlockSurface(JNIEnv *env, jobject obj, jobject surface){
jobject sdl_surface_obj = (*env)->GetObjectClass(env, surface);
jclass sdl_surface = getSDL_Surface(env);
jfieldID fld_pointer = (*env)->GetFieldID(env, sdl_surface, "pointer", "I");
- jint surface_pointer = (*env)->GetIntField(env, surface, fld_pointer);
- SDL_UnlockSurface((SDL_Surface*)surface_pointer);
+ SDL_Surface* surface_pointer = (SDL_Surface*)(*env)->GetIntField(env, surface, fld_pointer);
+ SDL_UnlockSurface(surface_pointer);
return;
}
+SDL_Rect* createSDL_Rect(JNIEnv* env, jobject rect_obj){
+ jclass sdl_rect = getSDL_Rect(env);
+ jfieldID fld_x = (*env)->GetFieldID(env, sdl_rect, "x", "I");
+ jfieldID fld_y = (*env)->GetFieldID(env, sdl_rect, "y", "I");
+ jfieldID fld_w = (*env)->GetFieldID(env, sdl_rect, "w", "I");
+ jfieldID fld_h = (*env)->GetFieldID(env, sdl_rect, "h", "I");
+
+ jint rect_x = (*env)->GetIntField(env, rect_obj, fld_x);
+ jint rect_y = (*env)->GetIntField(env, rect_obj, fld_y);
+ jint rect_w = (*env)->GetIntField(env, rect_obj, fld_w);
+ jint rect_h = (*env)->GetIntField(env, rect_obj, fld_h);
+
+ SDL_Rect* ret_rect;
+ ret_rect->x = rect_x;
+ ret_rect->y = rect_y;
+ ret_rect->w = rect_w;
+ ret_rect->h = rect_h;
+
+ return ret_rect;
+}
+
+JNIEXPORT jint JNICALL Java_sdl_SDL_blitSurface(JNIEnv *env, jobject obj, jobject src, jobject srcrect, jobject dst, jobject dstrect){
+ jclass sdl_surface = getSDL_Surface(env);
+
+ SDL_Rect* srcrect2 = createSDL_Rect(env, srcrect);
+ SDL_Rect* dstrect2 = createSDL_Rect(env, dstrect);
+ SDL_Surface* src2 = getSDL_SurfacePointer(env, src);
+ SDL_Surface* dst2 = getSDL_SurfacePointer(env, dst);
+
+ return SDL_BlitSurface(src2, srcrect2, dst2, dstrect2);
+}
+
/**
* Window Management
def getVideoSurface():Surface = return sdl.getVideoSurface()
def getVideoInfo():VideoInfo = return sdl.getVideoInfo()
def videoDriverName():String = return sdl.videoDriverName()
- def listModes(format:PixelFormat, flags:Int):Rect = return sdl.listModes(format, flags)
+ def listModes(format:PixelFormat, flags:Int):Array[Rect] = return sdl.listModes(format, flags)
+ def videoModeOK(width:Int, height:Int, bpp:Int, flags:Int):Int = return sdl.videoModeOK(width,height,bpp,flags)
def setVideoMode(width:Int, height:Int, bitsperpixel:Int, flags:Int):Surface = return sdl.setVideoMode(width, height, bitsperpixel, flags)
def flip(surface:Surface):Int = sdl.flip(surface)
def setColors(surface:Surface, colors:Array[Color], firstcolor:Int, ncolor:Int):Int = return sdl.setColors(surface, colors, firstcolor, ncolor)
//char* SDL_VideoDriverName(char* namebuf, int maxlen)
@native def videoDriverName():String
//SDL_Rect** SDL_ListModes(SDL_PixelFormat* format, Unit32 flags)
- @native def listModes(format:PixelFormat, flags:Int):Rect
+ @native def listModes(format:PixelFormat, flags:Int):Array[Rect]
//int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
@native def videoModeOK(width:Int, height:Int, bpp:Int, flags:Long):Int
//SDL_Surface* setVideoMode(int width, int height, int bitsperpixel, Uint32 flags)
//SDL_Surface *SDL_ConvertSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags)
//SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface)
//SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface)
+ //SDL_Surface *SDL_LoadBMP(const char *file)
+ @native def loadBMP(file:String):Surface
//int SDL_SaveBMP(SDL_Surface *surface, const char *file)
+ @native def saveBMP(surface:Surface, file:String):Int
//int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
+ @native def setColorKey(surface:Surface, flag:Int, key:Int):Int
//int SDL_SetAlpha(SDL_Surface *surface, Uint32 flags, Uint8 alpha)
//void SDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect)
//void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)