# HG changeset patch # User koba # Date 1288082081 -32400 # Node ID 67ff44a080900b980f97d939d30c80d6ecb5306e # Parent 295b3c79fb4448e21a02aa4a6e0f6fb8c331497f# Parent 61f33945f85d85d8097cb1e1efc616bdca6fc751 add GTaskArray and merge. diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/GTaskArray.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/GTaskArray.cc Tue Oct 26 17:34:41 2010 +0900 @@ -0,0 +1,56 @@ +#include "GTaskArray.h" + +GTaskArray::GTaskArray() +{ + game_task_array = NULL; + game_task = NULL; + + task_id = 0; + task_num = 0; + param_num = 0; + inData_num = 0; + outData_num = 0; +} + +GTaskArray::~GTaskArray() +{ + if (game_task_array !=NULL) { + delete game_task_array; + } + if (game_task !=NULL) { + delete game_task; + } +} + +void +GTaskArray::init(int id, int task, int param, int inData, int outData) +{ + game_task = 0; + + task_id = id; + task_num = task; + param_num = param; + inData_num = inData; + outData_num = outData; +} + +void +GTaskArray::create_task_array(TaskManager *manager) +{ + game_task_array = manager->create_task_array(task_id, task_num, param_num, inData_num, outData_num); + game_task = 0; +} + +void +GTaskArray::next_task_array(int id) +{ + game_task = game_task_array->next_task_array(id, game_task); +} + +void +GTaskArray::finish() +{ + game_task_array->spawn_task_array(game_task->next()); + game_task_array->set_cpu(SPE_ANY); + game_task_array->spawn(); +} diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/GTaskArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Engine/GTaskArray.h Tue Oct 26 17:34:41 2010 +0900 @@ -0,0 +1,37 @@ +/** + * ゲームの TaskArray を管理するクラス + * 取りあえず TaskArray 1つでゲームの Task を格納するようにしてみた + * TaskArray って何?って人は Cerium/example/hello_array や word_count を参照 + **/ + +#ifndef INCLUDED_GTASK_ARRAY +#define INCLUDED_GTASK_ARRAY + +#include "TaskManager.h" + +class GTaskArray; + +class GTaskArray { +public: + GTaskArray(void); + ~GTaskArray(void); + + HTaskPtr game_task_array; + TaskPtr game_task; + + int task_id; + int task_num; + int param_num; + int inData_num; + int outData_num; + + void init(int id, int task, int param, int inData, int outData); + void create_task_array(TaskManager *manager); + void next_task_array(int id); + void finish(); + HTaskPtr get_task_array(){return game_task_array;} +}; + +typedef GTaskArray* GTaskArrayPtr; + +#endif diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/GTaskArray.o Binary file Renderer/Engine/GTaskArray.o has changed diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/SceneGraph.cc --- a/Renderer/Engine/SceneGraph.cc Tue Oct 26 17:29:50 2010 +0900 +++ b/Renderer/Engine/SceneGraph.cc Tue Oct 26 17:34:41 2010 +0900 @@ -453,12 +453,20 @@ SDL_Surface *texture_image = IMG_Load(image_name); if (!texture_image) return 0; SDL_Surface *tmpImage - = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w, - texture_image->h, 32, redMask, - greenMask, blueMask, alphaMask); + = SDL_CreateRGBSurface(SDL_SWSURFACE, texture_image->w, + texture_image->h, 32, redMask, + greenMask, blueMask, alphaMask); + + //= SDL_CreateRGBSurface(SDL_HWSURFACE, 0, + // 0, 32, redMask, + // greenMask, blueMask, alphaMask); + SDL_Surface *converted; converted = SDL_ConvertSurface(texture_image, tmpImage->format, SDL_HWSURFACE); + + //SDL_SetAlpha(converted, 0, 0); + if (converted != NULL) { SDL_FreeSurface(texture_image); texture_image = converted; diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/spe/DrawSpan.cc --- a/Renderer/Engine/spe/DrawSpan.cc Tue Oct 26 17:29:50 2010 +0900 +++ b/Renderer/Engine/spe/DrawSpan.cc Tue Oct 26 17:34:41 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; diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/viewer.cc --- a/Renderer/Engine/viewer.cc Tue Oct 26 17:29:50 2010 +0900 +++ b/Renderer/Engine/viewer.cc Tue Oct 26 17:34:41 2010 +0900 @@ -34,7 +34,7 @@ RederingData r[2]; -int ppi, spi; +int ppi, spi = 0; /** * @@ -292,7 +292,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(); } @@ -310,6 +310,7 @@ } dev->clean_pixels(); + pixels = dev->flip_screen(pixels); sgroot->updateControllerState(); @@ -363,6 +364,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); @@ -383,7 +386,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() を呼ぶ @@ -909,7 +912,7 @@ if (profile) { if (frames % 50 == 49) { - manager->show_profile(); + manager->show_profile(); this_time = get_ticks(); if (this_time != start_time) { printf("\n%f FPS\n", ((((float)frames)*1000.0)/(this_time-start_time))); diff -r 295b3c79fb44 -r 67ff44a08090 Renderer/Engine/viewerSDL.cc --- a/Renderer/Engine/viewerSDL.cc Tue Oct 26 17:29:50 2010 +0900 +++ b/Renderer/Engine/viewerSDL.cc Tue Oct 26 17:34:41 2010 +0900 @@ -2,6 +2,7 @@ #include "Func.h" #include "TaskManager.h" #include "viewer_types.h" +#include "fb.h" #define UGA 1 @@ -12,12 +13,50 @@ 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) { + +#if defined(__linux__) + + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + + // 読み書き用にファイルを開く + 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); + + width = vinfo.xres; + height = vinfo.yres; + bpp = vinfo.bits_per_pixel; + +#endif + 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); @@ -25,20 +64,16 @@ screen = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE); 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); } + this->width = screen->w; this->height = screen->h; 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 +82,38 @@ 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; } diff -r 295b3c79fb44 -r 67ff44a08090 TaskManager/Cell/spe/CellDmaManager.cc --- a/TaskManager/Cell/spe/CellDmaManager.cc Tue Oct 26 17:29:50 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Tue Oct 26 17:34:41 2010 +0900 @@ -4,6 +4,8 @@ #include "Scheduler.h" +unsigned long long alloc_flag = 0; + /** * DMA Load * @@ -110,7 +112,6 @@ { stop_profile(); } - void CellDmaManager::start_profile() { @@ -141,6 +142,9 @@ wait_time = spu_readch(SPU_RdDec); global_busy_time += busy_time - wait_time; spu_writech(SPU_WrDec, 0xffffffff); + + // Measurement of mainMem_alloc + mainMemalloc_time += (alloc_busy_time - wait_time)*alloc_flag; } @@ -151,6 +155,8 @@ *counter += 0xffffffff - wait_time; busy_time = wait_time; + // Measurement of mainMem_alloc + alloc_busy_time = wait_time; } void CellDmaManager::null_start_dmawait_profile() {} @@ -177,15 +183,18 @@ " mail_time = %lld(%.3g%%), " " busy_ratio = %.3g%%" " array_load_time = %lld\n" + " mainMem_alloc_time = %lld\n" ,cpu, global_busy_time, global_wait_time, d, global_mail_time, m, r, - task_array_load_time); + task_array_load_time, + mainMemalloc_time); global_busy_time = 0; global_mail_time = 0; global_wait_time = 0; task_array_load_time = 0; - + mainMemalloc_time = 0; + alloc_flag = 0; } diff -r 295b3c79fb44 -r 67ff44a08090 TaskManager/Cell/spe/CellDmaManager.h --- a/TaskManager/Cell/spe/CellDmaManager.h Tue Oct 26 17:29:50 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.h Tue Oct 26 17:34:41 2010 +0900 @@ -24,8 +24,8 @@ CellDmaManager() ; /* variables */ - unsigned int wait_time, busy_time; - unsigned long long global_busy_time, global_wait_time, global_mail_time; + unsigned int wait_time, busy_time, alloc_busy_time; + unsigned long long global_busy_time, global_wait_time, global_mail_time, mainMemalloc_time; unsigned long long task_array_load_time; /* functions */ diff -r 295b3c79fb44 -r 67ff44a08090 TaskManager/Cell/spe/CellScheduler.cc --- a/TaskManager/Cell/spe/CellScheduler.cc Tue Oct 26 17:29:50 2010 +0900 +++ b/TaskManager/Cell/spe/CellScheduler.cc Tue Oct 26 17:34:41 2010 +0900 @@ -6,6 +6,7 @@ // ユーザプログラムで定義 // なんだけど、それは微妙じゃね? extern void task_init(Scheduler *scheduler); +extern unsigned long long alloc_flag; void CellScheduler::init_impl() @@ -30,6 +31,9 @@ CellScheduler::mainMem_alloc(int id, int size) { mainMemList[id] = (memaddr)NULL; + + // flag on. (unsigned long long) + alloc_flag = 1; mainMemNum++; mail_write((memaddr)MY_SPE_COMMAND_MALLOC); diff -r 295b3c79fb44 -r 67ff44a08090 old/sdl_test/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/Makefile Tue Oct 26 17:34:41 2010 +0900 @@ -0,0 +1,11 @@ +all: sdl_test fb_test + +sdl_test: sdl_test.cc + g++ -O9 `sdl-config --libs --cflags` -o sdl_test sdl_test.cc + +fb_test: fb_test.cc + g++ -O9 `sdl-config --libs --cflags` -o fb_test fb_test.cc + +clean: + rm -f sdl_test *.o + rm -f fb_test *.o \ No newline at end of file diff -r 295b3c79fb44 -r 67ff44a08090 old/sdl_test/fb.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/fb.h Tue Oct 26 17:34:41 2010 +0900 @@ -0,0 +1,33 @@ +#ifndef FB_H +#define FB_H + +#define DEVICE_NAME "/dev/fb0" +#define DIV_BYTE 8 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct fb_t { + + char *pixels; + int size; + int width; + int height; + int bpp; + int fd; + +}; + +/* function prototype */ +void send_current_error_msg(const char *ptr); +void send_current_information(const char *ptr); +fb_t get_fbdev_addr(void); + +#endif diff -r 295b3c79fb44 -r 67ff44a08090 old/sdl_test/fb_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/fb_test.cc Tue Oct 26 17:34:41 2010 +0900 @@ -0,0 +1,181 @@ +#include "fb.h" +#include +using namespace std; + +void send_current_error_msg(const char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} + +void send_current_information(const char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); +} + +const int redMask = 0x00ff0000; +const int greenMask = 0x0000ff00; +const int blueMask = 0x000000ff; +const int alphaMask = 0xff000000; + +fb_t +get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + //long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + //int x , y ; + int xres,yres,vbpp,line_len; + //unsigned short tcolor ; + + /* 読み書き用にファイルを開く */ + 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); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + printf("vinfo.yres %d \n", vinfo.yres); + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + sprintf( tmp , "%d(xoffset)x%d(yoffset)",vinfo.xoffset, vinfo.yoffset); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + /* デバイスをメモリにマップする */ + fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); + if ( (int)fbptr == -1 ) { + send_current_error_msg("Don't get framebuffer device to memory !"); + exit(4); + } + send_current_information("The framebuffer device was mapped !"); + + printf("fb: 0x%x \n", (unsigned int)fbptr); + + fb_t fb; + fb.pixels = fbptr; + fb.size = screensize; + fb.width = xres; + fb.height = yres; + fb.bpp = vbpp; + fb.fd = fd_framebuffer; + + return fb; + +} + +int main() { + + fb_t fb = get_fbdev_addr(); + + void *p; + Uint32 *gUra; + + gUra = (Uint32*)fb.pixels; + //gUra = (Uint32*)malloc(fb.width*fb.height*4); + + printf("fb.height %d \n", fb.height); + + int i; + int color = 0; + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + + //初期化 + if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK ) < 0) { + printf("SDL_Init failed\n"); + return -1; + } + + printf("fb.width %d fb.height %d fb.bpp %d \n",fb.width, fb.height, fb.bpp); + + SDL_Surface *screen=SDL_SetVideoMode(fb.width,fb.height,fb.bpp,SDL_HWSURFACE); + if (screen == NULL) { + printf("SDL_Surface failed\n"); + SDL_Quit(); + return -1; + } + + int done = 0; + SDL_Event event; + + int fps=0; + + Uint32 t1=SDL_GetTicks(); + + while(!done){ + while(SDL_PollEvent(&event)){ + switch(event.type){ + case SDL_QUIT: + done = 1; + break; + case SDL_KEYDOWN: + if(event.key.keysym.sym == SDLK_ESCAPE){ + done = 1; + } + break; + } + } + + if (color == 0xffffffff) { + color = 0; + } else { + + char r = ((color & redMask) >> 16) + 1; + char g = ((color & greenMask) >> 8) + 1; + char b = (color & blueMask) + 1; + + color = alphaMask + (r << 16) + (g << 8) + b; + + } + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + + if (SDL_GetTicks() < t1 + 1000){ + fps++; + } else{ + printf("fps=%d\n", fps); + fps=0; + t1=SDL_GetTicks(); + } + } + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = 0; + } + munmap(fb.pixels, fb.size); + close(fb.fd); + SDL_Quit(); + + + return 0; + +} + diff -r 295b3c79fb44 -r 67ff44a08090 old/sdl_test/sdl_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/old/sdl_test/sdl_test.cc Tue Oct 26 17:34:41 2010 +0900 @@ -0,0 +1,175 @@ +#include "fb.h" +#include +using namespace std; + +void send_current_error_msg(const char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} + +void send_current_information(const char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); +} + + +const int redMask = 0x00ff0000; +const int greenMask = 0x0000ff00; +const int blueMask = 0x000000ff; +const int alphaMask = 0xff000000; + + +fb_t +get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + //long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + //int x , y ; + int xres,yres,vbpp,line_len; + //unsigned short tcolor ; + + /* 読み書き用にファイルを開く */ + 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); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + printf("vinfo.yres %d \n", vinfo.yres); + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + sprintf( tmp , "%d(xoffset)x%d(yoffset)",vinfo.xoffset, vinfo.yoffset); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + fb_t fb; + fb.size = screensize; + fb.width = xres; + fb.height = yres; + fb.bpp = vbpp; + fb.fd = fd_framebuffer; + + return fb; + +} + +int main() { + + fb_t fb = get_fbdev_addr(); + + close(fb.fd); + + void *p; + Uint32 *gUra; + + //posix_memalign((void**)&gUra, 16, fb.width*fb.height*4); + + gUra = (Uint32*)malloc(fb.width*fb.height*4); + + printf("fb.height %d \n", fb.height); + + int i; + int color = 0x000000ff; + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + + //初期化 + if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK ) < 0) { + printf("SDL_Init failed\n"); + return -1; + } + + printf("fb.width %d fb.height %d fb.bpp %d \n",fb.width, fb.height, fb.bpp); + + SDL_Surface *screen=SDL_SetVideoMode(fb.width,fb.height,fb.bpp,SDL_HWSURFACE); + if (screen == NULL) { + printf("SDL_Surface failed\n"); + SDL_Quit(); + return -1; + } + + int done = 0; + SDL_Event event; + + int fps=0; + + Uint32 t1=SDL_GetTicks(); + + while(!done){ + while(SDL_PollEvent(&event)){ + switch(event.type){ + case SDL_QUIT: + done = 1; + break; + case SDL_KEYDOWN: + if(event.key.keysym.sym == SDLK_ESCAPE){ + done = 1; + } + break; + } + } + + + if (color == 0xffffffff) { + color = 0x000000ff; + } else { + + char r = ((color & redMask) >> 16) + 1; + char g = ((color & greenMask) >> 8) + 1; + char b = (color & blueMask) + 1; + + color = alphaMask + (r << 16) + (g << 8) + b; + + } + + for (i = 0; i < fb.width*fb.height; i++) { + gUra[i] = color; + } + + //ここに処理を追加して変化を見る + SDL_Surface *bitmap = SDL_CreateRGBSurfaceFrom((void *)gUra,fb.width,fb.height,fb.bpp,fb.width*4,redMask,greenMask,blueMask,0); + SDL_BlitSurface(bitmap,NULL,screen,NULL); + SDL_UpdateRect(screen,0,0,0,0); + + + if (SDL_GetTicks() < t1 + 1000){ + fps++; + } else{ + printf("fps=%d\n", fps); + fps=0; + t1=SDL_GetTicks(); + } + } + + SDL_Quit(); + + return 0; + +} +