mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 03:00:38 +00:00
Merge a patch from NY00123 that draws the screen to a temporary surface under the selected bit depth then blits it to a surface at the system desktop bit depth, under SDL. This allows 8-bit classic to run in fullscreen under certain *nix configurations and Windows 8.
git-svn-id: https://svn.eduke32.com/eduke32@4080 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
c1bbf25700
commit
92b441cb11
1 changed files with 27 additions and 10 deletions
|
@ -76,6 +76,7 @@ char quitevent=0, appactive=1, novideo=0;
|
||||||
|
|
||||||
// video
|
// video
|
||||||
static SDL_Surface *sdl_surface;
|
static SDL_Surface *sdl_surface;
|
||||||
|
static SDL_Surface *sdl_buffersurface=NULL;
|
||||||
#if SDL_MAJOR_VERSION==2
|
#if SDL_MAJOR_VERSION==2
|
||||||
static SDL_Surface *sdl_surface2;
|
static SDL_Surface *sdl_surface2;
|
||||||
static SDL_Palette *sdl_palptr;
|
static SDL_Palette *sdl_palptr;
|
||||||
|
@ -1049,7 +1050,8 @@ void getvalidmodes(void)
|
||||||
pf.BitsPerPixel = cdepths[j];
|
pf.BitsPerPixel = cdepths[j];
|
||||||
pf.BytesPerPixel = cdepths[j] >> 3;
|
pf.BytesPerPixel = cdepths[j] >> 3;
|
||||||
|
|
||||||
modes = SDL_ListModes(&pf, SURFACE_FLAGS | SDL_FULLSCREEN);
|
// We convert paletted contents to non-paletted
|
||||||
|
modes = SDL_ListModes((cdepths[j] == 8) ? NULL : &pf, SURFACE_FLAGS | SDL_FULLSCREEN);
|
||||||
|
|
||||||
if (modes == (SDL_Rect **)0)
|
if (modes == (SDL_Rect **)0)
|
||||||
{
|
{
|
||||||
|
@ -1255,6 +1257,12 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
SDL_SetGammaRamp(sysgamma[0], sysgamma[1], sysgamma[2]);
|
SDL_SetGammaRamp(sysgamma[0], sysgamma[1], sysgamma[2]);
|
||||||
gammabrightness = 0; // redetect on next mode switch
|
gammabrightness = 0; // redetect on next mode switch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sdl_buffersurface)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface(sdl_buffersurface);
|
||||||
|
sdl_buffersurface = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
|
@ -1357,12 +1365,20 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
initprintf("Setting video mode %dx%d (%d-bpp %s)\n",
|
initprintf("Setting video mode %dx%d (%d-bpp %s)\n",
|
||||||
x,y,c, ((fs&1) ? "fullscreen" : "windowed"));
|
x,y,c, ((fs&1) ? "fullscreen" : "windowed"));
|
||||||
#if SDL_MAJOR_VERSION==1
|
#if SDL_MAJOR_VERSION==1
|
||||||
sdl_surface = SDL_SetVideoMode(x, y, c, SURFACE_FLAGS | ((fs&1)?SDL_FULLSCREEN:0));
|
// We convert paletted contents to non-paletted
|
||||||
|
sdl_surface = SDL_SetVideoMode(x, y, 0, SURFACE_FLAGS | ((fs&1)?SDL_FULLSCREEN:0));
|
||||||
if (!sdl_surface)
|
if (!sdl_surface)
|
||||||
{
|
{
|
||||||
initprintf("Unable to set video mode!\n");
|
initprintf("Unable to set video mode!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
sdl_buffersurface = SDL_CreateRGBSurface(SURFACE_FLAGS, x, y, c, 0, 0, 0, 0);
|
||||||
|
if (!sdl_buffersurface)
|
||||||
|
{
|
||||||
|
initprintf("Unable to set video mode: SDL_CreateRGBSurface failed: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// deinit
|
// deinit
|
||||||
destroy_window_and_renderer();
|
destroy_window_and_renderer();
|
||||||
|
@ -1399,7 +1415,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
if (!sdl_palptr)
|
if (!sdl_palptr)
|
||||||
sdl_palptr = SDL_AllocPalette(256);
|
sdl_palptr = SDL_AllocPalette(256);
|
||||||
|
|
||||||
if (SDL_SetSurfacePalette(sdl_surface, sdl_palptr) < 0)
|
if (SDL_SetSurfacePalette(sdl_buffersurface, sdl_palptr) < 0)
|
||||||
initprintf("SDL_SetSurfacePalette failed: %s\n", SDL_GetError());
|
initprintf("SDL_SetSurfacePalette failed: %s\n", SDL_GetError());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1669,12 +1685,12 @@ void begindrawing(void)
|
||||||
|
|
||||||
if (offscreenrendering) return;
|
if (offscreenrendering) return;
|
||||||
|
|
||||||
if (SDL_MUSTLOCK(sdl_surface)) SDL_LockSurface(sdl_surface);
|
if (SDL_MUSTLOCK(sdl_buffersurface)) SDL_LockSurface(sdl_buffersurface);
|
||||||
frameplace = (intptr_t)sdl_surface->pixels;
|
frameplace = (intptr_t)sdl_buffersurface->pixels;
|
||||||
|
|
||||||
if (sdl_surface->pitch != bytesperline || modechange)
|
if (sdl_buffersurface->pitch != bytesperline || modechange)
|
||||||
{
|
{
|
||||||
bytesperline = sdl_surface->pitch;
|
bytesperline = sdl_buffersurface->pitch;
|
||||||
|
|
||||||
calc_ylookup(bytesperline, ydim);
|
calc_ylookup(bytesperline, ydim);
|
||||||
|
|
||||||
|
@ -1702,7 +1718,7 @@ void enddrawing(void)
|
||||||
|
|
||||||
if (offscreenrendering) return;
|
if (offscreenrendering) return;
|
||||||
|
|
||||||
if (SDL_MUSTLOCK(sdl_surface)) SDL_UnlockSurface(sdl_surface);
|
if (SDL_MUSTLOCK(sdl_buffersurface)) SDL_UnlockSurface(sdl_buffersurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1740,9 +1756,9 @@ void showframe(int32_t w)
|
||||||
if (needpalupdate)
|
if (needpalupdate)
|
||||||
{
|
{
|
||||||
#if SDL_MAJOR_VERSION==1
|
#if SDL_MAJOR_VERSION==1
|
||||||
SDL_SetColors(sdl_surface, sdlayer_pal, 0, 256);
|
SDL_SetColors(sdl_buffersurface, sdlayer_pal, 0, 256);
|
||||||
// same as:
|
// same as:
|
||||||
//SDL_SetPalette(sdl_surface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256);
|
//SDL_SetPalette(sdl_buffersurface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256);
|
||||||
#else
|
#else
|
||||||
if (SDL_SetPaletteColors(sdl_palptr, sdlayer_pal, 0, 256) < 0)
|
if (SDL_SetPaletteColors(sdl_palptr, sdlayer_pal, 0, 256) < 0)
|
||||||
initprintf("SDL_SetPaletteColors failed: %s\n", SDL_GetError());
|
initprintf("SDL_SetPaletteColors failed: %s\n", SDL_GetError());
|
||||||
|
@ -1751,6 +1767,7 @@ void showframe(int32_t w)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_MAJOR_VERSION==1
|
#if SDL_MAJOR_VERSION==1
|
||||||
|
SDL_BlitSurface(sdl_buffersurface, NULL, sdl_surface, NULL);
|
||||||
SDL_Flip(sdl_surface);
|
SDL_Flip(sdl_surface);
|
||||||
#else
|
#else
|
||||||
// SDL_UpdateWindowSurface(sdl_window);
|
// SDL_UpdateWindowSurface(sdl_window);
|
||||||
|
|
Loading…
Reference in a new issue