Add an SDL_Surface-based renderer
Ha, my custom software renderer is faster!
This commit is contained in:
parent
f21f17f4c2
commit
44456e4a25
6 changed files with 19 additions and 7 deletions
|
@ -11,7 +11,7 @@ option(JAPANESE "Enable the Japanese-language build" OFF)
|
|||
option(FIX_BUGS "Fix certain bugs (see src/Bug Fixes.txt)" OFF)
|
||||
option(NONPORTABLE "Enable bits of code that aren't portable, but are what the original game used" OFF)
|
||||
option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF)
|
||||
set(RENDERER "Texture" CACHE STRING "Which renderer the game should use: 'Texture' for SDL2's hardware-accelerated Texture API, and 'Software' for a handwritten software renderer")
|
||||
set(RENDERER "Texture" CACHE STRING "Which renderer the game should use: 'Texture' for SDL2's hardware-accelerated Texture API, 'Surface' for SDL2's software-rendered Surface API, and 'Software' for a handwritten software renderer")
|
||||
|
||||
project(CSE2 LANGUAGES C CXX)
|
||||
|
||||
|
@ -248,8 +248,12 @@ endif()
|
|||
|
||||
if(RENDERER MATCHES "Texture")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/SDLTexture.cpp")
|
||||
elseif(RENDERER MATCHES "Surface")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/SDLSurface.cpp")
|
||||
elseif(RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Software.cpp")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid RENDERER selected")
|
||||
endif()
|
||||
|
||||
# Make some tweaks if we're targetting Windows
|
||||
|
|
4
Makefile
4
Makefile
|
@ -210,8 +210,12 @@ endif
|
|||
|
||||
ifeq ($(RENDERER), Texture)
|
||||
SOURCES += Backends/Rendering/SDLTexture
|
||||
else ifeq ($(RENDERER), Surface)
|
||||
SOURCES += Backends/Rendering/Software
|
||||
else ifeq ($(RENDERER), Software)
|
||||
SOURCES += Backends/Rendering/Software
|
||||
else
|
||||
@echo Invalid RENDERER selected; this build will fail
|
||||
endif
|
||||
|
||||
OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
|
||||
|
|
|
@ -30,7 +30,10 @@ You can also add the following flags:
|
|||
* `-DNONPORTABLE=ON` - Enable bits of code that aren't portable, but are what the original game used
|
||||
* `-DFORCE_LOCAL_LIBS=ON` - Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones
|
||||
* `-DRENDERER=Texture` - Use the hardware-accelerated SDL2 Texture API renderer (default)
|
||||
* `-DRENDERER=Software` - Use the software renderer
|
||||
* `-DRENDERER=Surface` - Use SDL2's software-renderer Surface API
|
||||
* `-DRENDERER=Texture` - Use the hardware-accelerated SDL2 Texture API renderer (default)
|
||||
* `-DRENDERER=Surface` - Use the software-rendered SDL2 Surface API renderer
|
||||
* `-DRENDERER=Software` - Use a handwritten software renderer
|
||||
|
||||
Then compile CSE2 with this command:
|
||||
|
||||
|
@ -56,7 +59,8 @@ Run 'make' in this folder, preferably with some of the following settings:
|
|||
* `RASPBERRY_PI=1` - Enable tweaks to improve performance on Raspberry Pis
|
||||
* `NONPORTABLE=1` - Enable bits of code that aren't portable, but are what the original game used
|
||||
* `RENDERER=Texture` - Use the hardware-accelerated SDL2 Texture API renderer (default)
|
||||
* `RENDERER=Software` - Use the software renderer
|
||||
* `RENDERER=Surface` - Use the software-rendered SDL2 Surface API renderer
|
||||
* `RENDERER=Software` - Use a hand-written software renderer
|
||||
|
||||
### Visual Studio .NET 2003
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "../Font.h"
|
||||
|
||||
struct Backend_Surface;
|
||||
typedef struct Backend_Surface Backend_Surface;
|
||||
|
||||
BOOL Backend_Init(SDL_Window *window);
|
||||
void Backend_Deinit(void);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "../../Font.h"
|
||||
|
||||
struct Backend_Surface
|
||||
typedef struct Backend_Surface
|
||||
{
|
||||
BOOL needs_syncing;
|
||||
SDL_Surface *sdl_surface;
|
||||
|
@ -17,7 +17,7 @@ struct Backend_Surface
|
|||
|
||||
struct Backend_Surface *next;
|
||||
struct Backend_Surface *prev;
|
||||
};
|
||||
} Backend_Surface;
|
||||
|
||||
static SDL_Renderer *renderer;
|
||||
static SDL_Texture *screen_texture;
|
||||
|
|
|
@ -15,7 +15,7 @@ struct Backend_Surface
|
|||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int pitch;
|
||||
};
|
||||
} Backend_Surface;
|
||||
|
||||
static SDL_Window *window;
|
||||
static SDL_Surface *window_surface;
|
||||
|
|
Loading…
Add table
Reference in a new issue