void myInitOGLFun() { sgct::TextureManager::instance()->setAnisotropicFilterSize(8.0f); sgct::TextureManager::instance()->setCompression(sgct::TextureManager::S3TC_DXT); sgct::TextureManager::instance()->loadTexure("box", "../SharedResources/box.png", true); myBox = new sgct_utils::SGCTBox(2.0f, sgct_utils::SGCTBox::Regular); //Set up backface culling glCullFace(GL_BACK); glFrontFace(GL_CCW); //our polygon winding is counter clockwise sgct::ShaderManager::instance()->addShaderProgram( "xform", "SimpleVertexShader.vertexshader", "SimpleFragmentShader.fragmentshader" ); sgct::ShaderManager::instance()->bindShaderProgram( "xform" ); Matrix_Loc = sgct::ShaderManager::instance()->getShaderProgram( "xform").getUniformLocation( "MVP" ); GLint Tex_Loc = sgct::ShaderManager::instance()->getShaderProgram( "xform").getUniformLocation( "Tex" ); glUniform1i( Tex_Loc, 0 ); sgct::ShaderManager::instance()->unBindShaderProgram(); // Setup ImGui binding if( gEngine->isMaster() ) ImGui_ImplGlfwGL3_Init(gEngine->getCurrentWindowPtr()->getWindowHandle()); }
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(); }
void DebugLayer::init(graphics::Window* window) { m_window = window; ImGui_ImplGlfwGL3_Init(window->getGLFWwindow(), false); glfwSetCharCallback(m_window->getGLFWwindow(), ImGui_ImplGlfwGL3_CharCallback); glfwSetScrollCallback(window->getGLFWwindow(), ImGui_ImplGlfwGL3_ScrollCallback); }
void Subsystem::Startup() { gl3wInit(); ImGui_ImplGlfwGL3_Init(Graphics::Subsystem::Instance()->Adapter->Window, true); Initialized = true; }
void GUI::Startup(GLFWwindow* window) { //Initialise ImGUI ImGui_ImplGlfwGL3_Init(window, true); ImGuiIO& io = ImGui::GetIO(); //Get window size and give to ImGUI int width = 0, height = 0; glfwGetWindowSize(window, &width, &height); io.DisplaySize.x = (float)width; io.DisplaySize.y = (float)height; }
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() { DEBUGLOG->setAutoPrint(true); ////////////////////////////////////////////////////////////////////////////// /////////////////////// INIT ////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // create window and opengl context auto window = generateWindow(800,800); ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// RENDERING /////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ///////////////////// Scene / View Settings ////////////////////////// glm::mat4 model = glm::mat4(1.0f); glm::vec4 eye(0.0f, 0.0f, 3.0f, 1.0f); glm::vec4 center(0.0f,0.0f,0.0f,1.0f); glm::mat4 view = glm::lookAt(glm::vec3(eye), glm::vec3(center), glm::vec3(0,1,0)); // glm::mat4 perspective = glm::ortho(-2.0f, 2.0f, -2.0f, 2.0f, -1.0f, 6.0f); /// perspective projection is experimental; yields weird warping effects due to vertex interpolation of uv-coordinates glm::mat4 perspective = glm::perspective(glm::radians(65.f), getRatio(window), 0.1f, 10.f); // create object // Sphere grid; Grid grid(10,10,0.1f,0.1f,true); // Volume grid; // load grass texture s_texHandle = TextureTools::loadTexture(RESOURCES_PATH + std::string( "/grass.png")); glBindTexture(GL_TEXTURE_2D, s_texHandle); /////////////////////// Renderpass /////////////////////////// DEBUGLOG->log("Shader Compilation: volume uvw coords"); DEBUGLOG->indent(); ShaderProgram shaderProgram("/modelSpace/GBuffer.vert", "/modelSpace/GBuffer.frag"); DEBUGLOG->outdent(); shaderProgram.update("model", model); shaderProgram.update("view", view); shaderProgram.update("projection", perspective); shaderProgram.update("color", glm::vec4(1.0f,0.0f,0.0f,1.0f)); DEBUGLOG->log("FrameBufferObject Creation: volume uvw coords"); DEBUGLOG->indent(); FrameBufferObject fbo(getResolution(window).x, getResolution(window).y); FrameBufferObject::s_internalFormat = GL_RGBA32F; // to allow arbitrary values in G-Buffer fbo.addColorAttachments(4); DEBUGLOG->outdent(); // G-Buffer FrameBufferObject::s_internalFormat = GL_RGBA; // restore default RenderPass renderPass(&shaderProgram, &fbo); renderPass.addEnable(GL_DEPTH_TEST); renderPass.addClearBit(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); renderPass.addRenderable(&grid); ShaderProgram compShader("/screenSpace/fullscreen.vert", "/screenSpace/finalCompositing.frag"); // ShaderProgram compShader("/screenSpace/fullscreen.vert", "/screenSpace/simpleAlphaTexture.frag"); Quad quad; RenderPass compositing(&compShader, 0); compositing.addClearBit(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); compositing.addRenderable(&quad); // Geometry test shader ShaderProgram geomShader("/modelSpace/geometry.vert", "/modelSpace/simpleLighting.frag", "/geometry/simpleGeom.geom"); RenderPass geom(&geomShader, 0); geom.addClearBit(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); geom.addRenderable(&grid); geom.addEnable(GL_DEPTH_TEST); geom.addEnable(GL_ALPHA_TEST); geom.addEnable(GL_BLEND); glAlphaFunc(GL_GREATER, 0); geomShader.update("projection", perspective); ////////////////////////////////////////////////////////////////////////////// /////////////////////// GUI / USER INPUT //////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); Turntable turntable; double old_x; double old_y; glfwGetCursorPos(window, &old_x, &old_y); auto cursorPosCB = [&](double x, double y) { ImGuiIO& io = ImGui::GetIO(); if ( io.WantCaptureMouse ) { return; } // ImGUI is handling this double d_x = x - old_x; double d_y = y - old_y; if ( turntable.getDragActive() ) { turntable.dragBy(d_x, d_y, view); } old_x = x; old_y = y; }; auto mouseButtonCB = [&](int b, int a, int m) { if (b == GLFW_MOUSE_BUTTON_LEFT && a == GLFW_PRESS) { turntable.setDragActive(true); } if (b == GLFW_MOUSE_BUTTON_LEFT && a == GLFW_RELEASE) { turntable.setDragActive(false); } ImGui_ImplGlfwGL3_MouseButtonCallback(window, b, a, m); }; auto keyboardCB = [&](int k, int s, int a, int m) { if (a == GLFW_RELEASE) {return;} switch (k) { case GLFW_KEY_W: eye += glm::inverse(view) * glm::vec4(0.0f,0.0f,-0.1f,0.0f); center += glm::inverse(view) * glm::vec4(0.0f,0.0f,-0.1f,0.0f); break; case GLFW_KEY_A: eye += glm::inverse(view) * glm::vec4(-0.1f,0.0f,0.0f,0.0f); center += glm::inverse(view) * glm::vec4(-0.1f,0.0f,0.0f,0.0f); break; case GLFW_KEY_S: eye += glm::inverse(view) * glm::vec4(0.0f,0.0f,0.1f,0.0f); center += glm::inverse(view) * glm::vec4(0.0f,0.0f,0.1f,0.0f); break; case GLFW_KEY_D: eye += glm::inverse(view) * glm::vec4(0.1f,0.0f,0.0f,0.0f); center += glm::inverse(view) * glm::vec4(0.1f,0.0f,0.0f,0.0f); break; default: break; } ImGui_ImplGlfwGL3_KeyCallback(window,k,s,a,m); }; setCursorPosCallback(window, cursorPosCB); setMouseButtonCallback(window, mouseButtonCB); setKeyCallback(window, keyboardCB); ////////////////////////////////////////////////////////////////////////////// //////////////////////////////// RENDER LOOP ///////////////////////////////// ////////////////////////////////////////////////////////////////////////////// double elapsedTime = 0.0; render(window, [&](double dt) { elapsedTime += dt; std::string window_header = "Volume Renderer - " + std::to_string( 1.0 / dt ) + " FPS"; glfwSetWindowTitle(window, window_header.c_str() ); //////////////////////////////// GUI //////////////////////////////// ImGuiIO& io = ImGui::GetIO(); ImGui_ImplGlfwGL3_NewFrame(); // tell ImGui a new frame is being rendered ImGui::PushItemWidth(-100); if (ImGui::CollapsingHeader("Geometry Shader Settings")) { ImGui::ColorEdit4( "color", glm::value_ptr( s_color)); // color mixed at max distance ImGui::SliderFloat("strength", &s_strength, 0.0f, 2.0f); // influence of color shift } ImGui::Checkbox("auto-rotate", &s_isRotating); // enable/disable rotating volume ImGui::PopItemWidth(); ////////////////////////////////////////////////////////////////////////////// ///////////////////////////// MATRIX UPDATING /////////////////////////////// if (s_isRotating) // update view matrix { model = glm::rotate(glm::mat4(1.0f), (float) dt, glm::vec3(0.0f, 1.0f, 0.0f) ) * model; } view = glm::lookAt(glm::vec3(eye), glm::vec3(center), glm::vec3(0.0f, 1.0f, 0.0f)); ////////////////////////////////////////////////////////////////////////////// //////////////////////// SHADER / UNIFORM UPDATING ////////////////////////// // update view related uniforms shaderProgram.update( "view", view); shaderProgram.update( "model", turntable.getRotationMatrix() * model); geomShader.update( "view", view); geomShader.update( "model", turntable.getRotationMatrix() * model); compShader.update( "vLightPos", view * turntable.getRotationMatrix() * s_lightPos); updateVectorTexture(elapsedTime); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, s_vectorTexture); // glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // this is altered by ImGui::Render(), so reset it every frame glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, s_texHandle); geomShader.update("tex", 1); geomShader.update("blendColor", 2.0); geomShader.update("color", s_color); geomShader.update("strength", s_strength); ////////////////////////////////////////////////////////////////////////////// //////////////////////////////// RENDERING //// ///////////////////////////// // glActiveTexture(GL_TEXTURE0); // glBindTexture(GL_TEXTURE_2D, fbo.getColorAttachmentTextureHandle(GL_COLOR_ATTACHMENT0)); // color // glActiveTexture(GL_TEXTURE1); // glBindTexture(GL_TEXTURE_2D, fbo.getColorAttachmeHntTextureHandle(GL_COLOR_ATTACHMENT1)); // normal // glActiveTexture(GL_TEXTURE2); // glBindTexture(GL_TEXTURE_2D, fbo.getColorAttachmentTextureHandle(GL_COLOR_ATTACHMENT2)); // position // glActiveTexture(GL_TEXTURE0); // compShader.update("colorMap", 0); // compShader.update("normalMap", 1); // compShader.update("positionMap", 2); // renderPass.render(); // compositing.render(); geom.render(); ImGui::Render(); glDisable(GL_BLEND); glBlendFunc(GL_ONE, GL_ZERO); // this is altered by ImGui::Render(), so reset it every frame ////////////////////////////////////////////////////////////////////////////// }); destroyWindow(window); return 0; }
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; }
void Gui::init(ptr<Window> w) { ImGui_ImplGlfwGL3_Init(static_cast<GLFWwindow*>(w->getWindowPtr()), false); ImGui_ImplGlfwGL3_CreateDeviceObjects(); }
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; }
GLFWOSPRayWindow::GLFWOSPRayWindow(const ospcommon::vec2i &windowSize, const ospcommon::box3f &worldBounds, OSPModel model, OSPRenderer renderer) : windowSize(windowSize), worldBounds(worldBounds), model(model), renderer(renderer) { if (activeWindow != nullptr) throw std::runtime_error("Cannot create more than one GLFWOSPRayWindow!"); activeWindow = this; // initialize GLFW if (!glfwInit()) throw std::runtime_error("Failed to initialize GLFW!"); // create GLFW window glfwWindow = glfwCreateWindow( windowSize.x, windowSize.y, "OSPRay Tutorial", NULL, NULL); if (!glfwWindow) { glfwTerminate(); throw std::runtime_error("Failed to create GLFW window!"); } // make the window's context current glfwMakeContextCurrent(glfwWindow); ImGui_ImplGlfwGL3_Init(glfwWindow, true); // set initial OpenGL state glEnable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); // create OpenGL frame buffer texture glGenTextures(1, &framebufferTexture); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, framebufferTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // set GLFW callbacks glfwSetFramebufferSizeCallback( glfwWindow, [](GLFWwindow *, int newWidth, int newHeight) { activeWindow->reshape(ospcommon::vec2i{newWidth, newHeight}); }); glfwSetCursorPosCallback(glfwWindow, [](GLFWwindow *, double x, double y) { ImGuiIO &io = ImGui::GetIO(); if (!io.WantCaptureMouse) activeWindow->motion(ospcommon::vec2f{float(x), float(y)}); }); glfwSetKeyCallback(glfwWindow, [](GLFWwindow *, int key, int, int action, int) { if (action == GLFW_PRESS) { switch (key) { case GLFW_KEY_G: activeWindow->showUi = !(activeWindow->showUi); break; } } }); // OSPRay setup // set the model on the renderer ospSetObject(renderer, "model", model); // create the arcball camera model arcballCamera = std::unique_ptr<ArcballCamera>( new ArcballCamera(worldBounds, windowSize)); // create camera camera = ospNewCamera("perspective"); ospSetf(camera, "aspect", windowSize.x / float(windowSize.y)); ospSetVec3f(camera, "pos", osp::vec3f{arcballCamera->eyePos().x, arcballCamera->eyePos().y, arcballCamera->eyePos().z}); ospSetVec3f(camera, "dir", osp::vec3f{arcballCamera->lookDir().x, arcballCamera->lookDir().y, arcballCamera->lookDir().z}); ospSetVec3f(camera, "up", osp::vec3f{arcballCamera->upDir().x, arcballCamera->upDir().y, arcballCamera->upDir().z}); ospCommit(camera); // set camera on the renderer ospSetObject(renderer, "camera", camera); // finally, commit the renderer ospCommit(renderer); // trigger window reshape events with current window size glfwGetFramebufferSize(glfwWindow, &this->windowSize.x, &this->windowSize.y); reshape(this->windowSize); }
int run( int width, int height, const std::string& caption, const std::function<void(GLFWwindow* window)>& func) { if (!glfwInit()) { std::cerr << "Cannot initialize glfw." << std::endl; return -1; } auto window = create_window(width, height, caption); if (!window) { std::cerr << "Cannot create window." << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); glfwSwapInterval(0); if (!gladLoadGL()) { std::cerr << "Cannot load glad extensions." << std::endl; glfwTerminate(); return -1; } std::cerr << "Loaded OpenGL " << GLVersion.major << "." << GLVersion.minor << " profile." << std::endl; window_context_t* context = new window_context_t(); glfwSetWindowUserPointer(window, context); glfwSetWindowSizeCallback(window, window_resize); window_resize(window, width, height); context->program_id = create_program(); context->sampler_location = glGetUniformLocation(context->program_id, "sampler"); context->scale_location = glGetUniformLocation(context->program_id, "scale"); glGenVertexArrays(1, &context->varray_id); glBindVertexArray(context->varray_id); context->buffer_id = create_fullscreen_quad(); auto& io = ImGui::GetIO(); io.IniFilename = nullptr; ImGui_ImplGlfwGL3_Init(window, true); func(window); if (context->texture_created) { glDeleteTextures(1, &context->texture_id); } glDeleteVertexArrays(1, &context->varray_id); delete context; glfwTerminate(); return 0; }
GLFWwindow* gfx::GraphicsEngine::Initialize( int width, int height, bool vsync, bool fullscreen ){ m_Width = width; m_Height = height; if( !glfwInit( ) ) return nullptr; //glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); //glfwWindowHint(GLFW_DECORATED, GL_FALSE); if(fullscreen){ m_Window = glfwCreateWindow( width, height, "ModelViewer", glfwGetPrimaryMonitor( ), nullptr ); }else{ m_Window = glfwCreateWindow( width, height, "ModelViewer", nullptr, nullptr ); } if(!m_Window) return nullptr; glfwMakeContextCurrent( m_Window ); ImGui_ImplGlfwGL3_Init( m_Window, true ); glewExperimental = GL_TRUE; glewInit( ); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CCW); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); if(vsync){ glfwSwapInterval( 1 ); }else{ glfwSwapInterval( 0 ); } glClearColor(0.2f, 0.2f, 0.2f, 1.0f); //set camera float aspectRatio = width / (float)height; m_Camera.GetEditableLens( ).Near = 0.1f; m_Camera.GetEditableLens( ).Far = 100.0f; m_Camera.GetEditableLens( ).VerticalFOV = ( ( 90.0f / ( aspectRatio ) ) / 360.0f ) * 2 * glm::pi<float>( ); // calc FOV as horisontal FOV 90 degrees m_Camera.GetEditableLens().WindowHeight = height - BUTTON_SIZE * 2; m_Camera.GetEditableLens().WindowWidth = (int)(width * 0.5f); m_Camera.SetPosition(glm::vec3(0.0f, 10.0f, 20.0f)); m_Camera.CalculateViewProjection(); //load shaders m_Shader = g_ShaderBank.LoadShaderProgram( "shader/CombinedShader.glsl" ); m_SpriteShader = g_ShaderBank.LoadShaderProgram("shader/SpriteShader.glsl"); m_GizmoProgram = g_ShaderBank.LoadShaderProgram("shader/GizmoProgram.glsl"); m_LineProgram = g_ShaderBank.LoadShaderProgram("shader/LineShader.glsl"); //Load cubeTex m_SkyTex = new Texture(); m_SkyTex->Init("asset/CubeMaps/square.dds", TEXTURE_CUBE); m_IrradianceTex = new Texture(); m_IrradianceTex->Init("asset/CubeMaps/square_irr.dds", TEXTURE_CUBE); m_FrameBuffer.Init(); glGenBuffers(1, &m_LineVBO); glGenVertexArrays(1, &m_LineVAO); glBindVertexArray(m_LineVAO); glBindBuffer(GL_ARRAY_BUFFER, m_LineVBO); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec2) * 100000, nullptr, GL_DYNAMIC_DRAW); //allocate buffer return m_Window; }
//Main Thread int main(int argc, char** argv) { InitalizeEngine(); InitalizeNetwork(); window = new FireCore::Graphics::Window("Graphics Context -FireCore <Opengl 4.5>", 800, 800); memoryManager = new FireCore::Managers::MemoryManager(); fileManager = new FireCore::Managers::FileManager(memoryManager); renderer = new FireCore::Managers::Renderer(window); sceneManager = new FireCore::Managers::SceneManager(fileManager, renderer,window); /// Load Scenes sceneManager->AddScene(new FireCore::World::Debug()); sceneManager->AddScene(new FireCore::World::LoginScreen()); sceneManager->AddScene(new FireCore::World::Game()); sceneManager->AddScene(new FireCore::World::Graph()); sceneManager->Initialise(); //Threads and loops #if defined DEBUG CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)AdminScene, NULL, NULL, NULL); #endif CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)MessageThread, NULL, NULL, NULL); double lastTime = 0; ImGui_ImplGlfwGL3_Init(window->getWindow(), true); while (true) { double currentTime = glfwGetTime(); double deltaTime = float(currentTime - lastTime); window->Clear(); sceneManager->Update(deltaTime); ImGui_ImplGlfwGL3_NewFrame(); if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu("Levels")) { if (ImGui::MenuItem("Forest", "Index : 0 ")) { sceneManager->ChangeLevel(0); } ImGui::Separator(); if (ImGui::MenuItem("Login Screen", "Index : 1 ")) { sceneManager->ChangeLevel(1); } ImGui::Separator(); if (ImGui::MenuItem("Quarry", "Index : 2 ")) { sceneManager->ChangeLevel(2); } ImGui::Separator(); if (ImGui::MenuItem("Graph Example", "Index : 3 ")) { sceneManager->ChangeLevel(3); } ImGui::Separator(); if (ImGui::MenuItem("Exit", "")) { exit(1); } ImGui::EndMenu(); } if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Edit Object..", NULL, &Edit_Mode)) { if (Edit_Mode){ EditorWindow(&Edit_Mode, renderer->GetSelectedObject()); } } ImGui::Separator(); if (ImGui::MenuItem("Save...")) { std::cout << "Saving file not yet implimented noob..." << std::endl; } ImGui::EndMenu(); } if (ImGui::BeginMenu("Chat")) { if (ImGui::MenuItem("Chat Console", NULL, &Chat_Enabled)) { if (Chat_Enabled){ NetworkChat(&Chat_Enabled); } } ImGui::EndMenu(); } if (ImGui::BeginMenu("Debug")) { if (ImGui::MenuItem("Colliders", NULL, &Collider_Debug)){ renderer->SetDebug(Collider_Debug); } ImGui::Separator(); if (ImGui::MenuItem("Camera -> Tracked", NULL, &Camera_TRACKED)){ Camera_FPS = false; Camera_FIXED = false; renderer->GetCamera()->SetType(FireCore::Graphics::CameraType::Tracked); } if (ImGui::MenuItem("Camera -> FPS", NULL, &Camera_FPS)){ Camera_TRACKED = false; Camera_FIXED = false; renderer->GetCamera()->SetType(FireCore::Graphics::CameraType::FPS); } if (ImGui::MenuItem("Camera -> Fixed", NULL, &Camera_FIXED)){ Camera_FPS = false; Camera_TRACKED = false; renderer->GetCamera()->SetType(FireCore::Graphics::CameraType::Fixed); } ImGui::EndMenu(); } ImGui::EndMainMenuBar(); } if (Chat_Enabled){ NetworkChat(&Chat_Enabled); } if (Edit_Mode){ EditorWindow(&Edit_Mode,renderer->GetSelectedObject()); } ImGui::Render(); window->Update(); lastTime = currentTime; } 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; }
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; }
GUI::GUI(GLFWwindow* window){ ImGui_ImplGlfwGL3_Init(window, false); }
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; }