Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Diego Pérez Peña
/
PAG_p1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
058cdcb3
authored
Sep 25, 2025
by
Diego Pérez Peña
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Arregladas algunas fallas heredadas de la práctica 2
parent
000430f2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
38 deletions
CMakeLists.txt
LogWindow.cpp
conandata.yml
main.cpp
CMakeLists.txt
View file @
058cdcb3
...
...
@@ -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})
LogWindow.cpp
View file @
058cdcb3
...
...
@@ -35,6 +35,8 @@ void LogWindow::render() {
ImGui
::
SetWindowFontScale
(
1.0
f
);
// Escalamos el texto si fuera necesario
// Pintamos los controles
ImGui
::
TextWrapped
(
log
.
c_str
());
// Autoscroll hacia abajo
ImGui
::
SetScrollHereY
(
1.0
f
);
}
ImGui
::
End
();
}
...
...
conandata.yml
View file @
058cdcb3
...
...
@@ -4,3 +4,4 @@
requirements
:
-
"
glfw/3.3.8"
-
"
opengl/system"
-
"
glm/1.0.1"
\ No newline at end of file
main.cpp
View file @
058cdcb3
...
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment