Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
José Pardo Madera
/
pag_practicas_2025
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
2443606f
authored
Sep 11, 2025
by
José Pardo Madera
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Refinado el programa
parent
b71051cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
main.cpp
main.cpp
View file @
2443606f
...
...
@@ -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
);
...
...
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