void Init(HINSTANCE hInstance, int nCmdShow) { // Make sure everything is zero-ed out. memset(&EngineModules, 0, sizeof(FEngineModules)); InitCore(hInstance, nCmdShow); InitRendering(); InitImGui(); }
void DemoInit() { int i; for (i = 0; i < 256; i++) gPressed[i] = gWasPressed[i] = 0; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError()); SDL_Quit(); exit(0); } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; gSDLWindow = SDL_CreateWindow( "", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 400, flags); SDL_GLContext glcontext = SDL_GL_CreateContext(gSDLWindow); SDL_GL_SetSwapInterval(1); glViewport(0, 0, 800, 400); // set window title SDL_SetWindowTitle(gSDLWindow, "http://soloud-audio.com"); #ifndef __EMSCRIPTEN__ glewInit(); #endif InitImGui(); framework_init_flat(); framework_init_tex(); desktop_tex = DemoLoadTexture("graphics/soloud_bg.png"); // Register SDL_Quit to be called at exit; makes sure things are // cleaned up when we quit. atexit(SDL_Quit); }
// Application code int main(int argc, char** argv) { InitGL(); InitImGui(); while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); mousePressed[0] = mousePressed[1] = false; glfwPollEvents(); UpdateImGui(); static bool show_test_window = true; static bool show_another_window = false; // 1. Show a simple window // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" { static float f; ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; static int ms_per_frame_idx = 0; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; const float ms_per_frame_avg = ms_per_frame_accum / 120; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); } // 2. Show another simple window, this time using an explicit Begin/End pair if (show_another_window) { ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100)); ImGui::Text("Hello"); ImGui::End(); } // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow() if (show_test_window) { ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCondition_FirstUseEver); ImGui::ShowTestWindow(&show_test_window); } // Rendering glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(0.8f, 0.6f, 0.6f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } // Cleanup ImGui::Shutdown(); glfwTerminate(); return 0; }
int main(int argc, char** argv) { InitGL(); InitImGui(); double time = glfwGetTime(); while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); glfwPollEvents(); // 1) ImGui start frame, setup time delta & inputs const double current_time = glfwGetTime(); io.DeltaTime = (float)(current_time - time); time = current_time; double mouse_x, mouse_y; glfwGetCursorPos(window, &mouse_x, &mouse_y); io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.) io.MouseDown[0] = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) != 0; io.MouseDown[1] = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) != 0; io.MouseWheel = (mouse_wheel != 0) ? mouse_wheel > 0.0f ? 1 : - 1 : 0; // Mouse wheel: -1,0,+1 mouse_wheel = 0.0f; ImGui::NewFrame(); // 2) ImGui usage static bool show_test_window = true; static bool show_another_window = false; static float f; ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); // Calculate and show framerate static float ms_per_frame[120] = { 0 }; static int ms_per_frame_idx = 0; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = io.DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; const float ms_per_frame_avg = ms_per_frame_accum / 120; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); if (show_test_window) { // More example code in ShowTestWindow() ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly! ImGui::ShowTestWindow(&show_test_window); } if (show_another_window) { ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100)); ImGui::Text("Hello"); ImGui::End(); } // 3) Rendering glClearColor(0.8f, 0.6f, 0.6f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } Shutdown(); return 0; }
// Application code int main(int argc, char** argv) { InitGL(); InitImGui(); while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); io.MouseWheel = 0; glfwPollEvents(); UpdateImGui(); // Create a simple window // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" static bool show_test_window = true; static bool show_another_window = false; static float f; ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); // Calculate and show framerate static float ms_per_frame[120] = { 0 }; static int ms_per_frame_idx = 0; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; const float ms_per_frame_avg = ms_per_frame_accum / 120; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); // Show the ImGui test window // Most of user example code is in ImGui::ShowTestWindow() if (show_test_window) { ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly! ImGui::ShowTestWindow(&show_test_window); } // Show another simple window if (show_another_window) { ImGui::Begin("Another Window", &show_another_window, ImVec2(200,100)); ImGui::Text("Hello"); ImGui::End(); } // Rendering glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(0.8f, 0.6f, 0.6f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } ImGui::Shutdown(); glfwTerminate(); return 0; }