}
}
+static void R_reload_textures (void);
+
void R_set_videomode (int w, int h, int fullscreen) {
assert(w > 0);
assert(h > 0);
if (fullscreen) {
flags |= SYSTEM_USE_FULLSCREEN;
}
+ if (root != NULL) {
+ R_cache_free(root, 0);
+ root = NULL;
+ }
int res = Y_set_videomode(w, h, flags);
if (res == 0) {
if (was == 0) {
ERR_failinit("Unable to set video mode\n");
}
} else {
- SCRW = w;
- SCRH = h;
+ Y_get_videomode(&SCRW, &SCRH);
+ root = R_cache_new();
+ assert(root);
+ R_alloc();
+ R_reload_textures();
}
}
void R_toggle_fullscreen (void) {
+ R_cache_free(root, 0);
Y_set_fullscreen(!Y_get_fullscreen());
fullscreen = Y_get_fullscreen();
+ Y_get_videomode(&SCRW, &SCRH);
+ root = R_cache_new();
+ assert(root);
+ R_alloc();
+ R_reload_textures();
}
void R_init (void) {
logo("R_init: intialize opengl render\n");
R_init_playpal();
R_set_videomode(SCRW, SCRH, fullscreen);
- root = R_cache_new();
- assert(root);
- R_alloc();
}
void R_done (void) {
return walp[n].res == -2 ? (intptr_t)walp[n].n : -1;
}
+static void R_reload_textures (void) {
+ int i;
+ char s[8];
+ for (i = 0; i < max_textures; i++) {
+ R_get_name(i, s);
+ if (walp[i].res >= 0) {
+ walp[i] = R_gl_getimage(walp[i].res);
+ }
+ }
+ horiz = R_gl_getimage(horiz.res);
+}
+
void R_begin_load (void) {
int i;
for (i = 0; i < 256; i++) {
if (k >= 256) {
k = j;
j += 1;
+ max_textures += 1;
walp[k] = R_gl_getimage(g);
walf[k] = g & 0x8000 ? 1 : 0;
}
return s != NULL;
}
+void Y_get_videomode (int *w, int *h) {
+ if (surf != NULL) {
+ *w = surf->w;
+ *h = surf->h;
+ } else {
+ *w = 0;
+ *h = 0;
+ }
+}
+
int Y_videomode_setted (void) {
return surf != NULL;
}
SDL_InitSubSystem(SDL_INIT_VIDEO);
}
-int Y_set_fullscreen (int yes) {
- //SDL_WM_ToggleFullScreen();
- return 0;
+void Y_set_fullscreen (int yes) {
+ assert(surf != NULL);
+ Uint32 flags = surf->flags & ~SDL_FULLSCREEN;
+ if ((surf->flags & SDL_FULLSCREEN) == 0) {
+ flags |= SDL_FULLSCREEN;
+ }
+ Y_set_videomode(surf->w, surf->h, flags);
}
int Y_get_fullscreen (void) {
}
}
+void Y_get_videomode (int *w, int *h) {
+ if (window != NULL) {
+ SDL_GetWindowSize(window, w, h);
+ } else {
+ *w = 0;
+ *h = 0;
+ }
+}
+
int Y_videomode_setted (void) {
return window != NULL;
}
ERR_failinit("Unable to set video mode");
}
} else {
- SCRW = w;
- SCRH = h;
+ Y_get_videomode(&SCRW, &SCRH);
Y_get_buffer(&buffer, &buf_w, &buf_h, &pitch);
+ R_setgamma(gammaa);
}
}
void R_toggle_fullscreen (void) {
Y_set_fullscreen(!Y_get_fullscreen());
fullscreen = Y_get_fullscreen();
+ Y_get_videomode(&SCRW, &SCRH);
+ Y_get_buffer(&buffer, &buf_w, &buf_h, &pitch);
+ R_setgamma(gammaa);
}
void R_init () {
F_loadres(F_getresid("MIXMAP"), mixmap, 0, 0x10000);
F_loadres(F_getresid("COLORMAP"), clrmap, 0, 256*12);
R_set_videomode(SCRW, SCRH, fullscreen);
- R_setgamma(gammaa);
V_setrect(0, SCRW, 0, SCRH);
V_clr(0, SCRW, 0, SCRH, 0);
R_alloc();
void V_setrect (short x, short w, short y, short h) {
cx1 = max(x, 0);
- cx2 = min(x + w - 1, SCRW - 1);
+ cx2 = min(x + w - 1, buf_w - 1);
cy1 = max(y, 0);
- cy2 = min(y + h - 1, SCRH - 1);
+ cy2 = min(y + h - 1, buf_h - 1);
}
static void putpixel (int x, int y, byte color) {
void V_center (int f) {
if (f) {
- V_offset(SCRW / 2 - 320 / 2, SCRH / 2 - 200 / 2);
+ V_offset(buf_w / 2 - 320 / 2, buf_h / 2 - 200 / 2);
} else {
V_offset(0, 0);
}
/* common video subsystem routines */
int Y_set_videomode (int w, int h, int flags);
+void Y_get_videomode (int *w, int *h);
int Y_videomode_setted (void);
void Y_unset_videomode (void);
-int Y_set_fullscreen (int yes);
+void Y_set_fullscreen (int yes);
int Y_get_fullscreen (void);
/* hardware specific rendering */