Improved openGL and ImGUI implementation
This commit is contained in:
parent
645faf6546
commit
e746781494
2
.gitignore
vendored
2
.gitignore
vendored
@ -101,4 +101,4 @@ _deps
|
||||
CMakeUserPresets.json
|
||||
build
|
||||
.cache
|
||||
|
||||
test
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
const char FRAGMENT_SHADER_SOURCE[] = "./source/shader/fragment.glsl";
|
||||
const char VERTEX_SHADER_SOURCE[] = "./source/shader/vertex.glsl";
|
||||
|
||||
const char PROGRAM_NAME[] = "ImGui OpenGL Example";
|
||||
const char PROGRAM_NAME[] = "OpenGL Template";
|
||||
|
||||
const unsigned int SCR_WIDTH = 1920;
|
||||
const unsigned int SCR_HEIGHT = 1080;
|
||||
@ -97,12 +97,18 @@ static inline void init_imgui() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
#ifndef NDEBUG
|
||||
init_imgui();
|
||||
#endif
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
// Poll events
|
||||
glfwPollEvents();
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
// Start ImGui frame
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
@ -112,14 +118,17 @@ int main() {
|
||||
ImGui::Begin("Debug");
|
||||
ImGui::Text("FPS: %.1f", static_cast<double>(ImGui::GetIO().Framerate));
|
||||
ImGui::End();
|
||||
#endif
|
||||
|
||||
// Render
|
||||
glClearColor(0.03f, 0.03f, 0.03f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Render ImGui
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
#endif
|
||||
|
||||
// Swap buffers
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user