X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgl%2Frender.c;h=41670016fa3872969e352ea937bf684c5ba987cb;hb=c92f6d1da3e71fb18a1c4cd46e7daa899a658b9c;hp=91707ef5d32d2e7af2209a0a61d8c34d44672bb9;hpb=4402c26ec7a3554069c214a648de5130cce3493b;p=flatwaifu.git diff --git a/src/gl/render.c b/src/gl/render.c index 91707ef..4167001 100644 --- a/src/gl/render.c +++ b/src/gl/render.c @@ -1,5 +1,6 @@ #include "glob.h" #include "render.h" +#include "system.h" #include "files.h" #include "memory.h" #include "misc.h" @@ -26,9 +27,10 @@ #else # include #endif -#include // malloc free abs -#include // assert -#include +#include +#include +#include +#include #define VGA_TRANSPARENT_COLOR 0 #define DEFAULT_SKY_COLOR 0x97 @@ -80,7 +82,6 @@ int SCRW = 320; // public int SCRH = 200; // public static int gamma; static int fullscreen; -static SDL_Surface *surf; static rgb playpal[256]; static byte bright[256]; static GLuint lastTexture; @@ -1440,7 +1441,7 @@ void R_draw (void) { break; } GM_draw(); - SDL_GL_SwapBuffers(); + Y_swap_buffers(); } void R_alloc (void) { @@ -1670,19 +1671,22 @@ void R_alloc (void) { } void R_init (void) { - Uint32 flags = SDL_OPENGL; + int res = 0; + int flags = SYSTEM_USE_OPENGL; if (fullscreen) { - flags = flags | SDL_FULLSCREEN; + flags |= SYSTEM_USE_FULLSCREEN; } + logo("R_init: intialize opengl render\n"); + int was = Y_videomode_setted(); if (SCRW <= 0 || SCRH <= 0) { ERR_failinit("Invalid screen size %ix%i\n", SCRW, SCRH); } - if (surf == NULL) { + if (was == 0) { R_init_playpal(); // only onece } - surf = SDL_SetVideoMode(SCRW, SCRH, 0, flags); - if (surf == NULL) { - ERR_failinit("Unable to set video mode: %s\n", SDL_GetError()); + res = Y_set_videomode(SCRW, SCRH, flags); + if (res == 0) { + ERR_failinit("Unable to set video mode\n"); } root = R_cache_new(); assert(root); @@ -1691,6 +1695,7 @@ void R_init (void) { void R_done (void) { R_cache_free(root, 1); + Y_unset_videomode(); } void R_setgamma (int g) { @@ -1702,10 +1707,9 @@ int R_getgamma (void) { } void R_toggle_fullscreen (void) { - fullscreen = !fullscreen; - if (surf) { - R_init(); // recreate window - } + Y_set_fullscreen(!Y_get_fullscreen()); + fullscreen = Y_get_fullscreen(); + R_alloc(); } void R_get_name (int n, char s[8]) {