r/cpp_questions • u/Usual_Office_1740 • 4d ago
OPEN Rendering text through ImGui?
I'm hoping to get a basic repl running with ImGui, OpenGL, and GLFW. I'm comfortable with GLfW and OpenGL rendering but not the ImGui portion.
My question is, can I use the OpenGL context and the GLFW window and then get basic text editing functionality with just ImGui? No opengl buffers, no custom shaders. I think the opengl context needs a default vertex and fragment shader to function but I'm looking to keep that very minimal and handle basic repl input and text rendering between imgui::begin() and imgui::end(). A basic per keypress render loop where each GLFW key event updates a string and then ImGui renders a new frame for the window. I haven't worked with ImGui before. Do you think this is possible?
1
u/dougbinks 1d ago
Dear ImGui comes with a GLFW + OpenGL backend and example which can render text and the demo has a set of text input widget examples.
I've also created a RCC++ Dear ImGui GLFW example with Power Saving example which shows how to use
glfwWaitEventsinstead of polling to reduce power consumption by only running when there is input.