10 #include <SDL2/SDL_ttf.h>
13 #include <imgui/imgui.h>
14 #include <imgui/imgui_impl_sdl.h>
15 #include <imgui/imgui_impl_opengl3.h>
18 #include "nta/MyEngine.h"
19 #include "nta/ResourceManager.h"
20 #include "nta/WindowManager.h"
21 #include "nta/CallbackManager.h"
22 #include "nta/Logger.h"
23 #include "nta/Random.h"
24 #include "nta/utils.h"
27 #include "nta/AudioManager.h"
32 static std::map<std::ostream*, std::unique_ptr<std::mutex>> g_stream_locks;
33 static std::mutex g_map_lock;
36 void init(
int gl_major_version,
int gl_minor_version,
bool use_gl_core) {
41 if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
45 if (gl_major_version > 0) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, gl_major_version);
46 if (gl_minor_version >= 0) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, gl_minor_version);
47 if (use_gl_core) SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
48 SDL_SetCursor(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR));
53 ImGui::CreateContext();
54 ImGui::StyleColorsDark();
71 ImGui_ImplOpenGL3_Shutdown();
72 ImGui_ImplSDL2_Shutdown();
73 ImGui::DestroyContext();
75 ResourceManager::destroy();
86 int err = GL_NO_ERROR;
87 if (SDL_GL_GetCurrentContext() !=
nullptr) {
88 while ((err = glGetError()) != GL_NO_ERROR) {
89 gl_err += gl_err ==
"" ?
"" :
"\n";
96 std::string sdl_err = SDL_GetError();
101 return err != GL_NO_ERROR || sdl_err !=
"";
105 auto& lock = g_stream_locks[&stream];
106 if (!lock) lock.reset(
new std::mutex);
113 auto& lock = g_stream_locks[&stream];
115 if (lock) lock->unlock();