ref: 1ae63bea967e9952c60814d8f0caa36534262498
parent: 1d665aaab66db903cf06c1dc6eac1a5ad5dd3106
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Apr 4 16:51:07 EDT 2020
Move window ownership to the window backend
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,13 +338,13 @@
"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()
--- a/src/Backends/GLFW3/Misc.cpp
+++ b/src/Backends/GLFW3/Misc.cpp
@@ -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"
@@ -22,8 +22,6 @@
case GLFW_KEY: \
backend_keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
break;
-
-GLFWwindow *window;
BOOL bActive = TRUE;
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
--- a/src/Backends/GLFW3/Misc.h
+++ /dev/null
@@ -1,7 +1,0 @@
-#pragma once
-
-#define GLFW_INCLUDE_NONE
-#include <GLFW/glfw3.h>
-#undef GLFW_INCLUDE_NONE
-
-extern GLFWwindow *window;
--- a/src/Backends/GLFW3/Window-OpenGL3.cpp
+++ b/src/Backends/GLFW3/Window-OpenGL3.cpp
@@ -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)
{
--- /dev/null
+++ b/src/Backends/GLFW3/Window.h
@@ -1,0 +1,7 @@
+#pragma once
+
+#define GLFW_INCLUDE_NONE
+#include <GLFW/glfw3.h>
+#undef GLFW_INCLUDE_NONE
+
+extern GLFWwindow *window;
--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -9,7 +9,7 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
-#include "../SDL2/Misc.h"
+#include "../SDL2/Window.h"
typedef struct RenderBackend_Surface
{
@@ -20,6 +20,8 @@
{
SDL_Surface *sdlsurface;
} RenderBackend_Glyph;
+
+SDL_Window *window;
static SDL_Surface *window_sdlsurface;
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -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"
@@ -37,6 +37,8 @@
unsigned int width;
unsigned int height;
} RenderBackend_Glyph;
+
+SDL_Window *window;
static SDL_Renderer *renderer;
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -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))
@@ -35,6 +35,8 @@
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)
{
--- a/src/Backends/SDL2/Misc.cpp
+++ b/src/Backends/SDL2/Misc.cpp
@@ -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"
@@ -20,8 +20,6 @@
case SDL_KEY: \
backend_keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
break;
-
-SDL_Window *window;
BOOL bActive = TRUE;
BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
--- a/src/Backends/SDL2/Misc.h
+++ /dev/null
@@ -1,5 +1,0 @@
-#pragma once
-
-#include "SDL.h"
-
-extern SDL_Window *window;
--- a/src/Backends/SDL2/Window-OpenGL3.cpp
+++ b/src/Backends/SDL2/Window-OpenGL3.cpp
@@ -1,4 +1,5 @@
#include "../Window-OpenGL.h"
+#include "Window.h"
#include <stddef.h>
@@ -12,8 +13,9 @@
#include "../../WindowsWrapper.h"
#include "../Misc.h"
-#include "Misc.h"
#include "../../Resource.h"
+
+SDL_Window *window;
static SDL_GLContext context;
--- /dev/null
+++ b/src/Backends/SDL2/Window.h
@@ -1,0 +1,5 @@
+#pragma once
+
+#include "SDL.h"
+
+extern SDL_Window *window;