changeset 995:143e4f9af7be

merge
author yutaka@charles.cr.ie.u-ryukyu.ac.jp
date Mon, 11 Oct 2010 14:22:09 +0900
parents 33616b2789de (diff) 1b018a00cd17 (current diff)
children 78ebcdaae8bc
files
diffstat 4 files changed, 75 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Mon Oct 11 19:42:28 2010 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Mon Oct 11 14:22:09 2010 +0900
@@ -453,12 +453,12 @@
     SDL_Surface *texture_image = IMG_Load(image_name);
     if (!texture_image) return 0;
     SDL_Surface *tmpImage
-        = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
+        = SDL_CreateRGBSurface(SDL_SWSURFACE, texture_image->w,
                                texture_image->h, 32, redMask,
                                greenMask, blueMask, alphaMask);
     SDL_Surface *converted;
     converted = SDL_ConvertSurface(texture_image, tmpImage->format,
-                                   SDL_HWSURFACE);
+                                   SDL_SWSURFACE);
     if (converted != NULL) {
         SDL_FreeSurface(texture_image);
         texture_image = converted;
--- a/Renderer/Engine/spe/DrawSpan.cc	Mon Oct 11 19:42:28 2010 +0900
+++ b/Renderer/Engine/spe/DrawSpan.cc	Mon Oct 11 14:22:09 2010 +0900
@@ -216,14 +216,15 @@
 	     int world_x, int world_y, float world_z, SchedTask *smanager)
 {
 
-    int color = get_rgb(tex_x, tex_y, tile);
+    uint32 color = get_rgb(tex_x, tex_y, tile);
     /*下位4bitを抽出*/
 #if LITTLEENDIAN
     int alpha = color & 0x000000ff;
 #else
     int alpha = color & 0xff000000;
 #endif
-    /*完全に透けているか判断*/
+
+    //完全に透けているか判断
     int flag = (alpha != 0 && normal_z < 0);
     int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch);
     //smanager->printf("sys %d\n",light_sysswitch);
@@ -235,11 +236,9 @@
     }
 
     g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag);
-    int *point = &g->linebuf[localy][localx] ;
+    int *point = &g->linebuf[localy][localx];
     *point =  color*flag + *point *(1-flag);
 
-
-
 }
 
 /**
@@ -514,7 +513,6 @@
 
   }
 
-
     G g0;
     Gptr g = &g0;
 
@@ -566,13 +564,13 @@
             span = &spack->span[t];
 
 	    if (span->length_x != 1) {
-		drawLine1(
-		    smanager, g,
+	      drawLine1(
+	      	    smanager, g,
                     span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
 	    } else {
-		drawDot1(
-		    smanager, g,
-                    span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
+	      drawDot1(
+	          smanager, g,
+	           span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
             }
             next_span = span;
 
--- a/Renderer/Engine/viewer.cc	Mon Oct 11 19:42:28 2010 +0900
+++ b/Renderer/Engine/viewer.cc	Mon Oct 11 14:22:09 2010 +0900
@@ -34,7 +34,7 @@
 
 RederingData r[2];
 
-int  ppi, spi;
+int  ppi, spi = 0;
 
 /**
  *
@@ -293,7 +293,7 @@
 {
     HTaskPtr task_next = initLoop();
 
-    task_next->set_post(&post2runLoop, (void *)this, 0); // set_post(function(this->run_loop()), NULL)
+    task_next->set_post(&post2runLoop, (void *)this, (void*)pixels); // set_post(function(this->run_loop()), NULL)
     task_next->spawn();
 }
 
@@ -311,6 +311,7 @@
     }
 
     dev->clean_pixels();
+
     pixels = dev->flip_screen(pixels);
 
     /* ここでGameTaskの終了を待つTaskを生成しておく */
@@ -357,6 +358,8 @@
 static void
 post2runLoop(SchedTask *s, void *viewer_, void *arg)
 {
+
+
     Viewer *viewer = (Viewer*)viewer_;
     HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
     viewer->run_loop(task_next);
@@ -377,7 +380,7 @@
 {
     common_draw(task_next);
 
-    task_next->set_post(post2runLoop, (void*)this, 0); // set_post(function(this->run_loop()), NULL)
+    task_next->set_post(post2runLoop, (void*)this, (void*)pixels); // set_post(function(this->run_loop()), NULL)
     task_next->spawn();
     // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ    
 
--- a/Renderer/Engine/viewerSDL.cc	Mon Oct 11 19:42:28 2010 +0900
+++ b/Renderer/Engine/viewerSDL.cc	Mon Oct 11 14:22:09 2010 +0900
@@ -2,6 +2,7 @@
 #include "Func.h"
 #include "TaskManager.h"
 #include "viewer_types.h"
+#include "fb.h"
 
 #define UGA 1
 
@@ -12,20 +13,61 @@
 ViewerSDL::ViewerSDL() {}
 ViewerSDL::~ViewerSDL() {}
 
+#define DEVICE_NAME "/dev/fb0"
+#define DIV_BYTE 8
+
 Uint32 *
 ViewerSDL::video_init(TaskManager *manager, int bpp, int width, int height)
 {
+  
+    int fd_framebuffer ;
+    struct fb_var_screeninfo vinfo;
+    struct fb_fix_screeninfo finfo;
+    
+    int xres,yres,vbpp;
+    
+    // 読み書き用にファイルを開く 
+    fd_framebuffer = open( DEVICE_NAME , O_RDWR);
+    if ( !fd_framebuffer ) {
+      send_current_error_msg("Framebuffer device open error !");
+      exit(1);
+    }
+    send_current_information("The framebuffer device was opened !");
+	
+    // 固定スクリーン情報取得 
+    if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) {
+	    send_current_error_msg("Fixed information not gotton !");
+	    exit(2);
+    }
+    
+    // 変動スクリーン情報取得 
+    if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) {
+      send_current_error_msg("Variable information not gotton !");
+      exit(3);
+    }
+
+    close(fd_framebuffer);
+
+    xres = vinfo.xres;
+    yres = vinfo.yres;
+    vbpp = vinfo.bits_per_pixel;
+
+    width = xres;
+    height = yres;
+    bpp = vbpp;
+
+        
     Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO;
     Uint32 *p;
-
+	
     if (SDL_Init(sdl_flag) < 0) {
 	fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError());
 	exit(1);
     }
 
-    screen = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE);
+    screen = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE);
     if (screen == NULL) {
-	fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
+	fprintf(stderr, "Couldn't set SDL mode: %s\n", SDL_GetError());
 	SDL_Quit();
 	exit(1);
     }
@@ -34,11 +76,6 @@
     this->bpp = screen->format->BitsPerPixel;
     
     p = (Uint32*)manager->allocate(screen->pitch*height);
-    bitmap = SDL_CreateRGBSurfaceFrom((void *)p,
-				      screen->w, screen->h,
-				      screen->format->BitsPerPixel,
-				      screen->pitch,
-				      redMask, greenMask, blueMask, alphaMask);
 
     return p;
 }
@@ -47,25 +84,37 @@
 ViewerSDL::clean_pixels()
 {
     //bzero(pixels, sizeof(int)*width*height);
-    SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
+    //SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
 }
 
 void
 ViewerSDL::clear_screen()
 {
+
 #if !UGA
     SDL_BlitSurface(bitmap, NULL, screen, NULL);
     SDL_UpdateRect(screen, 0, 0, 0, 0);        
 #endif
+
 }
 
 uint32_t *
 ViewerSDL::flip_screen(uint32_t *old)
 {
 #if UGA
+
+    bitmap = SDL_CreateRGBSurfaceFrom((void *)old,
+				      screen->w, screen->h,
+				      screen->format->BitsPerPixel,
+				      screen->pitch,
+				      //redMask, greenMask, blueMask, alphaMask);
+				      redMask, greenMask, blueMask, 0);
+
     SDL_BlitSurface(bitmap,NULL,screen,NULL);
     SDL_UpdateRect(screen,0,0,0,0);
+
 #endif
+
     return old;
 }