Converted SDLSurface renderer
This commit is contained in:
parent
f6f3c26a3b
commit
87b296c513
1 changed files with 26 additions and 11 deletions
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
|
#include "../../Resource.h"
|
||||||
|
|
||||||
typedef struct Backend_Surface
|
typedef struct Backend_Surface
|
||||||
{
|
{
|
||||||
SDL_Surface *sdlsurface;
|
SDL_Surface *sdlsurface;
|
||||||
|
@ -36,28 +38,41 @@ static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect)
|
||||||
sdl_rect->h = 0;
|
sdl_rect->h = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Window* Backend_CreateWindow(const char *title, int width, int height)
|
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||||
}
|
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(SDL_Window *p_window)
|
if (window != NULL)
|
||||||
{
|
{
|
||||||
window = p_window;
|
#ifndef _WIN32 // On Windows, we use native icons instead (so we can give the taskbar and window separate icons, like the original EXE does)
|
||||||
|
size_t resource_size;
|
||||||
|
const unsigned char *resource_data = FindResource("ICON_MINI", "ICON", &resource_size);
|
||||||
|
SDL_RWops *rwops = SDL_RWFromConstMem(resource_data, resource_size);
|
||||||
|
SDL_Surface *icon_surface = SDL_LoadBMP_RW(rwops, 1);
|
||||||
|
SDL_SetWindowIcon(window, icon_surface);
|
||||||
|
SDL_FreeSurface(icon_surface);
|
||||||
|
#endif
|
||||||
|
|
||||||
window_sdlsurface = SDL_GetWindowSurface(window);
|
if (fullscreen)
|
||||||
|
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
|
||||||
|
|
||||||
framebuffer.sdlsurface = SDL_CreateRGBSurfaceWithFormat(0, window_sdlsurface->w, window_sdlsurface->h, 0, SDL_PIXELFORMAT_RGB24);
|
window_sdlsurface = SDL_GetWindowSurface(window);
|
||||||
|
|
||||||
if (framebuffer.sdlsurface == NULL)
|
framebuffer.sdlsurface = SDL_CreateRGBSurfaceWithFormat(0, window_sdlsurface->w, window_sdlsurface->h, 0, SDL_PIXELFORMAT_RGB24);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return &framebuffer;
|
if (framebuffer.sdlsurface != NULL)
|
||||||
|
return &framebuffer;
|
||||||
|
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void Backend_Deinit(void)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(framebuffer.sdlsurface);
|
SDL_FreeSurface(framebuffer.sdlsurface);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void Backend_DrawScreen(void)
|
||||||
|
|
Loading…
Add table
Reference in a new issue