annotate TaskManager/Test/test_render/viewerSDL.cpp @ 174:559b48b69b76

getScale()、getTapestry から、span->length に適切なテクスチャの選択に成功
author gongo@localhost.localdomain
date Fri, 12 Dec 2008 12:23:20 +0900
parents d1f2ce3bdb2f
children 897aeb144569
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
170
d1f2ce3bdb2f fix ViewerSDL
gongo@localhost.localdomain
parents: 169
diff changeset
20 screen = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE);
109
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
170
d1f2ce3bdb2f fix ViewerSDL
gongo@localhost.localdomain
parents: 169
diff changeset
27 p = (Uint32*)manager->malloc(screen->pitch*height);
169
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 168
diff changeset
28 bitmap = SDL_CreateRGBSurfaceFrom((void *)p,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 168
diff changeset
29 screen->w, screen->h,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 168
diff changeset
30 screen->format->BitsPerPixel,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 168
diff changeset
31 screen->pitch,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 168
diff changeset
32 redMask, greenMask, blueMask, alphaMask);
170
d1f2ce3bdb2f fix ViewerSDL
gongo@localhost.localdomain
parents: 169
diff changeset
33
d1f2ce3bdb2f fix ViewerSDL
gongo@localhost.localdomain
parents: 169
diff changeset
34 pixels = p;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
38 ViewerSDL::clean_pixels()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
39 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
40 //bzero(pixels, sizeof(int)*width*height);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
41 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44 ViewerSDL::run_loop(void)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
45 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
46 SDL_BlitSurface(bitmap, NULL, screen, NULL);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
47 SDL_UpdateRect(screen, 0, 0, 0, 0);
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 {
170
d1f2ce3bdb2f fix ViewerSDL
gongo@localhost.localdomain
parents: 169
diff changeset
55 free(bitmap->pixels);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 SDL_FreeSurface(bitmap);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
57
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
58 Viewer::run_finish();
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 }