annotate TaskManager/Test/test_render/viewerSDL.cpp @ 132:e7c80537b6aa

add XML
author gongo@charles.cr.ie.u-ryukyu.ac.jp
date Tue, 25 Nov 2008 18:19:53 +0900
parents 5c194c71eca8
children cf2aa37d2fe7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include "viewerSDL.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include "Func.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include "TaskManager.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 extern void post2runLoop(void *);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 extern
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
8
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 ViewerSDL::video_init()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12 Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 Uint32 *p;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
15 if (SDL_Init(sdl_flag) < 0) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
16 fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError());
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17 exit(1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 screen = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 if (screen == NULL) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23 SDL_Quit();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 exit(1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
26
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
27 pixels = (Uint32*)screen->pixels;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
28
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
29 p = (Uint32*)manager->malloc(sizeof(int)*width*height);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
30 bitmap = SDL_CreateRGBSurfaceFrom((void *)p, width, height, 32,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
31 width*4, redMask, greenMask,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 blueMask, alphaMask);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
33 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 ViewerSDL::clean_pixels()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 //bzero(pixels, sizeof(int)*width*height);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 ViewerSDL::run_loop(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 #if !defined(__LINUX__)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 SDL_BlitSurface(bitmap, NULL, screen, NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 SDL_UpdateRect(screen, 0, 0, 0, 0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 #endif
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
48
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 Viewer::run_loop();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
50 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
51
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
52 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
53 ViewerSDL::run_finish(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
54 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
55 SDL_FreeSurface(bitmap);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57 Viewer::run_finish();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 }