WIP: delete glSDL shim, replace with sdl_compat.h
Step 1+2 of the SDL 3 migration. The 2300-line graphics/glSDL.{c,h}
OpenGL-on-top-of-SDL-1.2 shim is obsolete under SDL 3 (SDL_Renderer
does what glSDL did natively), and its #define overrides of SDL
surface APIs collided directly with SDL 3's SDL_oldnames.h.
- Add graphics/sdl_compat.h: a one-line umbrella that just pulls in
<SDL3/SDL.h>.
- Replace every #include "glSDL.h" with #include "sdl_compat.h" (15
files across the tree).
- Delete graphics/glSDL.c, graphics/glSDL.h.
- Drop glSDL.c from graphics/CMakeLists.txt.
- Remove GFX_DRIVER_GLSDL from the gfx_drivers_t enum and from all
switches/conditions in gfxengine.cpp.
- Drop the glSDL_VSync() call site (will be re-introduced as
SDL_SetRenderVSync once gfxengine is ported to SDL_Renderer).
- Drop the two glSDL_Invalidate() calls in window.cpp (texture
re-upload hints with no equivalent in a pure-surface compositor).
- options.cpp: remove the now-empty "OpenGL/glSDL" menu item; force
videodriver to GFX_DRIVER_SDL2D.
- prefs.cpp: collapse legacy GLSDL setting onto SDL2D on load.
After this commit the macro-collision wall is gone (renamed_-token
errors drop from many to zero). The build still fails on the next
layer of work: SDL 1.2 surface APIs that no longer exist
(SDL_FreeSurface, SDL_SetAlpha, SDL_CreateRGBSurface, SDL_DisplayFormat,
SDL_PixelFormat struct member access, SDL audio callback API, etc.).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9b0662865e
commit
762b095462
@ -23,7 +23,7 @@
|
|||||||
#ifndef _KOBO_GAMECTL_H_
|
#ifndef _KOBO_GAMECTL_H_
|
||||||
#define _KOBO_GAMECTL_H_
|
#define _KOBO_GAMECTL_H_
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define KEY_KP_DOWN SDLK_KP2
|
#define KEY_KP_DOWN SDLK_KP2
|
||||||
|
|||||||
@ -2,7 +2,6 @@ add_library(graphics STATIC
|
|||||||
cs.c
|
cs.c
|
||||||
sprite.c
|
sprite.c
|
||||||
filters.c
|
filters.c
|
||||||
glSDL.c
|
|
||||||
gfxengine.cpp
|
gfxengine.cpp
|
||||||
window.cpp
|
window.cpp
|
||||||
sofont.cpp
|
sofont.cpp
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include <SDL3_image/SDL_image.h>
|
#include <SDL3_image/SDL_image.h>
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
#include "gfxengine.h"
|
#include "gfxengine.h"
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
#include <SDL3_image/SDL_image.h>
|
#include <SDL3_image/SDL_image.h>
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include "sofont.h"
|
#include "sofont.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@ -443,23 +443,10 @@ void gfxengine_t::dither(int type, int _broken_rgba8)
|
|||||||
|
|
||||||
if(_dither)
|
if(_dither)
|
||||||
{
|
{
|
||||||
if(_driver == GFX_DRIVER_GLSDL)
|
df->args.x = 0;
|
||||||
{
|
df->args.r = 1<<(screen_surface->format->Rloss-1);
|
||||||
//Klugde for glSDL, which doesn't give us a faked
|
df->args.g = 1<<(screen_surface->format->Gloss-1);
|
||||||
//screen surface - while we're interested only in
|
df->args.b = 1<<(screen_surface->format->Bloss-1);
|
||||||
//the *texture* depth; not the display depth!
|
|
||||||
df->args.r = df->args.g = df->args.b = 0;
|
|
||||||
//Another kludge, because some cards support RGB8
|
|
||||||
//(24 bit) textures, but not RGBA8 (32 bit).
|
|
||||||
df->args.x = broken_rgba8;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
df->args.x = 0;
|
|
||||||
df->args.r = 1<<(screen_surface->format->Rloss-1);
|
|
||||||
df->args.g = 1<<(screen_surface->format->Gloss-1);
|
|
||||||
df->args.b = 1<<(screen_surface->format->Bloss-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
df->args.x = df->args.r = df->args.g = df->args.b = 0;
|
df->args.x = df->args.r = df->args.g = df->args.b = 0;
|
||||||
@ -775,36 +762,6 @@ int gfxengine_t::show()
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(_driver)
|
|
||||||
{
|
|
||||||
case GFX_DRIVER_SDL2D:
|
|
||||||
break;
|
|
||||||
case GFX_DRIVER_GLSDL:
|
|
||||||
if(!_doublebuf)
|
|
||||||
{
|
|
||||||
log_printf(WLOG, "Only double buffering is supported"
|
|
||||||
" with OpenGL drivers!\n");
|
|
||||||
doublebuffer(1);
|
|
||||||
}
|
|
||||||
if(_shadow)
|
|
||||||
{
|
|
||||||
log_printf(WLOG, "Shadow buffer not supported"
|
|
||||||
" with OpenGL drivers!\n");
|
|
||||||
shadow(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(_driver)
|
|
||||||
{
|
|
||||||
case GFX_DRIVER_SDL2D:
|
|
||||||
/* Nothing extra */
|
|
||||||
break;
|
|
||||||
case GFX_DRIVER_GLSDL:
|
|
||||||
flags |= SDL_GLSDL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_doublebuf)
|
if(_doublebuf)
|
||||||
flags |= SDL_DOUBLEBUF | SDL_HWSURFACE;
|
flags |= SDL_DOUBLEBUF | SDL_HWSURFACE;
|
||||||
else
|
else
|
||||||
@ -816,7 +773,6 @@ int gfxengine_t::show()
|
|||||||
if(_fullscreen)
|
if(_fullscreen)
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_FULLSCREEN;
|
||||||
|
|
||||||
glSDL_VSync(_vsync);
|
|
||||||
flags |= xflags;
|
flags |= xflags;
|
||||||
|
|
||||||
screen_surface = SDL_SetVideoMode(_width, _height, _depth, flags);
|
screen_surface = SDL_SetVideoMode(_width, _height, _depth, flags);
|
||||||
@ -826,25 +782,22 @@ int gfxengine_t::show()
|
|||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_driver != GFX_DRIVER_GLSDL)
|
if((screen_surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)
|
||||||
{
|
{
|
||||||
if((screen_surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)
|
if(!_doublebuf)
|
||||||
{
|
{
|
||||||
if(!_doublebuf)
|
log_printf(WLOG, "Could not get"
|
||||||
{
|
" single buffered display.\n");
|
||||||
log_printf(WLOG, "Could not get"
|
doublebuffer(1);
|
||||||
" single buffered display.\n");
|
|
||||||
doublebuffer(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_doublebuf)
|
||||||
{
|
{
|
||||||
if(_doublebuf)
|
log_printf(WLOG, "Could not get"
|
||||||
{
|
" double buffered display.\n");
|
||||||
log_printf(WLOG, "Could not get"
|
doublebuffer(0);
|
||||||
" double buffered display.\n");
|
|
||||||
doublebuffer(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,14 +29,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "cs.h"
|
#include "cs.h"
|
||||||
|
|
||||||
enum gfx_drivers_t
|
enum gfx_drivers_t
|
||||||
{
|
{
|
||||||
GFX_DRIVER_SDL2D = 0,
|
GFX_DRIVER_SDL2D = 0
|
||||||
GFX_DRIVER_GLSDL = 1
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum gfx_scalemodes_t
|
enum gfx_scalemodes_t
|
||||||
|
|||||||
2328
graphics/glSDL.c
2328
graphics/glSDL.c
File diff suppressed because it is too large
Load Diff
399
graphics/glSDL.h
399
graphics/glSDL.h
@ -1,399 +0,0 @@
|
|||||||
/*(LGPL)
|
|
||||||
------------------------------------------------------------
|
|
||||||
glSDL 0.9 - SDL 2D API on top of OpenGL
|
|
||||||
------------------------------------------------------------
|
|
||||||
* Copyright (C) 2001-2004, 2006-2007 David Olofson
|
|
||||||
* This code is released under the terms of the GNU LGPL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GLSDL_H_
|
|
||||||
#define _GLSDL_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you don't use GNU autotools or similar, uncomment this to
|
|
||||||
* compile with OpenGL enabled:
|
|
||||||
#define HAVE_OPENGL
|
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
* See README about using this glSDL wrapper with
|
|
||||||
* SDL versions that have the glSDL backend!
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* We're still using SDL datatypes here - we just add some stuff. */
|
|
||||||
#include <SDL3/SDL.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ignore the flag from SDL w/ glSDL backend, since we're going
|
|
||||||
* to use glSDL/wrapper by default.
|
|
||||||
*/
|
|
||||||
#ifdef SDL_GLSDL
|
|
||||||
#undef SDL_GLSDL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_OPENGL
|
|
||||||
|
|
||||||
/* Fakes to make glSDL code compile with SDL. */
|
|
||||||
#define SDL_GLSDL 0
|
|
||||||
#define GLSDL_FIX_SURFACE(s)
|
|
||||||
|
|
||||||
#else /* HAVE_OPENGL */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (SDL_MAJOR_VERSION <= 1) && (SDL_MINOR_VERSION <= 2) && \
|
|
||||||
(SDL_PATCHLEVEL < 5)
|
|
||||||
#warning glSDL: Using SDL version 1.2.5 or later is strongly recommended!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
|
||||||
SDL style API
|
|
||||||
----------------------------------------------------------*/
|
|
||||||
|
|
||||||
typedef enum glSDL_TileModes
|
|
||||||
{
|
|
||||||
GLSDL_TM_SINGLE,
|
|
||||||
GLSDL_TM_HORIZONTAL,
|
|
||||||
GLSDL_TM_VERTICAL,
|
|
||||||
GLSDL_TM_HUGE
|
|
||||||
} glSDL_TileModes;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct glSDL_TexInfo
|
|
||||||
{
|
|
||||||
int textures;
|
|
||||||
int *texture;
|
|
||||||
int texsize; /* width/height of OpenGL texture */
|
|
||||||
glSDL_TileModes tilemode;
|
|
||||||
int tilew, tileh; /* At least one must equal texsize! */
|
|
||||||
int tilespertex;
|
|
||||||
|
|
||||||
/* Area of surface to download when/after unlocking */
|
|
||||||
SDL_Rect invalid_area;
|
|
||||||
} glSDL_TexInfo;
|
|
||||||
|
|
||||||
#define GLSDL_FIX_SURFACE(s) (s)->unused1 = 0;
|
|
||||||
#define IS_GLSDL_SURFACE(s) ((s) && texinfotab && glSDL_GetTexInfo(s))
|
|
||||||
|
|
||||||
#ifdef SDL_GLSDL
|
|
||||||
#undef SDL_GLSDL /* In case SDL has the glSDL backend... */
|
|
||||||
#endif
|
|
||||||
#define SDL_GLSDL 0x00100000 /* Create an OpenGL 2D rendering context */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wraps SDL_SetVideoMode(), and adds support for the SDL_GLSDL flag.
|
|
||||||
*
|
|
||||||
* If 'flags' contains SDL_GLSDL, glSDL_SetVideoMode() sets up a "pure"
|
|
||||||
* OpenGL rendering context for use with the glSDL_ calls.
|
|
||||||
*
|
|
||||||
* SDL can be closed as usual (using SDL_ calls), but you should call
|
|
||||||
* glSDL_Quit() (kludge) to allow glSDL to clean up it's internal stuff.
|
|
||||||
*/
|
|
||||||
SDL_Surface *glSDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);
|
|
||||||
void glSDL_Quit(void);
|
|
||||||
|
|
||||||
void glSDL_QuitSubSystem(Uint32 flags);
|
|
||||||
|
|
||||||
/* Replaces SDL_Quit() entirely, when using the override defines */
|
|
||||||
void glSDL_FullQuit(void);
|
|
||||||
|
|
||||||
SDL_Surface *glSDL_GetVideoSurface(void);
|
|
||||||
|
|
||||||
void glSDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);
|
|
||||||
void glSDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Works like SDL_Flip(), but may also perform enqueued blits.
|
|
||||||
* (That is, it's possible that the implementation renders
|
|
||||||
* *nothing* until glSDL_Flip() is called.)
|
|
||||||
*/
|
|
||||||
int glSDL_Flip(SDL_Surface *screen);
|
|
||||||
|
|
||||||
void glSDL_FreeSurface(SDL_Surface *surface);
|
|
||||||
|
|
||||||
int glSDL_LockSurface(SDL_Surface *surface);
|
|
||||||
void glSDL_UnlockSurface(SDL_Surface *surface);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Like the respective SDL functions, although they ignore
|
|
||||||
* SDL_RLEACCEL, as it makes no sense in this context.
|
|
||||||
*/
|
|
||||||
int glSDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
|
|
||||||
int glSDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets up clipping for the screen, or a SDL_Surface.
|
|
||||||
*
|
|
||||||
* Note that this function takes both SDL_Surfaces and
|
|
||||||
* glSDL_Surfaces.
|
|
||||||
*/
|
|
||||||
SDL_bool glSDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect);
|
|
||||||
|
|
||||||
int glSDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect,
|
|
||||||
SDL_Surface *dst, SDL_Rect *dstrect);
|
|
||||||
|
|
||||||
int glSDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert the given surface into a SDL_Surface (if it isn't
|
|
||||||
* one already), and makes sure that the underlying SDL_Surface
|
|
||||||
* is of a pixel format suitable for fast texture downloading.
|
|
||||||
*
|
|
||||||
* Note that you *only* have to use this function if you want
|
|
||||||
* fast pixel access to surfaces (ie "procedural textures").
|
|
||||||
* Any surfaces that aren't converted will be downloaded
|
|
||||||
* automatically upon the first call to glSDL_BlitSurface(),
|
|
||||||
* but if conversion is required, it will be required for
|
|
||||||
* every glSDL_UnlockSurface() call.
|
|
||||||
*
|
|
||||||
* IMPORTANT:
|
|
||||||
* You *can* pass an SDL_Surface directly to this function,
|
|
||||||
* and it will try to deal with it nicely. However, this
|
|
||||||
* requires that a temporary SDL_Surface is created, and
|
|
||||||
* this surface is cached only until the texture memory is
|
|
||||||
* needed for new surfaces.
|
|
||||||
*/
|
|
||||||
SDL_Surface *glSDL_DisplayFormat(SDL_Surface *surface);
|
|
||||||
SDL_Surface *glSDL_DisplayFormatAlpha(SDL_Surface *surface);
|
|
||||||
|
|
||||||
SDL_Surface *glSDL_ConvertSurface
|
|
||||||
(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
|
|
||||||
SDL_Surface *glSDL_CreateRGBSurface
|
|
||||||
(Uint32 flags, int width, int height, int depth,
|
|
||||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
|
||||||
SDL_Surface *glSDL_CreateRGBSurfaceFrom(void *pixels,
|
|
||||||
int width, int height, int depth, int pitch,
|
|
||||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
|
||||||
SDL_Surface *glSDL_LoadBMP(const char *file);
|
|
||||||
int glSDL_SaveBMP(SDL_Surface *surface, const char *file);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Some ugly "overriding"... */
|
|
||||||
#ifndef _GLSDL_NO_REDEFINES_
|
|
||||||
/*
|
|
||||||
* You *always* need to lock and unlock a glSDL surface in
|
|
||||||
* order to get glSDL to update the OpenGL texture!
|
|
||||||
*/
|
|
||||||
#undef SDL_MUSTLOCK
|
|
||||||
#define SDL_MUSTLOCK(surface) \
|
|
||||||
(surface->offset || \
|
|
||||||
((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0) || \
|
|
||||||
IS_GLSDL_SURFACE(surface))
|
|
||||||
|
|
||||||
#define SDL_SetVideoMode glSDL_SetVideoMode
|
|
||||||
#define SDL_GetVideoSurface glSDL_GetVideoSurface
|
|
||||||
#define SDL_Quit glSDL_FullQuit
|
|
||||||
#define SDL_QuitSubSystem glSDL_QuitSubSystem
|
|
||||||
#define SDL_UpdateRects glSDL_UpdateRects
|
|
||||||
#define SDL_UpdateRect glSDL_UpdateRect
|
|
||||||
#define SDL_Flip glSDL_Flip
|
|
||||||
#define SDL_FreeSurface glSDL_FreeSurface
|
|
||||||
#define SDL_LockSurface glSDL_LockSurface
|
|
||||||
#define SDL_UnlockSurface glSDL_UnlockSurface
|
|
||||||
#define SDL_SetColorKey glSDL_SetColorKey
|
|
||||||
#define SDL_SetAlpha glSDL_SetAlpha
|
|
||||||
#define SDL_SetClipRect glSDL_SetClipRect
|
|
||||||
#undef SDL_BlitSurface
|
|
||||||
#define SDL_BlitSurface glSDL_BlitSurface
|
|
||||||
#define SDL_FillRect glSDL_FillRect
|
|
||||||
#define SDL_DisplayFormat glSDL_DisplayFormat
|
|
||||||
#define SDL_DisplayFormatAlpha glSDL_DisplayFormatAlpha
|
|
||||||
#define SDL_ConvertSurface glSDL_ConvertSurface
|
|
||||||
#define SDL_CreateRGBSurface glSDL_CreateRGBSurface
|
|
||||||
#define SDL_CreateRGBSurfaceFrom glSDL_CreateRGBSurfaceFrom
|
|
||||||
#undef SDL_AllocSurface
|
|
||||||
#define SDL_AllocSurface glSDL_CreateRGBSurface
|
|
||||||
#undef SDL_LoadBMP
|
|
||||||
#define SDL_LoadBMP glSDL_LoadBMP
|
|
||||||
#undef SDL_SaveBMP
|
|
||||||
#define SDL_SaveBMP glSDL_SaveBMP
|
|
||||||
#define IMG_Load(x) glSDL_IMG_Load(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAVE_OPENGL */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
|
||||||
|
|
||||||
/* Some extra overloading for common external lib calls... */
|
|
||||||
#include "SDL_image.h"
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
SDL_Surface *glSDL_IMG_Load(const char *file);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* HAVE_OPENGL */
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
|
||||||
glSDL API extensions, transparent
|
|
||||||
----------------------------------------------------------*/
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Invalidate part of a texture.
|
|
||||||
*
|
|
||||||
* This function can be used either between calls to
|
|
||||||
* glSDL_LockSurface() and glSDL_UnlockSurface(), or before
|
|
||||||
* calling glSDL_DownloadSurface().
|
|
||||||
*
|
|
||||||
* In either case, it causes only the specified area to be
|
|
||||||
* downloaded when unlocking the surface, or calling
|
|
||||||
* glSDL_UnlockSurface(), respectively.
|
|
||||||
*
|
|
||||||
* Note that if this function is not used, glSDL assumes that
|
|
||||||
* the entire surface has to be updated. (That is, it's safe
|
|
||||||
* to ignore this function - it's "just a performance hack.")
|
|
||||||
*
|
|
||||||
* Passing a rectangle with zero height or width cancels the
|
|
||||||
* downloading when/after unlocking the surface. Use if you
|
|
||||||
* just want to read the texture, but feel like being nice and
|
|
||||||
* obeying SDL_MUSTLOCK() - which is a good idea, as things
|
|
||||||
* may change...
|
|
||||||
*
|
|
||||||
* Passing NULL for the 'area' argument results in the entire
|
|
||||||
* surface being invalidated.
|
|
||||||
*
|
|
||||||
* NOTE: This function does NOT perform clipping! Weird or
|
|
||||||
* even Bad Things may happen if you specify areas
|
|
||||||
* that protrude outside the edges of the actual
|
|
||||||
* surface.
|
|
||||||
*/
|
|
||||||
void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure that the texture of the specified surface is up
|
|
||||||
* to date in OpenGL texture memory.
|
|
||||||
*
|
|
||||||
* This can be used together with glSDL_UnloadSurface() to
|
|
||||||
* implement custom texture caching schemes.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, or a negative value if something
|
|
||||||
* went wrong.
|
|
||||||
*/
|
|
||||||
int glSDL_UploadSurface(SDL_Surface *surface);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the texture space used by the specified surface.
|
|
||||||
*
|
|
||||||
* Normally, glSDL should download textures when needed, and
|
|
||||||
* unload the oldest (in terms of use) surfaces, if it runs out
|
|
||||||
* of texture space.
|
|
||||||
*/
|
|
||||||
void glSDL_UnloadSurface(SDL_Surface *surface);
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
|
||||||
glSDL API extensions, OpenGL mode ONLY
|
|
||||||
----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enable, disable or check the state of "vsync" or
|
|
||||||
* vertical retrace synchronization. Note that enabling
|
|
||||||
* this does not *guarantee* that the driver actually
|
|
||||||
* uses vsync; it only instructs OpenGL to do so if
|
|
||||||
* possible.
|
|
||||||
* Pass 1 for 'use' to enable vsync, '0' to disable
|
|
||||||
* it, and -1 to just return the current state without
|
|
||||||
* changing it.
|
|
||||||
* Returns the vsync state *before* any change made
|
|
||||||
* by the call.
|
|
||||||
*
|
|
||||||
* NOTE: Ignored when not using OpenGL acceleration!
|
|
||||||
*/
|
|
||||||
int glSDL_VSync(int use);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set alpha multiplier. This is multiplied with any full
|
|
||||||
* surface alpha or alpha channels of surfaces.
|
|
||||||
*
|
|
||||||
* The default value is 255, which makes glSDL render like
|
|
||||||
* the standard SDL 2D backends, ie based only on the
|
|
||||||
* surface settings.
|
|
||||||
*
|
|
||||||
* This function affects the global state of glSDL.
|
|
||||||
*
|
|
||||||
* NOTE: NOT available without OpenGL acceleration!
|
|
||||||
*/
|
|
||||||
void glSDL_SetBlendAlpha(Uint8 alpha);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set color multipliers. These are multiplied with the
|
|
||||||
* respective color channers of rendered surfaces,
|
|
||||||
* modulating the brightness of the resulting output.
|
|
||||||
*
|
|
||||||
* The default values are 255, which makes glSDL render
|
|
||||||
* like the standard SDL 2D backends.
|
|
||||||
*
|
|
||||||
* This function affects the global state of glSDL.
|
|
||||||
*
|
|
||||||
* NOTE: NOT available without OpenGL acceleration!
|
|
||||||
*/
|
|
||||||
void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set center offset in pixels for scaling and rotation.
|
|
||||||
*
|
|
||||||
* The default is (0, 0), which makes surfaces rotate and
|
|
||||||
* scale around their centers.
|
|
||||||
*
|
|
||||||
* This function affects the global state of glSDL.
|
|
||||||
*
|
|
||||||
* NOTE: NOT available without OpenGL acceleration!
|
|
||||||
*/
|
|
||||||
void glSDL_SetCenter(float x, float y);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set rotation angle in degrees. Rotation is done around
|
|
||||||
* the center point, which is defined as
|
|
||||||
* (w/2 + cx, h/2 + cy)
|
|
||||||
* where w and h are the width and height of the source
|
|
||||||
* surface, and cx and cy are the center offsets set by
|
|
||||||
* glSDL_SetCenter().
|
|
||||||
*
|
|
||||||
* The default value is 0.0f, which makes glSDL render
|
|
||||||
* like a normal SDL 2D backend.
|
|
||||||
*
|
|
||||||
* This function affects the global state of glSDL.
|
|
||||||
*
|
|
||||||
* NOTE: NOT available without OpenGL acceleration!
|
|
||||||
*/
|
|
||||||
void glSDL_SetRotation(float angle);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set scale factor. Scaling is centered around around
|
|
||||||
* the point
|
|
||||||
* (w/2 + cx, h/2 + cy)
|
|
||||||
* where w and h are the width and height of the source
|
|
||||||
* surface, and cx and cy are the center offsets set by
|
|
||||||
* glSDL_SetCenter().
|
|
||||||
*
|
|
||||||
* The default value is 1.0f, which makes glSDL render
|
|
||||||
* like a normal SDL 2D backend.
|
|
||||||
*
|
|
||||||
* This function affects the global state of glSDL.
|
|
||||||
*
|
|
||||||
* NOTE: NOT available without OpenGL acceleration!
|
|
||||||
*/
|
|
||||||
void glSDL_SetScale(float x, float y);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reset glSDL global state to defaults.
|
|
||||||
*/
|
|
||||||
void glSDL_ResetState(void);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _GLSDL_H_ */
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#ifndef KOBO_REGION_H
|
#ifndef KOBO_REGION_H
|
||||||
#define KOBO_REGION_H
|
#define KOBO_REGION_H
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
16
graphics/sdl_compat.h
Normal file
16
graphics/sdl_compat.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* sdl_compat.h - umbrella SDL 3 include for Kobo Deluxe.
|
||||||
|
*
|
||||||
|
* Replaces the legacy graphics/glSDL.h shim that wrapped SDL 1.2 with
|
||||||
|
* an OpenGL backend. SDL 3's renderer makes that unnecessary.
|
||||||
|
*
|
||||||
|
* This header exists so the codebase can use #include "sdl_compat.h"
|
||||||
|
* rather than scatter <SDL3/SDL.h> across the tree (which would also
|
||||||
|
* make a later SDL 4 swap painful).
|
||||||
|
*/
|
||||||
|
#ifndef _KOBO_SDL_COMPAT_H_
|
||||||
|
#define _KOBO_SDL_COMPAT_H_
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#endif /* _KOBO_SDL_COMPAT_H_ */
|
||||||
@ -34,7 +34,7 @@
|
|||||||
* Cursor tests first check if '|' is present.
|
* Cursor tests first check if '|' is present.
|
||||||
* Shadowed variables fixed.
|
* Shadowed variables fixed.
|
||||||
* Garbage data in spacing table fixed. (Thanks to
|
* Garbage data in spacing table fixed. (Thanks to
|
||||||
Andreas Spångberg for discovering this one!)
|
Andreas Sp<EFBFBD>ngberg for discovering this one!)
|
||||||
* Added ExtraSpace(). (Scaling support hack...)
|
* Added ExtraSpace(). (Scaling support hack...)
|
||||||
* Disabled colorkeying. (Ruins some RGBA fonts!)
|
* Disabled colorkeying. (Ruins some RGBA fonts!)
|
||||||
*/
|
*/
|
||||||
@ -42,7 +42,7 @@
|
|||||||
#ifndef __SOFONT_H
|
#ifndef __SOFONT_H
|
||||||
#define __SOFONT_H
|
#define __SOFONT_H
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
class SoFont
|
class SoFont
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,7 +29,7 @@ TODO: tables as needed when loading banks.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include <SDL3_image/SDL_image.h>
|
#include <SDL3_image/SDL_image.h>
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|||||||
@ -186,13 +186,9 @@ void window_t::invalidate(SDL_Rect *r)
|
|||||||
rr.w = phys_rect.w;
|
rr.w = phys_rect.w;
|
||||||
rr.h = phys_rect.h;
|
rr.h = phys_rect.h;
|
||||||
phys_refresh(&rr);
|
phys_refresh(&rr);
|
||||||
glSDL_Invalidate(surface, &rr);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
phys_refresh(r);
|
phys_refresh(r);
|
||||||
glSDL_Invalidate(surface, r);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -213,7 +213,7 @@
|
|||||||
#ifndef _WINDOW_H_
|
#ifndef _WINDOW_H_
|
||||||
#define _WINDOW_H_
|
#define _WINDOW_H_
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
class gfxengine_t;
|
class gfxengine_t;
|
||||||
|
|
||||||
|
|||||||
2
logger.c
2
logger.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
#define LOG_BUFFER 1024
|
#define LOG_BUFFER 1024
|
||||||
|
|
||||||
|
|||||||
2
manage.h
2
manage.h
@ -24,7 +24,7 @@
|
|||||||
#ifndef _KOBO_MANAGE_H_
|
#ifndef _KOBO_MANAGE_H_
|
||||||
#define _KOBO_MANAGE_H_
|
#define _KOBO_MANAGE_H_
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include "score.h"
|
#include "score.h"
|
||||||
|
|
||||||
class _manage
|
class _manage
|
||||||
|
|||||||
@ -184,14 +184,7 @@ void video_options_t::build()
|
|||||||
item("16 bits", 16);
|
item("16 bits", 16);
|
||||||
item("24 bits", 24);
|
item("24 bits", 24);
|
||||||
item("32 bits", 32);
|
item("32 bits", 32);
|
||||||
#if defined(HAVE_OPENGL) && !defined(GLSDL_OFF)
|
|
||||||
list("Display Driver", &prf->videodriver, OS_RESTART_VIDEO |
|
|
||||||
OS_REBUILD);
|
|
||||||
item("SDL 2D", GFX_DRIVER_SDL2D);
|
|
||||||
item("OpenGL/glSDL", GFX_DRIVER_GLSDL);
|
|
||||||
#else
|
|
||||||
prf->videodriver = GFX_DRIVER_SDL2D;
|
prf->videodriver = GFX_DRIVER_SDL2D;
|
||||||
#endif
|
|
||||||
space();
|
space();
|
||||||
xoffs = 0.55;
|
xoffs = 0.55;
|
||||||
switch(prf->videodriver)
|
switch(prf->videodriver)
|
||||||
|
|||||||
@ -171,7 +171,8 @@ void prefs_t::postload()
|
|||||||
scrollradar = 2;
|
scrollradar = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some unimplemented enums were removed in 0.4.1
|
// Only the SDL 2D driver remains since the SDL 3 migration; collapse
|
||||||
|
// any legacy GLSDL setting onto it.
|
||||||
if(videodriver != GFX_DRIVER_SDL2D)
|
if(videodriver != GFX_DRIVER_SDL2D)
|
||||||
videodriver = GFX_DRIVER_GLSDL;
|
videodriver = GFX_DRIVER_SDL2D;
|
||||||
}
|
}
|
||||||
|
|||||||
2
random.h
2
random.h
@ -24,7 +24,7 @@
|
|||||||
#define _KOBO_RANDOM_H_
|
#define _KOBO_RANDOM_H_
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
class rand_num_t
|
class rand_num_t
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
#ifndef _A_TOOLS_H_
|
#ifndef _A_TOOLS_H_
|
||||||
#define _A_TOOLS_H_
|
#define _A_TOOLS_H_
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "kobolog.h"
|
#include "kobolog.h"
|
||||||
#include "a_types.h"
|
#include "a_types.h"
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
#ifndef _A_TYPES_H_
|
#ifndef _A_TYPES_H_
|
||||||
#define _A_TYPES_H_
|
#define _A_TYPES_H_
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
|
|
||||||
/* Builtin patch drivers */
|
/* Builtin patch drivers */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "glSDL.h"
|
#include "sdl_compat.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
# define M_PI 3.14159265358979323846 /* pi */
|
# define M_PI 3.14159265358979323846 /* pi */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user