OSDN Git Service

SDL.fillRectの実装、Rectクラスを修正
authorRoNor <ronoru@users.sourceforge.jp>
Mon, 17 May 2010 17:23:40 +0000 (02:23 +0900)
committerRoNor <ronoru@users.sourceforge.jp>
Mon, 17 May 2010 17:23:40 +0000 (02:23 +0900)
SDL.Rectのコンストラクタ引数にx,y,w,hを取るように変更。
引数が0及び2の時に有効になる補助コンストラクタを追加。

15 files changed:
build/linux/libSDL.so
build/sdl/Color.class
build/sdl/Overlay.class
build/sdl/Palette.class
build/sdl/PixelFormat.class
build/sdl/Rect.class
build/sdl/SDL$.class
build/sdl/SDL.class
build/sdl/Surface.class
build/sdl/Version.class
build/sdl/VideoInfo.class
src/SDL.c
src/SDL.scala
src/SDL_structs.scala
src/sdl_SDL.h

index 114d939..dec6448 100755 (executable)
Binary files a/build/linux/libSDL.so and b/build/linux/libSDL.so differ
index b9fbe04..7092a54 100644 (file)
Binary files a/build/sdl/Color.class and b/build/sdl/Color.class differ
index a1fae41..192c7d4 100644 (file)
Binary files a/build/sdl/Overlay.class and b/build/sdl/Overlay.class differ
index 0cc7fe2..b28755c 100644 (file)
Binary files a/build/sdl/Palette.class and b/build/sdl/Palette.class differ
index c3686f0..1840d51 100644 (file)
Binary files a/build/sdl/PixelFormat.class and b/build/sdl/PixelFormat.class differ
index 3fc681e..68c48ba 100644 (file)
Binary files a/build/sdl/Rect.class and b/build/sdl/Rect.class differ
index deffbce..872e546 100644 (file)
Binary files a/build/sdl/SDL$.class and b/build/sdl/SDL$.class differ
index f591ae4..61fc4bc 100644 (file)
Binary files a/build/sdl/SDL.class and b/build/sdl/SDL.class differ
index 3b32fad..7b71f6b 100644 (file)
Binary files a/build/sdl/Surface.class and b/build/sdl/Surface.class differ
index e746e72..c97d8ac 100644 (file)
Binary files a/build/sdl/Version.class and b/build/sdl/Version.class differ
index c45dbeb..06279b5 100644 (file)
Binary files a/build/sdl/VideoInfo.class and b/build/sdl/VideoInfo.class differ
index 3e7b8cc..7eea45c 100644 (file)
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -453,9 +453,24 @@ SDL_Rect createSDL_Rect(JNIEnv* env, jobject rect_obj){
   return ret_rect;
 }
 
+SDL_Color createSDL_Color(JNIEnv* env, jobject color_obj){
+  jclass sdl_color = getSDL_Color(env);
+  jfieldID fld_r = (*env)->GetFieldID(env, sdl_color, "r", "I");
+  jfieldID fld_g = (*env)->GetFieldID(env, sdl_color, "g", "I");
+  jfieldID fld_b = (*env)->GetFieldID(env, sdl_color, "b", "I");
+
+  jint color_r = (*env)->GetIntField(env, color_obj, fld_r);
+  jint color_g = (*env)->GetIntField(env, color_obj, fld_g);
+  jint color_b = (*env)->GetIntField(env, color_obj, fld_b);
+  SDL_Color color;
+  color.r = color_r;
+  color.g = color_g;
+  color.b = color_b;
+
+  return color;
+}
+
 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);
@@ -464,6 +479,13 @@ JNIEXPORT jint JNICALL Java_sdl_SDL_blitSurface(JNIEnv *env, jobject obj, jobjec
   return SDL_BlitSurface(src2, &srcrect2, dst2, &dstrect2);
 }
 
+JNIEXPORT jint JNICALL Java_sdl_SDL_fillRect(JNIEnv *env, jobject obj, jobject surface, jobject dstrect, jlong color){
+  SDL_Rect dstrect2 = createSDL_Rect(env, dstrect);
+  SDL_Surface* dst_surface = getSDL_SurfacePointer(env, surface);
+  
+  return SDL_FillRect(dst_surface, &dstrect2, (Uint32)color);
+}
+
 
 /**
  * Window Management
index be45a22..d1a2384 100644 (file)
@@ -94,6 +94,8 @@ package sdl {
     def unlockSurface(surface:Surface):Unit = return sdl.unlockSurface(surface)
     def loadBMP(file:String):Surface = return sdl.loadBMP(file)
     def blitSurface(surface:Surface, srcrect:Rect, dst:Surface, dstrect:Rect):Int = sdl.blitSurface(surface, srcrect, dst, dstrect)
+    def fillRect(surface:Surface, dstrect:Rect, color:Long):Int = sdl.fillRect(surface, dstrect, color)
+
 
     //-------------------------------------------------
     // Window Management
@@ -200,6 +202,7 @@ package sdl {
     //int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
     @native def blitSurface(surface:Surface, srcrect:Rect, dst:Surface, dstrect:Rect):Int
     //int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
+    @native def fillRect(surface:Surface, dstrect:Rect, color:Long):Int
     
     //---GL---
     //int SDL_GL_LoadLibrary(const char *path)
index ff6ca09..fe534ca 100644 (file)
@@ -67,11 +67,9 @@ package sdl {
     var unused:Int = 0
   }
 
-  class Rect {
-    var x:Int = 0
-    var y:Int = 0
-    var w:Int = 0
-    var h:Int = 0
+  class Rect(var x:Int, var y:Int, var w:Int, var h:Int) {
+    def this(x:Int, y:Int) = this(x,y,0,0)
+    def this() = this(0,0,0,0)
   }
 
   /**
index 177eef6..611c001 100644 (file)
@@ -265,6 +265,14 @@ JNIEXPORT jint JNICALL Java_sdl_SDL_blitSurface
 
 /*
  * Class:     sdl_SDL
+ * Method:    fillRect
+ * Signature: (Lsdl/Surface;Lsdl/Rect;I)I
+ */
+JNIEXPORT jint JNICALL Java_sdl_SDL_fillRect
+  (JNIEnv *, jobject, jobject, jobject, jlong);
+
+/*
+ * Class:     sdl_SDL
  * Method:    setCaption
  * Signature: (Ljava/lang/String;I)V
  */