implement shooting gunturrets
[rofl0r-openDOW.git] / video.c
blob0a3fba02adda035c624e6620dec30111f91b0444
1 #include "video.h"
2 #include <stdbool.h>
4 SDL_Surface *surface;
5 bool fullscreen_active;
6 struct vo_desc video;
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);
31 #include "sdl_rgb.h"
32 void clear_screen(void) {
33 sdl_rgb_t *ptr = (sdl_rgb_t *) surface->pixels;
34 unsigned pitch = surface->pitch/4;
35 unsigned x, y;
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);
43 SDL_Delay(1);
44 clear_screen();
45 SDL_UpdateRect(surface,0,0,VMODE_W,VMODE_H);
46 SDL_Delay(1);