Mercurial > hg > Game > Cerium
annotate TaskManager/Test/test_render/viewerSDL.cc @ 526:413667c70a1d draft
fix
author | tkaito@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 22 Oct 2009 01:31:09 +0900 |
parents | 0d2dc1869cbe |
children |
rev | line source |
---|---|
109 | 1 #include "viewerSDL.h" |
2 #include "Func.h" | |
3 #include "TaskManager.h" | |
4 | |
5 extern void post2runLoop(void *); | |
6 | |
7 extern | |
8 | |
9 void | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
10 ViewerSDL::video_init(TaskManager *manager) |
109 | 11 { |
12 Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; | |
13 Uint32 *p; | |
14 | |
15 if (SDL_Init(sdl_flag) < 0) { | |
16 fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError()); | |
17 exit(1); | |
18 } | |
19 | |
170 | 20 screen = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE); |
109 | 21 if (screen == NULL) { |
22 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); | |
23 SDL_Quit(); | |
24 exit(1); | |
25 } | |
26 | |
217 | 27 p = (Uint32*)manager->allocate(screen->pitch*height); |
169 | 28 bitmap = SDL_CreateRGBSurfaceFrom((void *)p, |
29 screen->w, screen->h, | |
30 screen->format->BitsPerPixel, | |
31 screen->pitch, | |
32 redMask, greenMask, blueMask, alphaMask); | |
170 | 33 |
34 pixels = p; | |
109 | 35 } |
36 | |
37 void | |
38 ViewerSDL::clean_pixels() | |
39 { | |
40 //bzero(pixels, sizeof(int)*width*height); | |
222 | 41 SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0)); |
109 | 42 } |
43 | |
44 void | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
45 ViewerSDL::run_loop(HTaskPtr task_next) |
109 | 46 { |
47 SDL_BlitSurface(bitmap, NULL, screen, NULL); | |
48 SDL_UpdateRect(screen, 0, 0, 0, 0); | |
49 | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
50 Viewer::run_loop(task_next); |
109 | 51 } |
52 | |
53 void | |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
222
diff
changeset
|
54 ViewerSDL::run_finish() |
109 | 55 { |
170 | 56 free(bitmap->pixels); |
109 | 57 SDL_FreeSurface(bitmap); |
58 | |
222 | 59 Viewer::run_finish(); |
109 | 60 } |