
Along with being more accurate to the original, this fixes switching out of fullscreen causing textures to disappear. This was caused by DirectX destroying textures that are marked as render-targets when a device-loss occurs. SDL2 doesn't do anything to recover them, unlike regular textures, so my solution is just to avoid render-target textures entirely. On the upside, this should make drawing text to surfaces much faster, since we're not reading back bitmaps from the GPU.
12 lines
500 B
C
12 lines
500 B
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "SDL.h"
|
|
|
|
typedef struct FontObject FontObject;
|
|
|
|
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);
|
|
void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsigned long colour, const char *string, size_t string_length);
|
|
void UnloadFont(FontObject *font_object);
|