summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8191e06)
raw | patch | inline | side by side (parent: 8191e06)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 1 Apr 2020 07:45:56 +0000 (11:45 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 1 Apr 2020 07:45:56 +0000 (11:45 +0400) |
src/gl/render.c | patch | blob | history | |
src/sdl/main.c | patch | blob | history | |
src/sdl2/main.c | patch | blob | history | |
src/soft/render.c | patch | blob | history | |
src/soft/vga.c | patch | blob | history | |
src/system.h | patch | blob | history |
diff --git a/src/gl/render.c b/src/gl/render.c
index 73ce92a4390892e76009478be58d04f916003c08..b2c625fb4f57ec63162c97a027594aa537905cc0 100644 (file)
--- a/src/gl/render.c
+++ b/src/gl/render.c
}
}
+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;
}
diff --git a/src/sdl/main.c b/src/sdl/main.c
index 5706cc75c95c5d490414e2673a56725522e724e7..07dccf98f5fee9198b1f4f748165619438e402b3 100644 (file)
--- a/src/sdl/main.c
+++ b/src/sdl/main.c
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) {
diff --git a/src/sdl2/main.c b/src/sdl2/main.c
index dd5b8d43b2d16947a79291f66e1dc57d9fa9c38f..c1b872ca71a417cf29817d220d91b251dd07e10b 100644 (file)
--- a/src/sdl2/main.c
+++ b/src/sdl2/main.c
}
}
+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;
}
diff --git a/src/soft/render.c b/src/soft/render.c
index aaaea63749ccb2f9d8c947794fa4dd212601cb53..fafe379ded1be470dd0ce583a67ecb133cfe6964 100644 (file)
--- a/src/soft/render.c
+++ b/src/soft/render.c
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();
diff --git a/src/soft/vga.c b/src/soft/vga.c
index d9c77e1e8dea01a24339a990bd5f0da209f503bc..ce83101ec24dbabf5d61fad05295fb9915ca5705 100644 (file)
--- a/src/soft/vga.c
+++ b/src/soft/vga.c
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);
}
diff --git a/src/system.h b/src/system.h
index 37d28541744ca37b8ea4a301d6ba934caddbee9e..445de10cf7cbb1a8bc48bff24c0906a9b696f54c 100644 (file)
--- a/src/system.h
+++ b/src/system.h
/* 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 */