5 #include <imgui/imgui.h>
6 #include <imgui/imgui_impl_sdl.h>
7 #include <imgui/imgui_impl_opengl3.h>
10 #include "nta/Window.h"
11 #include "nta/Logger.h"
12 #include "nta/IOManager.h"
13 #include "nta/utils.h"
16 WindowID Window::m_keyboard_focus(0);
17 std::mutex Window::m_keyboard_mutex;
18 WindowID Window::m_mouse_focus(0);
19 std::mutex Window::m_mouse_mutex;
33 WindowID Window::getKeyboardFocus() {
34 std::lock_guard<std::mutex> g(m_keyboard_mutex);
35 return m_keyboard_focus;
37 void Window::setKeyboardFocus(
const WindowID& win) {
38 std::lock_guard<std::mutex> g(m_keyboard_mutex);
39 m_keyboard_focus = win;
41 WindowID Window::getMouseFocus() {
42 std::lock_guard<std::mutex> g(m_mouse_mutex);
45 void Window::setMouseFocus(
const WindowID& win) {
46 std::lock_guard<std::mutex> g(m_mouse_mutex);
50 return glm::vec2(
m_width, m_height);
62 SDL_SetWindowSize(
m_window, width, height);
77 int sdlFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
78 if (flags & BORDERLESS) {
79 sdlFlags |= SDL_WINDOW_BORDERLESS;
81 if (flags & FULLSCREEN) {
82 sdlFlags |= SDL_WINDOW_FULLSCREEN;
84 if (flags & INVISIBLE) {
85 sdlFlags |= SDL_WINDOW_HIDDEN;
87 if (flags & NOTRESIZEABLE) {
88 sdlFlags &= ~SDL_WINDOW_RESIZABLE;
90 if (flags & HIGHDPI) {
91 sdlFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
93 m_window = SDL_CreateWindow(
m_title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
96 auto context = SDL_GL_CreateContext(
m_window);
102 glewExperimental = GL_TRUE;
104 const GLenum err = glewInit();
105 if (err != GLEW_OK) {
110 glBindFramebuffer(GL_FRAMEBUFFER, 0);
114 ImGui_ImplOpenGL3_Init();
115 ImGui_ImplSDL2_InitForOpenGL(
m_window, context);
126 ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());