5 bool fullscreen_active
;
8 void video_init(void) {
9 SDL_Init(SDL_INIT_VIDEO
);
10 surface
= SDL_SetVideoMode(VMODE_W
, VMODE_H
, 32, SDL_RESIZABLE
| SDL_HWPALETTE
);
11 video
.mem
= surface
->pixels
;
12 video
.pitch
= surface
->pitch
;
13 video
.width
= VMODE_W
;
14 video
.height
= VMODE_H
;
15 fullscreen_active
= 0;
18 void video_cleanup(void) {
19 if(fullscreen_active
) SDL_WM_ToggleFullScreen(surface
);
20 SDL_QuitSubSystem(SDL_INIT_VIDEO
);
23 void video_update_region(int x
, int y
, int w
, int h
) {
24 SDL_UpdateRect(surface
, x
, y
, w
, h
);
27 void video_update(void) {
28 SDL_UpdateRect(surface
, 0, 0, video
.width
, video
.height
);
32 void clear_screen(void) {
33 sdl_rgb_t
*ptr
= (sdl_rgb_t
*) surface
->pixels
;
34 unsigned pitch
= surface
->pitch
/4;
36 for(y
= 0; y
< VMODE_H
; y
++) for (x
= 0; x
< VMODE_W
; x
++)
37 ptr
[y
*pitch
+ x
] = SRGB_BLACK
;
40 void toggle_fullscreen(void) {
41 fullscreen_active
= !fullscreen_active
;
42 SDL_WM_ToggleFullScreen(surface
);
45 SDL_UpdateRect(surface
,0,0,VMODE_W
,VMODE_H
);