Move window ownership to the window backend

This commit is contained in:
Clownacy 2020-04-04 20:51:07 +01:00
parent 1d665aaab6
commit 1ae63bea96
10 changed files with 19 additions and 13 deletions

View file

@ -338,13 +338,13 @@ if(BACKEND_PLATFORM MATCHES "SDL2")
"src/Backends/SDL2/Controller.cpp"
"src/Backends/SDL2/Controller.h"
"src/Backends/SDL2/Misc.cpp"
"src/Backends/SDL2/Misc.h"
"src/Backends/SDL2/Window.h"
)
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
target_sources(CSE2 PRIVATE
"src/Backends/GLFW3/Controller.cpp"
"src/Backends/GLFW3/Misc.cpp"
"src/Backends/GLFW3/Misc.h"
"src/Backends/GLFW3/Window.h"
)
endif()

View file

@ -1,5 +1,4 @@
#include "../Misc.h"
#include "Misc.h"
#include <chrono>
#include <stddef.h>
@ -12,6 +11,7 @@
#include "../../WindowsWrapper.h"
#include "Window.h"
#include "../Rendering.h"
#include "../../Main.h"
#include "../../Organya.h"
@ -23,8 +23,6 @@
backend_keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
break;
GLFWwindow *window;
BOOL bActive = TRUE;
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];

View file

@ -1,4 +1,5 @@
#include "../Window-OpenGL.h"
#include "Window.h"
#include <stddef.h>
#include <stdlib.h>
@ -13,7 +14,8 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
#include "Misc.h"
GLFWwindow *window;
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
{

View file

@ -9,7 +9,7 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
#include "../SDL2/Misc.h"
#include "../SDL2/Window.h"
typedef struct RenderBackend_Surface
{
@ -21,6 +21,8 @@ typedef struct RenderBackend_Glyph
SDL_Surface *sdlsurface;
} RenderBackend_Glyph;
SDL_Window *window;
static SDL_Surface *window_sdlsurface;
static RenderBackend_Surface framebuffer;

View file

@ -13,7 +13,7 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
#include "../SDL2/Misc.h"
#include "../SDL2/Window.h"
#include "../../Draw.h"
#include "../../Ending.h"
#include "../../MapName.h"
@ -38,6 +38,8 @@ typedef struct RenderBackend_Glyph
unsigned int height;
} RenderBackend_Glyph;
SDL_Window *window;
static SDL_Renderer *renderer;
static RenderBackend_Surface framebuffer;

View file

@ -9,7 +9,7 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
#include "../SDL2/Misc.h"
#include "../SDL2/Window.h"
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
@ -36,6 +36,8 @@ static RenderBackend_Surface framebuffer;
static unsigned char glyph_colour_channels[3];
static RenderBackend_Surface *glyph_destination_surface;
SDL_Window *window;
RenderBackend_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);

View file

@ -1,5 +1,4 @@
#include "../Misc.h"
#include "Misc.h"
#include <stddef.h>
#include <stdio.h>
@ -10,6 +9,7 @@
#include "../../WindowsWrapper.h"
#include "Controller.h"
#include "Window.h"
#include "../Rendering.h"
#include "../../Main.h"
#include "../../Organya.h"
@ -21,8 +21,6 @@
backend_keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
break;
SDL_Window *window;
BOOL bActive = TRUE;
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];

View file

@ -1,4 +1,5 @@
#include "../Window-OpenGL.h"
#include "Window.h"
#include <stddef.h>
@ -12,9 +13,10 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
#include "Misc.h"
#include "../../Resource.h"
SDL_Window *window;
static SDL_GLContext context;
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)