annotate TaskManager/Test/test_render/viewerSDL.cpp @ 141:56db76a03294 draft

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