change windows backend to sdl2
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
#include "render/gui/TowerGui.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/imgui_impl_opengl3.h"
|
||||
#include "imgui/imgui_impl_glfw.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "imgui/imgui_impl_sdl.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <thread>
|
||||
#include "game/client/Client.h"
|
||||
#include "game/server/Server.h"
|
||||
@@ -23,19 +23,21 @@
|
||||
|
||||
namespace TowerGui {
|
||||
|
||||
static GLFWwindow* window;
|
||||
static SDL_Window* window;
|
||||
static SDL_GLContext gl_context;
|
||||
static std::unique_ptr<td::client::Client> client;
|
||||
static std::thread* serverThread;
|
||||
static td::render::Renderer* renderer;
|
||||
|
||||
bool serverShouldStop = false;
|
||||
|
||||
void init(GLFWwindow* glfw_window, td::render::Renderer* render) {
|
||||
window = glfw_window;
|
||||
void init(SDL_Window* sdl_window, SDL_GLContext sdlContext, td::render::Renderer* render) {
|
||||
window = sdl_window;
|
||||
gl_context = sdlContext;
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGui::StyleColorsDark();
|
||||
ImGui_ImplGlfw_InitForOpenGL(glfw_window, true);
|
||||
ImGui_ImplSDL2_InitForOpenGL(sdl_window, gl_context);
|
||||
const char* glslVersion = "#version 130";
|
||||
ImGui_ImplOpenGL3_Init(glslVersion);
|
||||
ImFontConfig c;
|
||||
@@ -47,7 +49,7 @@ void init(GLFWwindow* glfw_window, td::render::Renderer* render) {
|
||||
|
||||
void beginFrame() {
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
@@ -62,7 +64,7 @@ void renderFPSCounter() {
|
||||
ImGui::Text("FPS : %i", (int)ImGui::GetIO().Framerate);
|
||||
static bool vsync = true;
|
||||
if (ImGui::Checkbox("V-Sync", &vsync)) {
|
||||
glfwSwapInterval(vsync);
|
||||
SDL_GL_SetSwapInterval(vsync);
|
||||
}
|
||||
static bool isometric = true;
|
||||
if (ImGui::Checkbox("Vue Isometrique ?", &isometric)) {
|
||||
@@ -343,7 +345,7 @@ void destroy() {
|
||||
delete serverThread;
|
||||
}
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user