Mercurial > hg > Members > kono > Cerium
annotate Renderer/Engine/viewerSDL.cc @ 984:df5185513c2d
minor fix
author | root@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Fri, 01 Oct 2010 01:25:45 +0900 |
parents | bed529c55eda |
children | 0b6f8c82625a |
rev | line source |
---|---|
507 | 1 #include "viewerSDL.h" |
2 #include "Func.h" | |
3 #include "TaskManager.h" | |
728 | 4 #include "viewer_types.h" |
507 | 5 |
984 | 6 #define UGA 1 |
7 | |
507 | 8 extern void post2runLoop(void *); |
9 | |
728 | 10 #define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
507 | 11 |
728 | 12 ViewerSDL::ViewerSDL() {} |
13 ViewerSDL::~ViewerSDL() {} | |
14 | |
15 Uint32 * | |
16 ViewerSDL::video_init(TaskManager *manager, int bpp, int width, int height) | |
507 | 17 { |
18 Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; | |
19 Uint32 *p; | |
20 | |
21 if (SDL_Init(sdl_flag) < 0) { | |
22 fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError()); | |
23 exit(1); | |
24 } | |
25 | |
984 | 26 screen = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE); |
507 | 27 if (screen == NULL) { |
28 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); | |
29 SDL_Quit(); | |
30 exit(1); | |
31 } | |
895
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
728
diff
changeset
|
32 this->width = screen->w; |
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
728
diff
changeset
|
33 this->height = screen->h; |
bed529c55eda
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
728
diff
changeset
|
34 this->bpp = screen->format->BitsPerPixel; |
507 | 35 |
36 p = (Uint32*)manager->allocate(screen->pitch*height); | |
37 bitmap = SDL_CreateRGBSurfaceFrom((void *)p, | |
38 screen->w, screen->h, | |
39 screen->format->BitsPerPixel, | |
40 screen->pitch, | |
41 redMask, greenMask, blueMask, alphaMask); | |
42 | |
728 | 43 return p; |
507 | 44 } |
45 | |
46 void | |
47 ViewerSDL::clean_pixels() | |
48 { | |
49 //bzero(pixels, sizeof(int)*width*height); | |
984 | 50 #if !UGA |
507 | 51 SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0)); |
984 | 52 #endif |
507 | 53 } |
54 | |
55 void | |
728 | 56 ViewerSDL::clear_screen() |
507 | 57 { |
984 | 58 #if !UGA |
507 | 59 SDL_BlitSurface(bitmap, NULL, screen, NULL); |
60 SDL_UpdateRect(screen, 0, 0, 0, 0); | |
984 | 61 #endif |
62 } | |
63 | |
64 uint32_t * | |
65 ViewerSDL::flip_screen(uint32_t *old) | |
66 { | |
67 #if UGA | |
68 SDL_BlitSurface(bitmap,NULL,screen,NULL); | |
69 SDL_UpdateRect(screen,0,0,0,0); | |
70 #endif | |
71 return old; | |
507 | 72 } |
73 | |
74 void | |
728 | 75 ViewerSDL::free_device() |
507 | 76 { |
77 free(bitmap->pixels); | |
78 SDL_FreeSurface(bitmap); | |
79 } |