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
|
|
20 screen = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE);
|
|
21 if (screen == NULL) {
|
|
22 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
|
|
23 SDL_Quit();
|
|
24 exit(1);
|
|
25 }
|
|
26
|
|
27 pixels = (Uint32*)screen->pixels;
|
|
28
|
|
29 p = (Uint32*)manager->malloc(sizeof(int)*width*height);
|
|
30 bitmap = SDL_CreateRGBSurfaceFrom((void *)p, width, height, 32,
|
|
31 width*4, redMask, greenMask,
|
|
32 blueMask, alphaMask);
|
|
33 }
|
|
34
|
|
35 void
|
|
36 ViewerSDL::clean_pixels()
|
|
37 {
|
|
38 //bzero(pixels, sizeof(int)*width*height);
|
|
39 }
|
|
40
|
|
41 void
|
|
42 ViewerSDL::run_loop(void)
|
|
43 {
|
|
44 #if !defined(__LINUX__)
|
|
45 SDL_BlitSurface(bitmap, NULL, screen, NULL);
|
|
46 SDL_UpdateRect(screen, 0, 0, 0, 0);
|
|
47 #endif
|
|
48
|
|
49 Viewer::run_loop();
|
|
50 }
|
|
51
|
|
52 void
|
|
53 ViewerSDL::run_finish(void)
|
|
54 {
|
|
55 SDL_FreeSurface(bitmap);
|
|
56
|
|
57 Viewer::run_finish();
|
|
58 }
|