Mercurial > hg > Members > kono > Cerium
diff old/sdl_test/sdl_test.cc @ 998:ad5232ad4952
add fb_test, minor fix
author | yutaka@localhost.localdomain |
---|---|
date | Fri, 15 Oct 2010 02:13:55 +0900 |
parents | 78ebcdaae8bc |
children |
line wrap: on
line diff
--- a/old/sdl_test/sdl_test.cc Thu Oct 14 18:05:27 2010 +0900 +++ b/old/sdl_test/sdl_test.cc Fri Oct 15 02:13:55 2010 +0900 @@ -12,11 +12,13 @@ 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) { @@ -63,18 +65,7 @@ /* バイト単位でのスクリーンのサイズを計算 */ 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; @@ -88,6 +79,7 @@ int main() { fb_t fb = get_fbdev_addr(); + close(fb.fd); void *p; @@ -96,7 +88,6 @@ //posix_memalign((void**)&gUra, 16, fb.width*fb.height*4); gUra = (Uint32*)malloc(fb.width*fb.height*4); - Uint32 *tmp = (Uint32*)malloc(fb.width*fb.height*4); printf("fb.height %d \n", fb.height); @@ -145,8 +136,24 @@ } + 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,alphaMask); + 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);