01-07-2020, 01:56 PM
(This post was last modified: 01-19-2020, 12:55 PM by Brian Beuken.)
and to finish off, once its all set up creating a basic window is very simple, you do this.
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(SCRWIDTH, SCRHEIGHT);
io.DeltaTime = DT;
// we should also pass on mouse and key info into the IO here
// now if just displaying text there's no need to send key and mouse info, but if you want interaction then is simple enough to pass the mouse down and position as well as keys pressed.
// get on with the text/windows
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame(); // do this at the start of any frame
// position the window
ImGui::SetNextWindowPos(ImVec2(200, 200));
ImGui::SetNextWindowSize(ImVec2(400, 200));
// make sure you begin by naming the window
ImGui::Begin("Resolution Info"); // begin starts the window up and provides the name for it, you can fill in all manner of content from this point on and when done use end to close the content
// send text or buttons or sliders or whatver
ImGui::Text("hello there");
// end
ImGui::End();
// you can of course have more than one window....repeat the above at a different point and do a new begin/end sandwich.
// now render it somewhere in your main loop, ideally after you render all your other content.
ImGui::Render();
// and finally render to the GPU
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2(SCRWIDTH, SCRHEIGHT);
io.DeltaTime = DT;
// we should also pass on mouse and key info into the IO here
// now if just displaying text there's no need to send key and mouse info, but if you want interaction then is simple enough to pass the mouse down and position as well as keys pressed.
// get on with the text/windows
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame(); // do this at the start of any frame
// position the window
ImGui::SetNextWindowPos(ImVec2(200, 200));
ImGui::SetNextWindowSize(ImVec2(400, 200));
// make sure you begin by naming the window
ImGui::Begin("Resolution Info"); // begin starts the window up and provides the name for it, you can fill in all manner of content from this point on and when done use end to close the content
// send text or buttons or sliders or whatver
ImGui::Text("hello there");
// end
ImGui::End();
// you can of course have more than one window....repeat the above at a different point and do a new begin/end sandwich.
// now render it somewhere in your main loop, ideally after you render all your other content.
ImGui::Render();
// and finally render to the GPU
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's