mirror of
https://github.com/brammie15/VoxelRenderer.git
synced 2025-12-16 18:01:49 +01:00
46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
// Local headers
|
|
#include "program.hpp"
|
|
#include "gloom/gloom.hpp"
|
|
|
|
|
|
void runProgram(GLFWwindow* window)
|
|
{
|
|
// Enable depth (Z) buffer (accept "closest" fragment)
|
|
glEnable(GL_DEPTH_TEST);
|
|
glDepthFunc(GL_LESS);
|
|
|
|
// Configure miscellaneous OpenGL settings
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
// Set default colour after clearing the colour buffer
|
|
glClearColor(0.3f, 0.5f, 0.8f, 1.0f);
|
|
|
|
// Set up your scene here (create Vertex Array Objects, etc.)
|
|
|
|
// Rendering Loop
|
|
while (!glfwWindowShouldClose(window))
|
|
{
|
|
// Clear colour and depth buffers
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
// Draw your scene here
|
|
|
|
// Handle other events
|
|
glfwPollEvents();
|
|
handleKeyboardInput(window);
|
|
|
|
// Flip buffers
|
|
glfwSwapBuffers(window);
|
|
}
|
|
}
|
|
|
|
|
|
void handleKeyboardInput(GLFWwindow* window)
|
|
{
|
|
// Use escape key for terminating the GLFW window
|
|
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
|
{
|
|
glfwSetWindowShouldClose(window, GL_TRUE);
|
|
}
|
|
}
|