Change render backend namespace to RenderBackend_
This commit is contained in:
parent
8acdcface4
commit
4d322be866
10 changed files with 166 additions and 166 deletions
|
@ -141,7 +141,7 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||||
{
|
{
|
||||||
(void)window;
|
(void)window;
|
||||||
|
|
||||||
Backend_HandleWindowResize(width, height);
|
RenderBackend_HandleWindowResize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DragAndDropCallback(GLFWwindow *window, int count, const char **paths)
|
static void DragAndDropCallback(GLFWwindow *window, int count, const char **paths)
|
||||||
|
|
|
@ -2,25 +2,25 @@
|
||||||
|
|
||||||
#include "../WindowsWrapper.h"
|
#include "../WindowsWrapper.h"
|
||||||
|
|
||||||
typedef struct Backend_Surface Backend_Surface;
|
typedef struct RenderBackend_Surface RenderBackend_Surface;
|
||||||
typedef struct Backend_Glyph Backend_Glyph;
|
typedef struct RenderBackend_Glyph RenderBackend_Glyph;
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen);
|
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen);
|
||||||
void Backend_Deinit(void);
|
void RenderBackend_Deinit(void);
|
||||||
void Backend_DrawScreen(void);
|
void RenderBackend_DrawScreen(void);
|
||||||
void Backend_ClearScreen(void);
|
void RenderBackend_ClearScreen(void);
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height);
|
RenderBackend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height);
|
||||||
void Backend_FreeSurface(Backend_Surface *surface);
|
void RenderBackend_FreeSurface(RenderBackend_Surface *surface);
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface);
|
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface);
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface);
|
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface);
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height);
|
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height);
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height);
|
void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height);
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key);
|
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key);
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
|
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch);
|
RenderBackend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch);
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph);
|
void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph);
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels);
|
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels);
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y);
|
void RenderBackend_DrawGlyph(RenderBackend_Glyph *glyph, long x, long y);
|
||||||
void Backend_FlushGlyphs(void);
|
void RenderBackend_FlushGlyphs(void);
|
||||||
void Backend_HandleRenderTargetLoss(void);
|
void RenderBackend_HandleRenderTargetLoss(void);
|
||||||
void Backend_HandleWindowResize(unsigned int width, unsigned int height);
|
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height);
|
||||||
|
|
|
@ -36,21 +36,21 @@ typedef enum RenderMode
|
||||||
MODE_DRAW_GLYPH
|
MODE_DRAW_GLYPH
|
||||||
} RenderMode;
|
} RenderMode;
|
||||||
|
|
||||||
typedef struct Backend_Surface
|
typedef struct RenderBackend_Surface
|
||||||
{
|
{
|
||||||
GLuint texture_id;
|
GLuint texture_id;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
} Backend_Surface;
|
} RenderBackend_Surface;
|
||||||
|
|
||||||
typedef struct Backend_Glyph
|
typedef struct RenderBackend_Glyph
|
||||||
{
|
{
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int pitch;
|
unsigned int pitch;
|
||||||
} Backend_Glyph;
|
} RenderBackend_Glyph;
|
||||||
|
|
||||||
typedef struct Coordinate2D
|
typedef struct Coordinate2D
|
||||||
{
|
{
|
||||||
|
@ -91,10 +91,10 @@ static RenderMode last_render_mode;
|
||||||
static GLuint last_source_texture;
|
static GLuint last_source_texture;
|
||||||
static GLuint last_destination_texture;
|
static GLuint last_destination_texture;
|
||||||
|
|
||||||
static Backend_Surface framebuffer;
|
static RenderBackend_Surface framebuffer;
|
||||||
|
|
||||||
static unsigned char glyph_colour_channels[3];
|
static unsigned char glyph_colour_channels[3];
|
||||||
static Backend_Surface *glyph_destination_surface;
|
static RenderBackend_Surface *glyph_destination_surface;
|
||||||
|
|
||||||
static spritebatch_t glyph_batcher;
|
static spritebatch_t glyph_batcher;
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ static void GlyphBatch_Draw(spritebatch_sprite_t *sprites, int count, int textur
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)sprites[i].image_id;
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)sprites[i].image_id;
|
||||||
|
|
||||||
const GLfloat texture_left = sprites[i].minx;
|
const GLfloat texture_left = sprites[i].minx;
|
||||||
const GLfloat texture_right = texture_left + ((GLfloat)glyph->width / (GLfloat)texture_w); // Account for width not matching pitch
|
const GLfloat texture_right = texture_left + ((GLfloat)glyph->width / (GLfloat)texture_w); // Account for width not matching pitch
|
||||||
|
@ -467,7 +467,7 @@ static void GlyphBatch_GetPixels(SPRITEBATCH_U64 image_id, void *buffer, int byt
|
||||||
{
|
{
|
||||||
(void)udata;
|
(void)udata;
|
||||||
|
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)image_id;
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)image_id;
|
||||||
|
|
||||||
memcpy(buffer, glyph->pixels, bytes_to_fill);
|
memcpy(buffer, glyph->pixels, bytes_to_fill);
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ static void GlyphBatch_DestroyTexture(SPRITEBATCH_U64 texture_id, void *udata)
|
||||||
// Render-backend initialisation
|
// Render-backend initialisation
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
actual_screen_width = screen_width;
|
actual_screen_width = screen_width;
|
||||||
actual_screen_height = screen_height;
|
actual_screen_height = screen_height;
|
||||||
|
@ -624,7 +624,7 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void RenderBackend_Deinit(void)
|
||||||
{
|
{
|
||||||
free(local_vertex_buffer);
|
free(local_vertex_buffer);
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ void Backend_Deinit(void)
|
||||||
WindowBackend_OpenGL_DestroyWindow();
|
WindowBackend_OpenGL_DestroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void RenderBackend_DrawScreen(void)
|
||||||
{
|
{
|
||||||
spritebatch_tick(&glyph_batcher);
|
spritebatch_tick(&glyph_batcher);
|
||||||
|
|
||||||
|
@ -737,9 +737,9 @@ void Backend_DrawScreen(void)
|
||||||
// Surface management
|
// Surface management
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
RenderBackend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
|
RenderBackend_Surface *surface = (RenderBackend_Surface*)malloc(sizeof(RenderBackend_Surface));
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -767,7 +767,7 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface)
|
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -780,19 +780,19 @@ void Backend_FreeSurface(Backend_Surface *surface)
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface)
|
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -802,7 +802,7 @@ unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch
|
||||||
return surface->pixels;
|
return surface->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -822,7 +822,7 @@ void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigne
|
||||||
// Drawing
|
// Drawing
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
||||||
{
|
{
|
||||||
if (source_surface == NULL || destination_surface == NULL)
|
if (source_surface == NULL || destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -898,7 +898,7 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
static unsigned char last_red;
|
static unsigned char last_red;
|
||||||
static unsigned char last_green;
|
static unsigned char last_green;
|
||||||
|
@ -963,9 +963,9 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
|
||||||
// Glyph management
|
// Glyph management
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
RenderBackend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)malloc(sizeof(RenderBackend_Glyph));
|
||||||
|
|
||||||
if (glyph != NULL)
|
if (glyph != NULL)
|
||||||
{
|
{
|
||||||
|
@ -994,7 +994,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -1003,19 +1003,19 @@ void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
||||||
free(glyph);
|
free(glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
|
||||||
{
|
{
|
||||||
glyph_destination_surface = destination_surface;
|
glyph_destination_surface = destination_surface;
|
||||||
|
|
||||||
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
void RenderBackend_DrawGlyph(RenderBackend_Glyph *glyph, long x, long y)
|
||||||
{
|
{
|
||||||
spritebatch_push(&glyph_batcher, (SPRITEBATCH_U64)glyph, glyph->pitch, glyph->height, x, y, 1.0f, 1.0f, 0.0f, 0.0f, 0);
|
spritebatch_push(&glyph_batcher, (SPRITEBATCH_U64)glyph, glyph->pitch, glyph->height, x, y, 1.0f, 1.0f, 0.0f, 0.0f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FlushGlyphs(void)
|
void RenderBackend_FlushGlyphs(void)
|
||||||
{
|
{
|
||||||
spritebatch_defrag(&glyph_batcher);
|
spritebatch_defrag(&glyph_batcher);
|
||||||
spritebatch_flush(&glyph_batcher);
|
spritebatch_flush(&glyph_batcher);
|
||||||
|
@ -1025,12 +1025,12 @@ void Backend_FlushGlyphs(void)
|
||||||
// Misc.
|
// Misc.
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
void Backend_HandleRenderTargetLoss(void)
|
void RenderBackend_HandleRenderTargetLoss(void)
|
||||||
{
|
{
|
||||||
// No problem for us
|
// No problem for us
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleWindowResize(unsigned int width, unsigned int height)
|
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
actual_screen_width = width;
|
actual_screen_width = width;
|
||||||
actual_screen_height = height;
|
actual_screen_height = height;
|
||||||
|
|
|
@ -11,19 +11,19 @@
|
||||||
#include "../Platform.h"
|
#include "../Platform.h"
|
||||||
#include "../SDL2/Platform.h"
|
#include "../SDL2/Platform.h"
|
||||||
|
|
||||||
typedef struct Backend_Surface
|
typedef struct RenderBackend_Surface
|
||||||
{
|
{
|
||||||
SDL_Surface *sdlsurface;
|
SDL_Surface *sdlsurface;
|
||||||
} Backend_Surface;
|
} RenderBackend_Surface;
|
||||||
|
|
||||||
typedef struct Backend_Glyph
|
typedef struct RenderBackend_Glyph
|
||||||
{
|
{
|
||||||
SDL_Surface *sdlsurface;
|
SDL_Surface *sdlsurface;
|
||||||
} Backend_Glyph;
|
} RenderBackend_Glyph;
|
||||||
|
|
||||||
static SDL_Surface *window_sdlsurface;
|
static SDL_Surface *window_sdlsurface;
|
||||||
|
|
||||||
static Backend_Surface framebuffer;
|
static RenderBackend_Surface framebuffer;
|
||||||
|
|
||||||
static unsigned char glyph_colour_channels[3];
|
static unsigned char glyph_colour_channels[3];
|
||||||
static SDL_Surface *glyph_destination_sdlsurface;
|
static SDL_Surface *glyph_destination_sdlsurface;
|
||||||
|
@ -42,7 +42,7 @@ static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect)
|
||||||
sdl_rect->h = 0;
|
sdl_rect->h = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
Backend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
|
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
|
||||||
|
|
||||||
|
@ -76,21 +76,21 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void RenderBackend_Deinit(void)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(framebuffer.sdlsurface);
|
SDL_FreeSurface(framebuffer.sdlsurface);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void RenderBackend_DrawScreen(void)
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(framebuffer.sdlsurface, NULL, window_sdlsurface, NULL);
|
SDL_BlitSurface(framebuffer.sdlsurface, NULL, window_sdlsurface, NULL);
|
||||||
SDL_UpdateWindowSurface(window);
|
SDL_UpdateWindowSurface(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
Backend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
|
RenderBackend_Surface *surface = (RenderBackend_Surface*)malloc(sizeof(RenderBackend_Surface));
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -106,7 +106,7 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface)
|
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -115,19 +115,19 @@ void Backend_FreeSurface(Backend_Surface *surface)
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface)
|
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
|
@ -139,14 +139,14 @@ unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch
|
||||||
return (unsigned char*)surface->sdlsurface->pixels;
|
return (unsigned char*)surface->sdlsurface->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
||||||
{
|
{
|
||||||
if (source_surface == NULL || destination_surface == NULL)
|
if (source_surface == NULL || destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -165,7 +165,7 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
|
||||||
SDL_BlitSurface(source_surface->sdlsurface, &source_rect, destination_surface->sdlsurface, &destination_rect);
|
SDL_BlitSurface(source_surface->sdlsurface, &source_rect, destination_surface->sdlsurface, &destination_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -176,9 +176,9 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
|
||||||
SDL_FillRect(surface->sdlsurface, &destination_rect, SDL_MapRGB(surface->sdlsurface->format, red, green, blue));
|
SDL_FillRect(surface->sdlsurface, &destination_rect, SDL_MapRGB(surface->sdlsurface->format, red, green, blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
Backend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)malloc(sizeof(RenderBackend_Glyph));
|
||||||
|
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -208,7 +208,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -217,7 +217,7 @@ void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
||||||
free(glyph);
|
free(glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
|
||||||
{
|
{
|
||||||
if (destination_surface == NULL)
|
if (destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -227,7 +227,7 @@ void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const uns
|
||||||
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
void RenderBackend_DrawGlyph(RenderBackend_Glyph *glyph, long x, long y)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -243,17 +243,17 @@ void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
||||||
SDL_BlitSurface(glyph->sdlsurface, NULL, glyph_destination_sdlsurface, &rect);
|
SDL_BlitSurface(glyph->sdlsurface, NULL, glyph_destination_sdlsurface, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FlushGlyphs(void)
|
void RenderBackend_FlushGlyphs(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleRenderTargetLoss(void)
|
void RenderBackend_HandleRenderTargetLoss(void)
|
||||||
{
|
{
|
||||||
// No problem for us
|
// No problem for us
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleWindowResize(unsigned int width, unsigned int height)
|
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "../../MapName.h"
|
#include "../../MapName.h"
|
||||||
#include "../../TextScr.h"
|
#include "../../TextScr.h"
|
||||||
|
|
||||||
typedef struct Backend_Surface
|
typedef struct RenderBackend_Surface
|
||||||
{
|
{
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
|
@ -27,22 +27,22 @@ typedef struct Backend_Surface
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
BOOL lost;
|
BOOL lost;
|
||||||
|
|
||||||
struct Backend_Surface *next;
|
struct RenderBackend_Surface *next;
|
||||||
struct Backend_Surface *prev;
|
struct RenderBackend_Surface *prev;
|
||||||
} Backend_Surface;
|
} RenderBackend_Surface;
|
||||||
|
|
||||||
typedef struct Backend_Glyph
|
typedef struct RenderBackend_Glyph
|
||||||
{
|
{
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
} Backend_Glyph;
|
} RenderBackend_Glyph;
|
||||||
|
|
||||||
static SDL_Renderer *renderer;
|
static SDL_Renderer *renderer;
|
||||||
|
|
||||||
static Backend_Surface framebuffer;
|
static RenderBackend_Surface framebuffer;
|
||||||
|
|
||||||
static Backend_Surface *surface_list_head;
|
static RenderBackend_Surface *surface_list_head;
|
||||||
|
|
||||||
static unsigned char glyph_colour_channels[3];
|
static unsigned char glyph_colour_channels[3];
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ static void GlyphBatch_Draw(spritebatch_sprite_t *sprites, int count, int textur
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)sprites[i].image_id;
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)sprites[i].image_id;
|
||||||
|
|
||||||
SDL_Rect source_rect = {(int)(texture_w * sprites[i].minx), (int)(texture_h * sprites[i].maxy), (int)glyph->width, (int)glyph->height};
|
SDL_Rect source_rect = {(int)(texture_w * sprites[i].minx), (int)(texture_h * sprites[i].maxy), (int)glyph->width, (int)glyph->height};
|
||||||
SDL_Rect destination_rect = {(int)sprites[i].x, (int)sprites[i].y, (int)glyph->width, (int)glyph->height};
|
SDL_Rect destination_rect = {(int)sprites[i].x, (int)sprites[i].y, (int)glyph->width, (int)glyph->height};
|
||||||
|
@ -90,7 +90,7 @@ static void GlyphBatch_GetPixels(SPRITEBATCH_U64 image_id, void *buffer, int byt
|
||||||
{
|
{
|
||||||
(void)udata;
|
(void)udata;
|
||||||
|
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)image_id;
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)image_id;
|
||||||
|
|
||||||
memcpy(buffer, glyph->pixels, bytes_to_fill);
|
memcpy(buffer, glyph->pixels, bytes_to_fill);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ static void GlyphBatch_DestroyTexture(SPRITEBATCH_U64 texture_id, void *udata)
|
||||||
SDL_DestroyTexture((SDL_Texture*)texture_id);
|
SDL_DestroyTexture((SDL_Texture*)texture_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
Backend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
puts("Available SDL2 render drivers:");
|
puts("Available SDL2 render drivers:");
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void RenderBackend_Deinit(void)
|
||||||
{
|
{
|
||||||
spritebatch_term(&glyph_batcher);
|
spritebatch_term(&glyph_batcher);
|
||||||
SDL_DestroyTexture(framebuffer.texture);
|
SDL_DestroyTexture(framebuffer.texture);
|
||||||
|
@ -200,7 +200,7 @@ void Backend_Deinit(void)
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void RenderBackend_DrawScreen(void)
|
||||||
{
|
{
|
||||||
spritebatch_tick(&glyph_batcher);
|
spritebatch_tick(&glyph_batcher);
|
||||||
|
|
||||||
|
@ -209,9 +209,9 @@ void Backend_DrawScreen(void)
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
Backend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
|
RenderBackend_Surface *surface = (RenderBackend_Surface*)malloc(sizeof(RenderBackend_Surface));
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -239,7 +239,7 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface)
|
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -254,17 +254,17 @@ void Backend_FreeSurface(Backend_Surface *surface)
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
return surface->lost;
|
return surface->lost;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface)
|
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
surface->lost = FALSE;
|
surface->lost = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -276,7 +276,7 @@ unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch
|
||||||
return surface->pixels;
|
return surface->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -312,7 +312,7 @@ void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigne
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
||||||
{
|
{
|
||||||
if (source_surface == NULL || destination_surface == NULL)
|
if (source_surface == NULL || destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -328,7 +328,7 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
|
||||||
SDL_RenderCopy(renderer, source_surface->texture, &source_rect, &destination_rect);
|
SDL_RenderCopy(renderer, source_surface->texture, &source_rect, &destination_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -349,9 +349,9 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
|
||||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
Backend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)malloc(sizeof(RenderBackend_Glyph));
|
||||||
|
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -385,7 +385,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -394,7 +394,7 @@ void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
||||||
free(glyph);
|
free(glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
|
||||||
{
|
{
|
||||||
if (destination_surface == NULL)
|
if (destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -404,24 +404,24 @@ void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const uns
|
||||||
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
void RenderBackend_DrawGlyph(RenderBackend_Glyph *glyph, long x, long y)
|
||||||
{
|
{
|
||||||
spritebatch_push(&glyph_batcher, (SPRITEBATCH_U64)glyph, glyph->width, glyph->height, x, y, 1.0f, 1.0f, 0.0f, 0.0f, 0);
|
spritebatch_push(&glyph_batcher, (SPRITEBATCH_U64)glyph, glyph->width, glyph->height, x, y, 1.0f, 1.0f, 0.0f, 0.0f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FlushGlyphs(void)
|
void RenderBackend_FlushGlyphs(void)
|
||||||
{
|
{
|
||||||
spritebatch_defrag(&glyph_batcher);
|
spritebatch_defrag(&glyph_batcher);
|
||||||
spritebatch_flush(&glyph_batcher);
|
spritebatch_flush(&glyph_batcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleRenderTargetLoss(void)
|
void RenderBackend_HandleRenderTargetLoss(void)
|
||||||
{
|
{
|
||||||
for (Backend_Surface *surface = surface_list_head; surface != NULL; surface = surface->next)
|
for (RenderBackend_Surface *surface = surface_list_head; surface != NULL; surface = surface->next)
|
||||||
surface->lost = TRUE;
|
surface->lost = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleWindowResize(unsigned int width, unsigned int height)
|
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
|
|
|
@ -14,29 +14,29 @@
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
|
||||||
typedef struct Backend_Surface
|
typedef struct RenderBackend_Surface
|
||||||
{
|
{
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int pitch;
|
unsigned int pitch;
|
||||||
} Backend_Surface;
|
} RenderBackend_Surface;
|
||||||
|
|
||||||
typedef struct Backend_Glyph
|
typedef struct RenderBackend_Glyph
|
||||||
{
|
{
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
} Backend_Glyph;
|
} RenderBackend_Glyph;
|
||||||
|
|
||||||
static SDL_Surface *window_sdlsurface;
|
static SDL_Surface *window_sdlsurface;
|
||||||
static SDL_Surface *framebuffer_sdlsurface;
|
static SDL_Surface *framebuffer_sdlsurface;
|
||||||
static Backend_Surface framebuffer;
|
static RenderBackend_Surface framebuffer;
|
||||||
|
|
||||||
static unsigned char glyph_colour_channels[3];
|
static unsigned char glyph_colour_channels[3];
|
||||||
static Backend_Surface *glyph_destination_surface;
|
static RenderBackend_Surface *glyph_destination_surface;
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
Backend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
|
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
|
||||||
|
|
||||||
|
@ -75,21 +75,21 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void RenderBackend_Deinit(void)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(framebuffer_sdlsurface);
|
SDL_FreeSurface(framebuffer_sdlsurface);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void RenderBackend_DrawScreen(void)
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(framebuffer_sdlsurface, NULL, window_sdlsurface, NULL);
|
SDL_BlitSurface(framebuffer_sdlsurface, NULL, window_sdlsurface, NULL);
|
||||||
SDL_UpdateWindowSurface(window);
|
SDL_UpdateWindowSurface(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
Backend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
|
RenderBackend_Surface *surface = (RenderBackend_Surface*)malloc(sizeof(RenderBackend_Surface));
|
||||||
|
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -109,7 +109,7 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface)
|
void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -118,19 +118,19 @@ void Backend_FreeSurface(Backend_Surface *surface)
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface)
|
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
|
@ -142,14 +142,14 @@ unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch
|
||||||
return surface->pixels;
|
return surface->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
||||||
{
|
{
|
||||||
if (source_surface == NULL || destination_surface == NULL)
|
if (source_surface == NULL || destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -232,7 +232,7 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -290,9 +290,9 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
Backend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
|
RenderBackend_Glyph *glyph = (RenderBackend_Glyph*)malloc(sizeof(RenderBackend_Glyph));
|
||||||
|
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -314,7 +314,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -323,7 +323,7 @@ void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
||||||
free(glyph);
|
free(glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
|
||||||
{
|
{
|
||||||
if (destination_surface == NULL)
|
if (destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -333,7 +333,7 @@ void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const uns
|
||||||
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
void RenderBackend_DrawGlyph(RenderBackend_Glyph *glyph, long x, long y)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -357,17 +357,17 @@ void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_FlushGlyphs(void)
|
void RenderBackend_FlushGlyphs(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleRenderTargetLoss(void)
|
void RenderBackend_HandleRenderTargetLoss(void)
|
||||||
{
|
{
|
||||||
// No problem for us
|
// No problem for us
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_HandleWindowResize(unsigned int width, unsigned int height)
|
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
|
|
|
@ -222,7 +222,7 @@ BOOL PlatformBackend_SystemTask(void)
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
Backend_HandleWindowResize(event.window.data1, event.window.data2);
|
RenderBackend_HandleWindowResize(event.window.data1, event.window.data2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ BOOL PlatformBackend_SystemTask(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
case SDL_RENDER_TARGETS_RESET:
|
case SDL_RENDER_TARGETS_RESET:
|
||||||
Backend_HandleRenderTargetLoss();
|
RenderBackend_HandleRenderTargetLoss();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
48
src/Draw.cpp
48
src/Draw.cpp
|
@ -32,9 +32,9 @@ RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||||
int magnification;
|
int magnification;
|
||||||
BOOL fullscreen;
|
BOOL fullscreen;
|
||||||
|
|
||||||
static Backend_Surface *framebuffer;
|
static RenderBackend_Surface *framebuffer;
|
||||||
|
|
||||||
static Backend_Surface *surf[SURFACE_ID_MAX];
|
static RenderBackend_Surface *surf[SURFACE_ID_MAX];
|
||||||
|
|
||||||
static FontObject *font;
|
static FontObject *font;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ BOOL Flip_SystemTask(void)
|
||||||
else
|
else
|
||||||
timePrev += 20;
|
timePrev += 20;
|
||||||
|
|
||||||
Backend_DrawScreen();
|
RenderBackend_DrawScreen();
|
||||||
|
|
||||||
if (RestoreSurfaces())
|
if (RestoreSurfaces())
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ BOOL StartDirectDraw(const char *title, int width, int height, int lMagnificatio
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
framebuffer = Backend_Init(title, width, height, fullscreen);
|
framebuffer = RenderBackend_Init(title, width, height, fullscreen);
|
||||||
|
|
||||||
if (framebuffer == NULL)
|
if (framebuffer == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -123,14 +123,14 @@ void EndDirectDraw(void)
|
||||||
{
|
{
|
||||||
if (surf[i] != NULL)
|
if (surf[i] != NULL)
|
||||||
{
|
{
|
||||||
Backend_FreeSurface(surf[i]);
|
RenderBackend_FreeSurface(surf[i]);
|
||||||
surf[i] = NULL;
|
surf[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
framebuffer = NULL;
|
framebuffer = NULL;
|
||||||
|
|
||||||
Backend_Deinit();
|
RenderBackend_Deinit();
|
||||||
|
|
||||||
memset(surface_metadata, 0, sizeof(surface_metadata));
|
memset(surface_metadata, 0, sizeof(surface_metadata));
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ void ReleaseSurface(SurfaceID s)
|
||||||
// Release the surface we want to release
|
// Release the surface we want to release
|
||||||
if (surf[s] != NULL)
|
if (surf[s] != NULL)
|
||||||
{
|
{
|
||||||
Backend_FreeSurface(surf[s]);
|
RenderBackend_FreeSurface(surf[s]);
|
||||||
surf[s] = NULL;
|
surf[s] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ static BOOL ScaleAndUploadSurface(const unsigned char *image_buffer, int width,
|
||||||
{
|
{
|
||||||
// IF YOU WANT TO ADD HD SPRITES, THIS IS THE CODE YOU SHOULD EDIT
|
// IF YOU WANT TO ADD HD SPRITES, THIS IS THE CODE YOU SHOULD EDIT
|
||||||
unsigned int pitch;
|
unsigned int pitch;
|
||||||
unsigned char *pixels = Backend_LockSurface(surf[surf_no], &pitch, width * magnification, height * magnification);
|
unsigned char *pixels = RenderBackend_LockSurface(surf[surf_no], &pitch, width * magnification, height * magnification);
|
||||||
|
|
||||||
if (magnification == 1)
|
if (magnification == 1)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ static BOOL ScaleAndUploadSurface(const unsigned char *image_buffer, int width,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_UnlockSurface(surf[surf_no], width * magnification, height * magnification);
|
RenderBackend_UnlockSurface(surf[surf_no], width * magnification, height * magnification);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
|
||||||
if (image_buffer == NULL)
|
if (image_buffer == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
surf[surf_no] = Backend_CreateSurface(width * magnification, height * magnification);
|
surf[surf_no] = RenderBackend_CreateSurface(width * magnification, height * magnification);
|
||||||
|
|
||||||
if (surf[surf_no] == NULL)
|
if (surf[surf_no] == NULL)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
|
||||||
|
|
||||||
if (!ScaleAndUploadSurface(image_buffer, width, height, surf_no))
|
if (!ScaleAndUploadSurface(image_buffer, width, height, surf_no))
|
||||||
{
|
{
|
||||||
Backend_FreeSurface(surf[surf_no]);
|
RenderBackend_FreeSurface(surf[surf_no]);
|
||||||
FreeBitmap(image_buffer);
|
FreeBitmap(image_buffer);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
surf[surf_no] = Backend_CreateSurface(width * magnification, height * magnification);
|
surf[surf_no] = RenderBackend_CreateSurface(width * magnification, height * magnification);
|
||||||
|
|
||||||
if (surf[surf_no] == NULL)
|
if (surf[surf_no] == NULL)
|
||||||
{
|
{
|
||||||
|
@ -290,7 +290,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
|
||||||
|
|
||||||
if (!ScaleAndUploadSurface(image_buffer, width, height, surf_no))
|
if (!ScaleAndUploadSurface(image_buffer, width, height, surf_no))
|
||||||
{
|
{
|
||||||
Backend_FreeSurface(surf[surf_no]);
|
RenderBackend_FreeSurface(surf[surf_no]);
|
||||||
FreeBitmap(image_buffer);
|
FreeBitmap(image_buffer);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem
|
||||||
if (surf[surf_no] != NULL)
|
if (surf[surf_no] != NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
surf[surf_no] = Backend_CreateSurface(bxsize * magnification, bysize * magnification);
|
surf[surf_no] = RenderBackend_CreateSurface(bxsize * magnification, bysize * magnification);
|
||||||
|
|
||||||
if (surf[surf_no] == NULL)
|
if (surf[surf_no] == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -418,7 +418,7 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect)
|
||||||
scaled_rect.right = rect->right * magnification;
|
scaled_rect.right = rect->right * magnification;
|
||||||
scaled_rect.bottom = rect->bottom * magnification;
|
scaled_rect.bottom = rect->bottom * magnification;
|
||||||
|
|
||||||
Backend_Blit(framebuffer, &scaled_rect, surf[surf_no], scaled_rect.left, scaled_rect.top, FALSE);
|
RenderBackend_Blit(framebuffer, &scaled_rect, surf[surf_no], scaled_rect.left, scaled_rect.top, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency
|
void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency
|
||||||
|
@ -450,7 +450,7 @@ void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
|
||||||
rcWork.right *= magnification;
|
rcWork.right *= magnification;
|
||||||
rcWork.bottom *= magnification;
|
rcWork.bottom *= magnification;
|
||||||
|
|
||||||
Backend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, TRUE);
|
RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency
|
void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency
|
||||||
|
@ -482,7 +482,7 @@ void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
|
||||||
rcWork.right *= magnification;
|
rcWork.right *= magnification;
|
||||||
rcWork.bottom *= magnification;
|
rcWork.bottom *= magnification;
|
||||||
|
|
||||||
Backend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, FALSE);
|
RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
|
void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
|
||||||
|
@ -494,7 +494,7 @@ void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
|
||||||
rcWork.right = rect->right * magnification;
|
rcWork.right = rect->right * magnification;
|
||||||
rcWork.bottom = rect->bottom * magnification;
|
rcWork.bottom = rect->bottom * magnification;
|
||||||
|
|
||||||
Backend_Blit(surf[from], &rcWork, surf[to], x * magnification, y * magnification, TRUE);
|
RenderBackend_Blit(surf[from], &rcWork, surf[to], x * magnification, y * magnification, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long GetCortBoxColor(unsigned long col)
|
unsigned long GetCortBoxColor(unsigned long col)
|
||||||
|
@ -515,7 +515,7 @@ void CortBox(const RECT *rect, unsigned long col)
|
||||||
const unsigned char green = (col >> 8) & 0xFF;
|
const unsigned char green = (col >> 8) & 0xFF;
|
||||||
const unsigned char blue = (col >> 16) & 0xFF;
|
const unsigned char blue = (col >> 16) & 0xFF;
|
||||||
|
|
||||||
Backend_ColourFill(framebuffer, &dst_rect, red, green, blue);
|
RenderBackend_ColourFill(framebuffer, &dst_rect, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
|
void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
|
||||||
|
@ -532,7 +532,7 @@ void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
|
||||||
const unsigned char green = (col >> 8) & 0xFF;
|
const unsigned char green = (col >> 8) & 0xFF;
|
||||||
const unsigned char blue = (col >> 16) & 0xFF;
|
const unsigned char blue = (col >> 16) & 0xFF;
|
||||||
|
|
||||||
Backend_ColourFill(surf[surf_no], &dst_rect, red, green, blue);
|
RenderBackend_ColourFill(surf[surf_no], &dst_rect, red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DummiedOutLogFunction(int unknown)
|
BOOL DummiedOutLogFunction(int unknown)
|
||||||
|
@ -560,10 +560,10 @@ int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the L
|
||||||
if (framebuffer == NULL)
|
if (framebuffer == NULL)
|
||||||
return surfaces_regenerated;
|
return surfaces_regenerated;
|
||||||
|
|
||||||
if (Backend_IsSurfaceLost(framebuffer))
|
if (RenderBackend_IsSurfaceLost(framebuffer))
|
||||||
{
|
{
|
||||||
++surfaces_regenerated;
|
++surfaces_regenerated;
|
||||||
Backend_RestoreSurface(framebuffer);
|
RenderBackend_RestoreSurface(framebuffer);
|
||||||
DummiedOutLogFunction(0x62);
|
DummiedOutLogFunction(0x62);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,10 +571,10 @@ int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the L
|
||||||
{
|
{
|
||||||
if (surf[s] != NULL)
|
if (surf[s] != NULL)
|
||||||
{
|
{
|
||||||
if (Backend_IsSurfaceLost(surf[s]))
|
if (RenderBackend_IsSurfaceLost(surf[s]))
|
||||||
{
|
{
|
||||||
++surfaces_regenerated;
|
++surfaces_regenerated;
|
||||||
Backend_RestoreSurface(surf[s]);
|
RenderBackend_RestoreSurface(surf[s]);
|
||||||
DummiedOutLogFunction(0x30 + s);
|
DummiedOutLogFunction(0x30 + s);
|
||||||
|
|
||||||
if (!surface_metadata[s].bSystem)
|
if (!surface_metadata[s].bSystem)
|
||||||
|
|
14
src/Font.cpp
14
src/Font.cpp
|
@ -32,7 +32,7 @@ typedef struct CachedGlyph
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int x_advance;
|
int x_advance;
|
||||||
Backend_Glyph *backend;
|
RenderBackend_Glyph *backend;
|
||||||
|
|
||||||
struct CachedGlyph *next;
|
struct CachedGlyph *next;
|
||||||
} CachedGlyph;
|
} CachedGlyph;
|
||||||
|
@ -1014,7 +1014,7 @@ static CachedGlyph* GetGlyphCached(FontObject *font_object, unsigned long unicod
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph->backend = Backend_LoadGlyph(bitmap.buffer, bitmap.width, bitmap.rows, bitmap.pitch);
|
glyph->backend = RenderBackend_LoadGlyph(bitmap.buffer, bitmap.width, bitmap.rows, bitmap.pitch);
|
||||||
|
|
||||||
FT_Bitmap_Done(font_object->library, &bitmap);
|
FT_Bitmap_Done(font_object->library, &bitmap);
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1029,7 @@ static void UnloadCachedGlyphs(FontObject *font_object)
|
||||||
{
|
{
|
||||||
CachedGlyph *next_glyph = glyph->next;
|
CachedGlyph *next_glyph = glyph->next;
|
||||||
|
|
||||||
Backend_UnloadGlyph(glyph->backend);
|
RenderBackend_UnloadGlyph(glyph->backend);
|
||||||
free(glyph);
|
free(glyph);
|
||||||
|
|
||||||
glyph = next_glyph;
|
glyph = next_glyph;
|
||||||
|
@ -1093,13 +1093,13 @@ FontObject* LoadFont(const char *font_filename, unsigned int cell_width, unsigne
|
||||||
return font_object;
|
return font_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawText(FontObject *font_object, Backend_Surface *surface, int x, int y, unsigned long colour, const char *string)
|
void DrawText(FontObject *font_object, RenderBackend_Surface *surface, int x, int y, unsigned long colour, const char *string)
|
||||||
{
|
{
|
||||||
if (font_object != NULL)
|
if (font_object != NULL)
|
||||||
{
|
{
|
||||||
const unsigned char colour_channels[3] = {(unsigned char)colour, (unsigned char)(colour >> 8), (unsigned char)(colour >> 16)};
|
const unsigned char colour_channels[3] = {(unsigned char)colour, (unsigned char)(colour >> 8), (unsigned char)(colour >> 16)};
|
||||||
|
|
||||||
Backend_PrepareToDrawGlyphs(surface, colour_channels);
|
RenderBackend_PrepareToDrawGlyphs(surface, colour_channels);
|
||||||
|
|
||||||
unsigned int pen_x = 0;
|
unsigned int pen_x = 0;
|
||||||
|
|
||||||
|
@ -1124,13 +1124,13 @@ void DrawText(FontObject *font_object, Backend_Surface *surface, int x, int y, u
|
||||||
const int letter_y = y + glyph->y;
|
const int letter_y = y + glyph->y;
|
||||||
|
|
||||||
if (glyph->backend != NULL)
|
if (glyph->backend != NULL)
|
||||||
Backend_DrawGlyph(glyph->backend, letter_x, letter_y);
|
RenderBackend_DrawGlyph(glyph->backend, letter_x, letter_y);
|
||||||
|
|
||||||
pen_x += glyph->x_advance;
|
pen_x += glyph->x_advance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend_FlushGlyphs();
|
RenderBackend_FlushGlyphs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,5 @@ typedef struct FontObject FontObject;
|
||||||
|
|
||||||
FontObject* LoadFontFromData(const unsigned char *data, size_t data_size, unsigned int cell_width, unsigned int cell_height);
|
FontObject* LoadFontFromData(const unsigned char *data, size_t data_size, unsigned int cell_width, unsigned int cell_height);
|
||||||
FontObject* LoadFont(const char *font_filename, unsigned int cell_width, unsigned int cell_height);
|
FontObject* LoadFont(const char *font_filename, unsigned int cell_width, unsigned int cell_height);
|
||||||
void DrawText(FontObject *font_object, Backend_Surface *surface, int x, int y, unsigned long colour, const char *string);
|
void DrawText(FontObject *font_object, RenderBackend_Surface *surface, int x, int y, unsigned long colour, const char *string);
|
||||||
void UnloadFont(FontObject *font_object);
|
void UnloadFont(FontObject *font_object);
|
||||||
|
|
Loading…
Add table
Reference in a new issue