Hey. I need help on how to make a button in OpenGL c++.
How to make a text box or button in OpenGL window in c++
@taby I know about them, but there is one problem. Both of them don't allow me to place buttons on x and y positions
Shaanveer said:
@taby I know about them, but there is one problem. Both of them don't allow me to place buttons on x and y positions
This is incorrect. Could you show us what you have currently set up, then we'll be able to tell you what you could do differently, to accomplish placing a button.
Do you just want a button rendered o top of whatever you were rendering before? (no panels etc.)
@SuperVGA I am currently trying to find an external gui library that lets me make buttons in x and y positions. I do not know how to make buttons from scratch. A video will be helpful.
Shaanveer said:
@SuperVGA I am currently trying to find an external gui library that lets me make buttons in x and y positions. I do not know how to make buttons from scratch. A video will be helpful.
Dear ImGui does that. Have you tried playing around with the examples included with ImGui, or looked for resources? It's very easy to find help online, although I haven't found (or searched thoroughly) videos describing just that. Here's a little snipped of ImGui that renders a button over whatever you drew before:
ImGui::SetNextWindowPos(ImVec2(8, 8), ImGuiCond_FirstUseEver);
const bool did_show = ImGui::Begin("Invisible window##InvisibleWindow", NULL, ImVec2(160, 160), 1.0f, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
ImGui::Button("Hello!");
ImGui::End();
return did_show;
@SuperVGA Thanks soo much. But does Dear Imgui work with glut. If yes wonderful. And does Dear Imgui or glui allow me to place buttons in x and y positions. Thanks
Shaanveer said:
@SuperVGA Thanks soo much. But does Dear Imgui work with glut. If yes wonderful. And does Dear Imgui or glui allow me to place buttons in x and y positions. Thanks
I don't know if it works with glut. I changed from freeglut to glfw3 before adopting ImGui, but I do acknowledge that many resources still involve glut. I think you should take the above example and tinker with it a bit. From the looks of it, button does not take an offset in its ctor, but it's easy to place the button at an offset anyways, wrapping it in the right parent element. Just by looking at my example, don't you see an obvious way you could offset the button?