Move window ownership to the window backend
This commit is contained in:
parent
1d665aaab6
commit
1ae63bea96
10 changed files with 19 additions and 13 deletions
|
@ -338,13 +338,13 @@ if(BACKEND_PLATFORM MATCHES "SDL2")
|
||||||
"src/Backends/SDL2/Controller.cpp"
|
"src/Backends/SDL2/Controller.cpp"
|
||||||
"src/Backends/SDL2/Controller.h"
|
"src/Backends/SDL2/Controller.h"
|
||||||
"src/Backends/SDL2/Misc.cpp"
|
"src/Backends/SDL2/Misc.cpp"
|
||||||
"src/Backends/SDL2/Misc.h"
|
"src/Backends/SDL2/Window.h"
|
||||||
)
|
)
|
||||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
||||||
target_sources(CSE2 PRIVATE
|
target_sources(CSE2 PRIVATE
|
||||||
"src/Backends/GLFW3/Controller.cpp"
|
"src/Backends/GLFW3/Controller.cpp"
|
||||||
"src/Backends/GLFW3/Misc.cpp"
|
"src/Backends/GLFW3/Misc.cpp"
|
||||||
"src/Backends/GLFW3/Misc.h"
|
"src/Backends/GLFW3/Window.h"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
#include "Misc.h"
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
#include "../Rendering.h"
|
#include "../Rendering.h"
|
||||||
#include "../../Main.h"
|
#include "../../Main.h"
|
||||||
#include "../../Organya.h"
|
#include "../../Organya.h"
|
||||||
|
@ -23,8 +23,6 @@
|
||||||
backend_keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
|
backend_keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GLFWwindow *window;
|
|
||||||
|
|
||||||
BOOL bActive = TRUE;
|
BOOL bActive = TRUE;
|
||||||
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../Window-OpenGL.h"
|
#include "../Window-OpenGL.h"
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -13,7 +14,8 @@
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Misc.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)
|
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
#include "../SDL2/Misc.h"
|
#include "../SDL2/Window.h"
|
||||||
|
|
||||||
typedef struct RenderBackend_Surface
|
typedef struct RenderBackend_Surface
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,8 @@ typedef struct RenderBackend_Glyph
|
||||||
SDL_Surface *sdlsurface;
|
SDL_Surface *sdlsurface;
|
||||||
} RenderBackend_Glyph;
|
} RenderBackend_Glyph;
|
||||||
|
|
||||||
|
SDL_Window *window;
|
||||||
|
|
||||||
static SDL_Surface *window_sdlsurface;
|
static SDL_Surface *window_sdlsurface;
|
||||||
|
|
||||||
static RenderBackend_Surface framebuffer;
|
static RenderBackend_Surface framebuffer;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
#include "../SDL2/Misc.h"
|
#include "../SDL2/Window.h"
|
||||||
#include "../../Draw.h"
|
#include "../../Draw.h"
|
||||||
#include "../../Ending.h"
|
#include "../../Ending.h"
|
||||||
#include "../../MapName.h"
|
#include "../../MapName.h"
|
||||||
|
@ -38,6 +38,8 @@ typedef struct RenderBackend_Glyph
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
} RenderBackend_Glyph;
|
} RenderBackend_Glyph;
|
||||||
|
|
||||||
|
SDL_Window *window;
|
||||||
|
|
||||||
static SDL_Renderer *renderer;
|
static SDL_Renderer *renderer;
|
||||||
|
|
||||||
static RenderBackend_Surface framebuffer;
|
static RenderBackend_Surface framebuffer;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
#include "../SDL2/Misc.h"
|
#include "../SDL2/Window.h"
|
||||||
|
|
||||||
#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))
|
||||||
|
@ -36,6 +36,8 @@ static RenderBackend_Surface framebuffer;
|
||||||
static unsigned char glyph_colour_channels[3];
|
static unsigned char glyph_colour_channels[3];
|
||||||
static RenderBackend_Surface *glyph_destination_surface;
|
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)
|
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);
|
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
#include "Misc.h"
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -10,6 +9,7 @@
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
#include "Window.h"
|
||||||
#include "../Rendering.h"
|
#include "../Rendering.h"
|
||||||
#include "../../Main.h"
|
#include "../../Main.h"
|
||||||
#include "../../Organya.h"
|
#include "../../Organya.h"
|
||||||
|
@ -21,8 +21,6 @@
|
||||||
backend_keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
|
backend_keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
SDL_Window *window;
|
|
||||||
|
|
||||||
BOOL bActive = TRUE;
|
BOOL bActive = TRUE;
|
||||||
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../Window-OpenGL.h"
|
#include "../Window-OpenGL.h"
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
@ -12,9 +13,10 @@
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Misc.h"
|
#include "../Misc.h"
|
||||||
#include "Misc.h"
|
|
||||||
#include "../../Resource.h"
|
#include "../../Resource.h"
|
||||||
|
|
||||||
|
SDL_Window *window;
|
||||||
|
|
||||||
static SDL_GLContext context;
|
static SDL_GLContext context;
|
||||||
|
|
||||||
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
|
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
|
||||||
|
|
Loading…
Add table
Reference in a new issue