Refinado el programa

parent b71051cb
Showing with 48 additions and 0 deletions
......@@ -12,9 +12,50 @@
exit(-1);\
}
// Callback cuando ocurre un error en GLFW
void error_callback(int errno, const char *desc) {
std::cout << "GLFW error " << errno << ": " << desc << std::endl;
}
void window_refresh_callback(GLFWwindow *window) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwSwapBuffers(window);
std::cout << "Refresh callback called" << std::endl;
}
void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
glViewport(0, 0, width, height);
std::cout << "Resize callback called. New size: " << width << ", " << height << std::endl;
}
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
std::cout << "Key callback called" << std::endl;
}
void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) {
if (action == GLFW_PRESS) {
std::cout << "Pulsado el botón: mouse " << button << std::endl;
} else if (action == GLFW_RELEASE) {
std::cout << "Soltado el botón: mouse " << button << std::endl;
}
}
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) {
std::cout << "Movida la rueda del raton "
<< xoffset << " unidades en horizontal y "
<< yoffset << " unidades en vertical" << std::endl;
}
int main() {
std::cout << "Starting Application PAG - Prueba 01" << std::endl;
glfwSetErrorCallback((GLFWerrorfun) error_callback);
if (glfwInit() != GLFW_TRUE) {
panic("Failed to initialize GLFW");
}
......@@ -45,6 +86,13 @@ int main() {
std::cout << glGetString(GL_VERSION) << std::endl;
std::cout << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
glfwSetWindowRefreshCallback(window, window_refresh_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glfwSetMouseButtonCallback(window, mouse_button_callback);
glfwSetScrollCallback(window, scroll_callback);
glClearColor(0.6, 0.6, 0.6, 1.0);
glEnable(GL_DEPTH_TEST);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment