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 )
# Uncomment the following when using Conan, comment (# at line start) otherwise
#find_package(opengl_system)
#find_package(glfw3)
find_package(opengl_system)
find_package(glfw3)
find_package(glm)
#target_link_libraries(PAG_p1 opengl::opengl)
#target_link_libraries(PAG_p1 glfw)
# Then, link your executable or library with the corresponding package targets:
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
find_package(glfw3 3.3 REQUIRED)
find_package(OpenGL REQUIRED)
#find_package(glfw3 3.3 REQUIRED)
#find_package(OpenGL REQUIRED)
target_include_directories(PAG_p1 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(PAG_p1 PUBLIC glfw OpenGL::GL ${CMAKE_DL_LIBS})
#target_include_directories(PAG_p1 PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
# $<INSTALL_INTERFACE:include>)
#target_link_libraries(PAG_p1 PUBLIC glfw OpenGL::GL ${CMAKE_DL_LIBS})
......@@ -35,6 +35,8 @@ void LogWindow::render() {
ImGui::SetWindowFontScale ( 1.0f ); // Escalamos el texto si fuera necesario
// Pintamos los controles
ImGui::TextWrapped(log.c_str());
// Autoscroll hacia abajo
ImGui::SetScrollHereY(1.0f);
}
ImGui::End();
}
......
......@@ -4,3 +4,4 @@
requirements:
- "glfw/3.3.8"
- "opengl/system"
- "glm/1.0.1"
\ No newline at end of file
......@@ -8,7 +8,6 @@
void error_callback(int errno, const char* desc) {
std::string aux = std::string();
aux.append("Error de GLFW número ").append(std::to_string(errno)).append(desc);
std::cout << aux << std::endl;
PAG::GUI::getInstancia().registrarMensaje(aux);
}
......@@ -17,17 +16,12 @@ void error_callback(int errno, const char* desc) {
void refresh_window_callback(GLFWwindow *window) {
// Llamada al mét0do refrescar del Renderer
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
// del área de dibujo OpenGL.
void framebuffer_size_callback(GLFWwindow *window, int width, int 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
......@@ -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) {
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
// del ratón sobre el área de dibujo OpenGL.
void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) {
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);
}
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);
}
refresh_window_callback(window);
......@@ -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.
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) {
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() {
......@@ -149,15 +125,16 @@ int main() {
// ventana principal deba cerrarse. Por ejemplo, si el usuario pulsa el
// botón de cerrar la ventana (la X).
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
// intercambia el buffer back (en el que se ha estado dibujando) por el
// que se mostraba hasta ahora (front).
glfwSwapBuffers(window);
PAG::GUI::getInstancia().prepararNuevoFrame();
// Renderizado de figuras OpenGL
PAG::GUI::getInstancia().renderizarNuevoFrame();
// - 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
// 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