| 14 | static void main_loop(void *); |
| 15 | |
| 16 | int main(int, char **) |
| 17 | { |
| 18 | ImStudio::GUI gui; |
| 19 | gui.bw.objects.reserve(2048); |
| 20 | |
| 21 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) |
| 22 | { |
| 23 | printf("Error: %s\n", SDL_GetError()); |
| 24 | return -1; |
| 25 | } |
| 26 | |
| 27 | const char *glsl_version = "#version 100"; |
| 28 | // const char* glsl_version = "#version 300 es"; |
| 29 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); |
| 30 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); |
| 31 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
| 32 | SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); |
| 33 | |
| 34 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
| 35 | SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); |
| 36 | SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); |
| 37 | SDL_DisplayMode current; |
| 38 | SDL_GetCurrentDisplayMode(0, ¤t); |
| 39 | SDL_WindowFlags window_flags = |
| 40 | (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); |
| 41 | g_Window = SDL_CreateWindow("ImStudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); |
| 42 | g_GLContext = SDL_GL_CreateContext(g_Window); |
| 43 | if (!g_GLContext) |
| 44 | { |
| 45 | fprintf(stderr, "Failed to initialize WebGL context!\n"); |
| 46 | return 1; |
| 47 | } |
| 48 | SDL_GL_SetSwapInterval(1); // Enable vsync |
| 49 | |
| 50 | IMGUI_CHECKVERSION(); |
| 51 | ImGui::CreateContext(); |
| 52 | |
| 53 | MainWindowStyle(); |
| 54 | |
| 55 | ImGui_ImplSDL2_InitForOpenGL(g_Window, g_GLContext); |
| 56 | ImGui_ImplOpenGL3_Init(glsl_version); |
| 57 | |
| 58 | ///////////////////////////////////////////////////////// |
| 59 | emscripten_set_main_loop_arg(main_loop, &gui, 0, true); |
| 60 | ///////////////////////////////////////////////////////// |
| 61 | } |
| 62 | |
| 63 | static void main_loop(void *arg) |
| 64 | { |
nothing calls this directly
no test coverage detected