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
|
|
10 ViewerSDL::video_init()
|
|
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
|
170
|
27 p = (Uint32*)manager->malloc(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);
|
|
41 }
|
|
42
|
|
43 void
|
|
44 ViewerSDL::run_loop(void)
|
|
45 {
|
|
46 SDL_BlitSurface(bitmap, NULL, screen, NULL);
|
|
47 SDL_UpdateRect(screen, 0, 0, 0, 0);
|
|
48
|
|
49 Viewer::run_loop();
|
|
50 }
|
|
51
|
|
52 void
|
|
53 ViewerSDL::run_finish(void)
|
|
54 {
|
170
|
55 free(bitmap->pixels);
|
109
|
56 SDL_FreeSurface(bitmap);
|
|
57
|
|
58 Viewer::run_finish();
|
|
59 }
|