Arregladas algunas fallas heredadas de la práctica 2

parent 000430f2
...@@ -13,20 +13,24 @@ target_include_directories(PAG_p1 PUBLIC glad/include imgui/include ) ...@@ -13,20 +13,24 @@ target_include_directories(PAG_p1 PUBLIC glad/include imgui/include )
# Uncomment the following when using Conan, comment (# at line start) otherwise # Uncomment the following when using Conan, comment (# at line start) otherwise
#find_package(opengl_system) find_package(opengl_system)
#find_package(glfw3) find_package(glfw3)
find_package(glm)
#target_link_libraries(PAG_p1 opengl::opengl) # Then, link your executable or library with the corresponding package targets:
#target_link_libraries(PAG_p1 glfw)
target_link_libraries(PAG_p1 opengl::opengl)
target_link_libraries(PAG_p1 glfw)
target_link_libraries(PAG_p1 glm::glm)
#=========================================== #===========================================
# Uncomment the following when using Linux, comment (# at line start) otherwise # Uncomment the following when using Linux, comment (# at line start) otherwise
find_package(glfw3 3.3 REQUIRED) #find_package(glfw3 3.3 REQUIRED)
find_package(OpenGL REQUIRED) #find_package(OpenGL REQUIRED)
target_include_directories(PAG_p1 PUBLIC #target_include_directories(PAG_p1 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> # $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:include>) # $<INSTALL_INTERFACE:include>)
target_link_libraries(PAG_p1 PUBLIC glfw OpenGL::GL ${CMAKE_DL_LIBS}) #target_link_libraries(PAG_p1 PUBLIC glfw OpenGL::GL ${CMAKE_DL_LIBS})
...@@ -35,6 +35,8 @@ void LogWindow::render() { ...@@ -35,6 +35,8 @@ void LogWindow::render() {
ImGui::SetWindowFontScale ( 1.0f ); // Escalamos el texto si fuera necesario ImGui::SetWindowFontScale ( 1.0f ); // Escalamos el texto si fuera necesario
// Pintamos los controles // Pintamos los controles
ImGui::TextWrapped(log.c_str()); ImGui::TextWrapped(log.c_str());
// Autoscroll hacia abajo
ImGui::SetScrollHereY(1.0f);
} }
ImGui::End(); ImGui::End();
} }
......
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
requirements: requirements:
- "glfw/3.3.8" - "glfw/3.3.8"
- "opengl/system" - "opengl/system"
- "glm/1.0.1"
\ No newline at end of file
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
void error_callback(int errno, const char* desc) { void error_callback(int errno, const char* desc) {
std::string aux = std::string(); std::string aux = std::string();
aux.append("Error de GLFW número ").append(std::to_string(errno)).append(desc); aux.append("Error de GLFW número ").append(std::to_string(errno)).append(desc);
std::cout << aux << std::endl;
PAG::GUI::getInstancia().registrarMensaje(aux); PAG::GUI::getInstancia().registrarMensaje(aux);
} }
...@@ -17,17 +16,12 @@ void error_callback(int errno, const char* desc) { ...@@ -17,17 +16,12 @@ void error_callback(int errno, const char* desc) {
void refresh_window_callback(GLFWwindow *window) { void refresh_window_callback(GLFWwindow *window) {
// Llamada al mét0do refrescar del Renderer // Llamada al mét0do refrescar del Renderer
PAG::Renderer::getInstancia().refrescar(); PAG::Renderer::getInstancia().refrescar();
std::cout << "Refresh callback called" << std::endl;
PAG::GUI::getInstancia().registrarMensaje("Refresh callback called");
} }
// - Esta función callback será llamada cada vez que se cambie el tamaño // - Esta función callback será llamada cada vez que se cambie el tamaño
// del área de dibujo OpenGL. // del área de dibujo OpenGL.
void framebuffer_size_callback(GLFWwindow *window, int width, int height) { void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
PAG::Renderer::getInstancia().refrescar_tamanio_framebuffer(width, height); PAG::Renderer::getInstancia().refrescar_tamanio_framebuffer(width, height);
std::cout << "Resize callback called" << std::endl;
PAG::GUI::getInstancia().registrarMensaje("Resize callback called");
} }
// - Esta función callback será llamada cada vez que se pulse una tecla // - Esta función callback será llamada cada vez que se pulse una tecla
...@@ -36,25 +30,15 @@ void key_callback(GLFWwindow *window, int key, int scancode, int action, int mod ...@@ -36,25 +30,15 @@ void key_callback(GLFWwindow *window, int key, int scancode, int action, int mod
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GLFW_TRUE); glfwSetWindowShouldClose(window, GLFW_TRUE);
} }
std::cout << "Key callback called" << std::endl;
PAG::GUI::getInstancia().registrarMensaje("Key callback called");
} }
// - Esta función callback será llamada cada vez que se pulse algún botón // - Esta función callback será llamada cada vez que se pulse algún botón
// del ratón sobre el área de dibujo OpenGL. // del ratón sobre el área de dibujo OpenGL.
void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) { void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) {
if (action == GLFW_PRESS) { if (action == GLFW_PRESS) {
std::string aux = std::string();
aux.append("Pulsado el botón ").append(std::to_string(button));
std::cout << aux << std::endl;
PAG::GUI::getInstancia().registrarMensaje(aux);
PAG::GUI::getInstancia().callback_raton(button, true); PAG::GUI::getInstancia().callback_raton(button, true);
} }
else if (action == GLFW_RELEASE) { else if (action == GLFW_RELEASE) {
std::string aux = std::string();
aux.append("Soltado el botón ").append(std::to_string(button));
std::cout << aux << std::endl;
PAG::GUI::getInstancia().registrarMensaje(aux);
PAG::GUI::getInstancia().callback_raton(button, false); PAG::GUI::getInstancia().callback_raton(button, false);
} }
refresh_window_callback(window); refresh_window_callback(window);
...@@ -64,14 +48,6 @@ void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) ...@@ -64,14 +48,6 @@ void mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
// del ratón sobre el área de dibujo OpenGL. // del ratón sobre el área de dibujo OpenGL.
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) { void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) {
refresh_window_callback(window); refresh_window_callback(window);
std::string aux = std::string();
aux.append("Movida la rueda del ratón ").append(std::to_string(xoffset))
.append(" unidades en horizontal y ").append(std::to_string(yoffset))
.append(" unidades en vertical.");
std::cout << aux << std::endl;
PAG::GUI::getInstancia().registrarMensaje(aux);
} }
int main() { int main() {
...@@ -149,15 +125,16 @@ int main() { ...@@ -149,15 +125,16 @@ int main() {
// ventana principal deba cerrarse. Por ejemplo, si el usuario pulsa el // ventana principal deba cerrarse. Por ejemplo, si el usuario pulsa el
// botón de cerrar la ventana (la X). // botón de cerrar la ventana (la X).
while (!glfwWindowShouldClose(window)) { while (!glfwWindowShouldClose(window)) {
PAG::GUI::getInstancia().prepararNuevoFrame();
// Renderizado de figuras OpenGL
refresh_window_callback(window);
PAG::GUI::getInstancia().renderizarNuevoFrame();
// - GLFW usa un doble buffer para que no haya parpadeo. Esta orden // - GLFW usa un doble buffer para que no haya parpadeo. Esta orden
// intercambia el buffer back (en el que se ha estado dibujando) por el // intercambia el buffer back (en el que se ha estado dibujando) por el
// que se mostraba hasta ahora (front). // que se mostraba hasta ahora (front).
glfwSwapBuffers(window); glfwSwapBuffers(window);
PAG::GUI::getInstancia().prepararNuevoFrame();
// Renderizado de figuras OpenGL
PAG::GUI::getInstancia().renderizarNuevoFrame();
// - Obtiene y organiza los eventos pendientes, tales como pulsaciones de // - Obtiene y organiza los eventos pendientes, tales como pulsaciones de
// teclas o de ratón, etc. Siempre al final de cada iteración del ciclo // teclas o de ratón, etc. Siempre al final de cada iteración del ciclo
// de eventos y después de glfwSwapBuffers(window); // de eventos y después de glfwSwapBuffers(window);
......
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