int main( int argc, char* argv[] ) { gEngine = new sgct::Engine( argc, argv ); gEngine->setInitOGLFunction( myInitOGLFun ); gEngine->setDrawFunction( myDrawFun ); gEngine->setPreSyncFunction( myPreSyncFun ); gEngine->setCleanUpFunction( myCleanUpFun ); gEngine->setKeyboardCallbackFunction( keyCallback ); gEngine->setCharCallbackFunction( charCallback ); gEngine->setMouseButtonCallbackFunction( mouseButtonCallback ); gEngine->setMouseScrollCallbackFunction( mouseScrollCallback ); if( !gEngine->init( sgct::Engine::OpenGL_3_3_Core_Profile ) ) { delete gEngine; return EXIT_FAILURE; } sgct::SharedData::instance()->setEncodeFunction(myEncodeFun); sgct::SharedData::instance()->setDecodeFunction(myDecodeFun); // Main loop gEngine->render(); // Clean up if( gEngine->isMaster() ) ImGui_ImplGlfwGL3_Shutdown(); delete gEngine; // Exit program exit( EXIT_SUCCESS ); }
void GLApplication::Run() { InitializeOpenGL(); Initialize(); Input::CreateSingleton(); Gizmos::create(); if (m_bDrawGUI) { ImGui_ImplGlfwGL3_Init(m_pWindow, true); ImGuiIO& io = ImGui::GetIO(); io.DisplaySize.x = GetScreenWidth(); io.DisplaySize.y = GetScreenHeight(); } m_bRunning = true; while (!glfwWindowShouldClose(m_pWindow) && m_bRunning) { m_lastTime = m_currentTime; m_currentTime = (float)glfwGetTime(); m_deltaTime = m_currentTime - m_lastTime; glClearColor(m_clearColour.r, m_clearColour.g, m_clearColour.b, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); Gizmos::clear(); if(m_bDrawGUI) ImGui_ImplGlfwGL3_NewFrame(); Update(m_deltaTime); UpdateFPS(m_deltaTime); if (m_pCamera) { m_pCamera->Update(m_deltaTime); Render(); Gizmos::draw(m_pCamera->GetProjectionView()); if (m_bDrawGUI) ImGui::Render(); } glfwSwapBuffers(m_pWindow); glfwPollEvents(); } if (m_bDrawGUI) { ImGui_ImplGlfwGL3_Shutdown(); } Gizmos::destroy(); glfwDestroyWindow(m_pWindow); glfwTerminate(); }
int main(int, char**) { // Setup window glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(1); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(1280, 720, "Empty imgui program", NULL, NULL); glfwMakeContextCurrent(window); gl3wInit(); // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); ImVec4 clear_color = ImColor(114, 144, 154); // Main loop while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); glfwPollEvents(); ImGui_ImplGlfwGL3_NewFrame(); make_gui(); // Rendering glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } // Cleanup ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); return 0; }
MainWindow::MainWindow() { // Setup window glfwSetErrorCallback(on_error); if (!glfwInit()) exit(1); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(1280, 720, "xds", NULL, NULL); if (window) { glfwMakeContextCurrent(window); gl3wInit(); ImGui_ImplGlfwGL3_Init(window, true); while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); glfwPollEvents(); ImGui_ImplGlfwGL3_NewFrame(); ImGui::SetNextWindowSize(ImVec2(400, 100), ImGuiSetCond_FirstUseEver); ImGui::Begin("Test Window"); ImGui::Text("TODO: Move this to new thread so xds can run in the background."); ImGui::Text("Close the window to continue xds execution."); ImGui::End(); // Rendering glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); ImVec4 clear_color = ImColor(114, 144, 154); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } // Cleanup ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); } }
int main(int argc, char** argv) { if(argc != 2) { std::cout << "Usage:\n\t" << argv[0] << " IMAGE" << std::endl; return 1; } // Setup window glfwSetErrorCallback(error_callback); if (!glfwInit()) return 1; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #if __APPLE__ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); #endif GLFWwindow* window = glfwCreateWindow(1280, 720, "HBVisionGraphEditor", NULL, NULL); glfwMakeContextCurrent(window); gl3wInit(); // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); ImVec4 clear_color = ImColor(39, 40, 34); cv::Mat image = cv::imread(argv[1]); Solution solution(image); AlgSimple simple; Preview preview{solution}; Preview preview2{solution}; while (!glfwWindowShouldClose(window)) { if(!glfwGetWindowAttrib(window, GLFW_ICONIFIED) && glfwGetWindowAttrib(window, GLFW_VISIBLE)) { glfwPollEvents(); ImGui_ImplGlfwGL3_NewFrame(); // Settings ImGui::BeginMainMenuBar(); int menuHeight = ImGui::GetTextLineHeightWithSpacing(); if(ImGui::BeginMenu("File")) { if(ImGui::MenuItem("Quit")) { glfwSetWindowShouldClose(window, GL_TRUE); } ImGui::EndMenu(); } ImGui::EndMainMenuBar(); bool open = false; ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0); ImGui::SetNextWindowPos(ImVec2(0, menuHeight)); ImGui::SetNextWindowSize(ImVec2(400, ImGui::GetIO().DisplaySize.y - menuHeight)); if (ImGui::Begin("###main", &open, ImVec2(0, 0), 0.5f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoSavedSettings)) { if (ImGui::TreeNodeEx("Solution", ImGuiTreeNodeFlags_DefaultOpen)) { solution.draw(); ImGui::TreePop(); } if (ImGui::TreeNodeEx("Algorithm", ImGuiTreeNodeFlags_DefaultOpen)) { static int currentAlgorithm = 0; ImGui::Combo("###AlgorithmCombo", ¤tAlgorithm, "simple\0empty\0\0"); simple.draw(); ImGui::TreePop(); } ImGui::Spacing(); ImGui::Separator(); ImGui::Spacing(); if (ImGui::Button("Calculate Pattern", ImVec2(ImGui::GetContentRegionAvailWidth(), 20))) { simple.calculate(solution); } } ImGui::End(); ImGui::PopStyleVar(); // Preview preview.draw(solution); preview2.draw(solution); // Rendering int display_w, display_h; glfwGetFramebufferSize(window, &display_w, &display_h); glViewport(0, 0, display_w, display_h); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } else { glfwWaitEvents(); } } // Cleanup ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); return 0; }
int main(int argc, char** argv) { glfwSetErrorCallback(glfwError); if (!glfwInit()) return 1; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* mode = glfwGetVideoMode(monitor); GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "HumanDetection", NULL, NULL); glfwMakeContextCurrent(window); glewExperimental = GL_TRUE; glewInit(); fhd_context detector; fhd_context_init(&detector, 512, 424, 8, 8); ImGui_ImplGlfwGL3_Init(window, true); ImGui::GetStyle().WindowRounding = 0.f; bool show_window = true; fhd_ui ui(&detector); if (argc > 1) { const char* train_database = argv[1]; ui.train_mode = true; fhd_candidate_db_init(&ui.candidate_db, train_database); } ImVec4 clear_color = ImColor(218, 223, 225); while (!glfwWindowShouldClose(window)) { glfwPollEvents(); if (ImGui::IsKeyPressed(GLFW_KEY_ESCAPE)) break; if (ui.train_mode) { if (ImGui::IsKeyPressed(GLFW_KEY_X)) { fhd_ui_clear_candidate_selection(&ui); ui.depth_frame = ui.frame_source->get_frame(); } if (ImGui::IsKeyPressed(GLFW_KEY_SPACE)) { fhd_ui_commit_candidates(&ui); } } else { if (ui.update_enabled) { ui.depth_frame = ui.frame_source->get_frame(); } } if (ui.depth_frame) { auto t1 = std::chrono::high_resolution_clock::now(); fhd_run_pass(&detector, ui.depth_frame); auto t2 = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1); ui.detection_pass_time_ms = double(duration.count()) / 1000.0; fhd_ui_update(&ui, ui.depth_frame); } ImGui_ImplGlfwGL3_NewFrame(); int display_w, display_h; glfwGetFramebufferSize(window, &display_w, &display_h); ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar; ImGui::Begin("foo", &show_window, ImVec2(float(display_w), float(display_h)), -1.f, flags); ImGui::BeginChild("toolbar", ImVec2(300.f, float(display_h))); render_db_selection(&ui); render_classifier_selection(&ui); if (ui.train_mode) { ImGui::Text("*** TRAINING DB: %s ***", argv[1]); } ImGui::Text("detection pass time %.3f ms", ui.detection_pass_time_ms); ImGui::Text("frame source: %s", ui.database_name.c_str()); ImGui::Text("frame %d/%d", ui.frame_source->current_frame(), ui.frame_source->total_frames()); ImGui::Text("classifier: %s", ui.classifier_name.c_str()); ImGui::Checkbox("update enabled", &ui.update_enabled); ImGui::SliderFloat("##det_thresh", &ui.detection_threshold, 0.f, 1.f, "detection threshold %.3f"); ImGui::InputFloat("seg k depth", &ui.fhd->depth_segmentation_threshold); ImGui::InputFloat("seg k normals", &ui.fhd->normal_segmentation_threshold); ImGui::SliderFloat("##min_reg_dim", &ui.fhd->min_region_size, 8.f, 100.f, "min region dimension %.1f"); ImGui::SliderFloat("##merge_dist_x", &ui.fhd->max_merge_distance, 0.1f, 2.f, "max h merge dist (m) %.2f"); ImGui::SliderFloat("##merge_dist_y", &ui.fhd->max_vertical_merge_distance, 0.1f, 3.f, "max v merge dist (m) %.2f"); ImGui::SliderFloat("##min_inlier", &ui.fhd->min_inlier_fraction, 0.5f, 1.f, "RANSAC min inlier ratio %.2f"); ImGui::SliderFloat("##max_plane_dist", &ui.fhd->ransac_max_plane_distance, 0.01f, 1.f, "RANSAC max plane dist %.2f"); ImGui::SliderFloat("##reg_height_min", &ui.fhd->min_region_height, 0.1f, 3.f, "min region height (m) %.2f"); ImGui::SliderFloat("##reg_height_max", &ui.fhd->max_region_height, 0.1f, 3.f, "max region height (m) %.2f"); ImGui::SliderFloat("##reg_width_min", &ui.fhd->min_region_width, 0.1f, 1.f, "min region width (m) %.2f"); ImGui::SliderFloat("##reg_width_max", &ui.fhd->max_region_height, 0.1f, 1.5f, "max region width (m) %.2f"); ImGui::SliderInt("##min_depth_seg_size", &ui.fhd->min_depth_segment_size, 4, 200, "min depth seg size"); ImGui::SliderInt("##min_normal_seg_size", &ui.fhd->min_normal_segment_size, 4, 200, "min normal seg size"); ImGui::EndChild(); ImGui::SameLine(); ImGui::BeginGroup(); ImDrawList* draw_list = ImGui::GetWindowDrawList(); ImVec2 p = ImGui::GetCursorScreenPos(); ImGui::Image((void*)intptr_t(ui.depth_texture.handle), ImVec2(512, 424)); ImU32 rect_color = ImColor(240, 240, 20); for (int i = 0; i < detector.candidates_len; i++) { const fhd_candidate* candidate = &detector.candidates[i]; if (candidate->weight >= 1.f) { const fhd_image_region region = candidate->depth_position; const float x = p.x + float(region.x); const float y = p.y + float(region.y); const float w = float(region.width); const float h = float(region.height); ImVec2 points[4] = { ImVec2(x, y), ImVec2(x + w, y), ImVec2(x + w, y + h), ImVec2(x, y + h) }; draw_list->AddPolyline(points, 4, rect_color, true, 4.f, true); } } ImGui::BeginGroup(); ImGui::Image((void*)intptr_t(ui.normals_texture.handle), ImVec2(256, 212)); ImGui::SameLine(); ImGui::Image((void*)intptr_t(ui.normals_seg_texture.handle), ImVec2(256, 212)); ImGui::EndGroup(); ImGui::BeginGroup(); ImGui::Image((void*)intptr_t(ui.downscaled_depth.handle), ImVec2(256, 212)); ImGui::SameLine(); ImGui::Image((void*)intptr_t(ui.depth_segmentation.handle), ImVec2(256, 212)); ImGui::EndGroup(); ImGui::Image((void*)intptr_t(ui.filtered_regions.handle), ImVec2(256, 212)); ImGui::EndGroup(); ImGui::SameLine(); ImGui::BeginGroup(); if (ui.train_mode) { fhd_candidate_selection_grid(&ui, FHD_HOG_WIDTH * 2, FHD_HOG_HEIGHT * 2); } else { for (int i = 0; i < detector.candidates_len; i++) { fhd_texture* t = &ui.textures[i]; ImGui::Image((void*)intptr_t(t->handle), ImVec2(t->width * 2, t->height * 2)); if (i % 7 < 6) ImGui::SameLine(); } } ImGui::EndGroup(); ImGui::End(); glViewport(0, 0, display_w, display_h); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } if (ui.train_mode) { fhd_candidate_db_close(&ui.candidate_db); } fhd_texture_destroy(&ui.depth_texture); fhd_classifier_destroy(detector.classifier); ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); return 0; }
void Subsystem::Shutdown() { ImGui_ImplGlfwGL3_Shutdown(); Initialized = false; }
int main() { hmk::Logger::get_instance().initialize("engine.txt"); if (glfwInit() == GL_FALSE) { HMK_LOG_ERROR("failed glfwInit") hmk::Logger::get_instance().shutdown(); return -1; } glfwSetErrorCallback(ErrorCallback); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); glfwWindowHint(GLFW_SAMPLES, 8); GLFWwindow* window = glfwCreateWindow(800, 600, "HMK", nullptr, nullptr); if (window == nullptr) { HMK_LOG_ERROR("failed glfwCreateWindow") hmk::Logger::get_instance().shutdown(); glfwTerminate(); return -1; } glfwSetWindowPos(window, 500, 30); glfwMakeContextCurrent(window); if (gl3wInit() == -1) // 0 success { HMK_LOG_ERROR("failed gl3wInit") hmk::Logger::get_instance().shutdown(); glfwTerminate(); return -1; } if (!gl3wIsSupported(3, 3)) { HMK_LOG_ERROR("Upgrade your graphic card!") hmk::Logger::get_instance().shutdown(); glfwTerminate(); return -1; } #if _DEBUG if (glDebugMessageCallback) { glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback(glErrorCallback, nullptr); GLuint unused = 0; glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, &unused, true); } #endif ImGui_ImplGlfwGL3_Init(window, false); Game *game = new Game(); game->initialize(); glfwSetKeyCallback(window, KeyCallback); glfwSetCursorPosCallback(window, CursorPosCallback); glfwSetMouseButtonCallback(window, MouseButtonCallback); glfwSetDropCallback(window, DropCallback); keyCallback = HMK_CALLBACK_4(Game::key_input, game); cursorPosCallback = HMK_CALLBACK_2(Game::cursor_pos_input, game); mouseButtonCallback = HMK_CALLBACK_3(Game::mouse_button_input, game); dropCallback = HMK_CALLBACK_2(Game::drop_files_callback, game); double lastTime = glfwGetTime(); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glDepthRange(0.0f, 1.0f); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CW); glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); // https://www.opengl.org/wiki/Cubemap_Texture#Seamless_cubemap glEnable(GL_MULTISAMPLE); glClearColor(0.2f, 0.3f, 0.2f, 1.0f); double fps = 0.0; double acc = 0.0; while (!glfwWindowShouldClose(window)) { glfwPollEvents(); ImGui_ImplGlfwGL3_NewFrame(); double now = glfwGetTime(); double delta = now - lastTime; lastTime = now; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); game->update((float)delta); game->render(); fps++; acc += delta; if (acc > 1.0) { acc = 0.0; fps = 0.0; } ImGui::Render(); glfwSwapBuffers(window); } delete game; hmk::Logger::get_instance().shutdown(); glfwDestroyWindow(window); ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); return 0; }
int Game::run() { // Initialize if (!initializeGlfw()) { return 1; } if (GLEW_OK != initializeGlew()) { return 2; } initializeGl(); tileManager_->initialize(currentPos_); options_ = tileManager_->getOptions(); ImGui_ImplGlfwGL3_Init(window_, true); deltaTime_ = 0.0f; // Time between current and last frame lastFrame_ = 0.0f; // Time at last frame lastTime_ = 0.0f; // Time since last fps-"second" frameCount_ = 0; // Game loop while (!glfwWindowShouldClose(window_)) { // Calculate deltatime of current frame GLfloat currentTime = glfwGetTime(); deltaTime_ = currentTime - lastFrame_; lastFrame_ = currentTime; // Check for events glfwPollEvents(); // GUI showGui(); // Move do_movement(deltaTime_); // Get current camera position getCurrentPosition(); // Clear color- and depth buffer glClearColor(0.3f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Update and render tiles tileManager_->update(currentPos_); tileManager_->renderAll(deltaTime_, camera_.getViewMatrix()); // Render GUI if (!guiClosed_) { // ignore wireframe setting for gui glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); ImGui::Render(); glPolygonMode(GL_FRONT_AND_BACK, fillmode_); } // Swap the screen buffers glfwSwapBuffers(window_); } // Clean up imgui ImGui_ImplGlfwGL3_Shutdown(); // Clean up tiles tileManager_->cleanUp(); // Terminate GLFW, clearing any resources allocated by GLFW. glfwDestroyWindow(window_); glfwTerminate(); return 0; }
Gui::~Gui() { ImGui_ImplGlfwGL3_Shutdown(); }
GUI::~GUI(){ ImGui_ImplGlfwGL3_Shutdown(); }
int main(int, char**){ const double FRAME_INTERVAL = 1.0 / 60.0; // Setup window glfwSetErrorCallback(error_callback); if (!glfwInit()) return 1; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #if __APPLE__ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); #endif GLFWwindow* window = glfwCreateWindow(1280, 720, "Falton Debug Visualizer", NULL, NULL); glfwMakeContextCurrent(window); gl3wInit(); // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); ImVec4 clear_color = ImColor(0, 0, 0); Phyvis::Context ctx; Phyvis::Init(&ctx); double prevTime = glfwGetTime(); double lag = 0.0f; // Main loop while (!glfwWindowShouldClose(window)) { double time0 = glfwGetTime(); double delta = time0- prevTime; lag += delta; prevTime = time0; while (lag >= FRAME_INTERVAL) { glfwPollEvents(); ImGui_ImplGlfwGL3_NewFrame(); // Rendering int display_w, display_h; glfwGetFramebufferSize(window, &display_w, &display_h); glViewport(0, 0, display_w, display_h); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Phyvis::Tick(&ctx, display_w, display_h); ImGui::Render(); glfwSwapBuffers(window); lag -= FRAME_INTERVAL; } } Phyvis::Cleanup(&ctx); // Cleanup ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); return 0; }
GLFWOSPRayWindow::~GLFWOSPRayWindow() { ImGui_ImplGlfwGL3_Shutdown(); // cleanly terminate GLFW glfwTerminate(); }
void GUI::Shutdown() { ImGui_ImplGlfwGL3_Shutdown(); }
DebugLayer::~DebugLayer() { ImGui_ImplGlfwGL3_Shutdown(); }
int main(int, char**) { // Setup window glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(1); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL3 example", NULL, NULL); glfwMakeContextCurrent(window); gl3wInit(); // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); //ImGuiIO& io = ImGui::GetIO(); //ImFont* my_font0 = io.Fonts->AddFontDefault(); //ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); //ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); //ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1; //ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1; //ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese()); bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); // Main loop while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); glfwPollEvents(); ImGui_ImplGlfwGL3_NewFrame(); // 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); ImGui::ColorEdit3("clear color", (float*)&clear_color); if (ImGui::Button("Test Window")) show_test_window ^= 1; if (ImGui::Button("Another Window")) show_another_window ^= 1; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); } // 2. Show another simple window, this time using an explicit Begin/End pair if (show_another_window) { ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver); ImGui::Begin("Another Window", &show_another_window); 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), ImGuiSetCond_FirstUseEver); ImGui::ShowTestWindow(&show_test_window); } // Rendering glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); glfwSwapBuffers(window); } // Cleanup ImGui_ImplGlfwGL3_Shutdown(); glfwTerminate(); return 0; }