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
55f91e77
authored
Sep 26, 2025
by
Diego Pérez Peña
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Ejercicio 4 terminado, falta documentación
parent
a3d3e2a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
Renderer.cpp
Renderer.h
pag03-fs.glsl
pag03-vs.glsl
Renderer.cpp
View file @
55f91e77
...
@@ -226,17 +226,45 @@ void PAG::Renderer::creaModelo() {
...
@@ -226,17 +226,45 @@ void PAG::Renderer::creaModelo() {
GLfloat
vertices
[]
=
{
-
.5
,
-
.5
,
0
,
GLfloat
vertices
[]
=
{
-
.5
,
-
.5
,
0
,
.5
,
-
.5
,
0
,
.5
,
-
.5
,
0
,
.0
,
.5
,
0
};
.0
,
.5
,
0
};
GLfloat
colores
[]
=
{
0.980392
,
0.341176
,
0.043137
,
0.721568
,
0.690196
,
0.647059
,
0.568627
,
0.898039
,
1.0
};
GLfloat
entrelazados
[]
=
{
-
0.5
,
-
0.5
,
0
,
0.980392
,
0.341176
,
0.043137
,
0.5
,
-
0.5
,
0
,
0.721568
,
0.690196
,
0.647059
,
0.0
,
0.5
,
0
,
0.568627
,
0.898039
,
1.0
};
GLuint
indices
[]
=
{
0
,
1
,
2
};
GLuint
indices
[]
=
{
0
,
1
,
2
};
glGenVertexArrays
(
1
,
&
idVAO
);
glGenVertexArrays
(
1
,
&
idVAO
);
glBindVertexArray
(
idVAO
);
glBindVertexArray
(
idVAO
);
// START NO ENTRELAZADO
/*
glGenBuffers(1, &idVBO);
glGenBuffers(1, &idVBO);
glBindBuffer(GL_ARRAY_BUFFER, idVBO);
glBindBuffer(GL_ARRAY_BUFFER, idVBO);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat), nullptr);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat), nullptr);
glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
glGenBuffers(1, &idColor);
glBindBuffer(GL_ARRAY_BUFFER, idColor);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat), nullptr);
glBufferData(GL_ARRAY_BUFFER, 9*sizeof(GLfloat), colores, GL_STATIC_DRAW);
*/
// END NO ENTRELAZADO
glGenBuffers
(
1
,
&
idVBO
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
idVBO
);
glEnableVertexAttribArray
(
0
);
glVertexAttribPointer
(
0
,
3
,
GL_FLOAT
,
GL_FALSE
,
6
*
sizeof
(
GLfloat
),
nullptr
);
glEnableVertexAttribArray
(
1
);
glVertexAttribPointer
(
1
,
3
,
GL_FLOAT
,
GL_FALSE
,
6
*
sizeof
(
GLfloat
),
(
GLvoid
*
)(
3
*
sizeof
(
float
)));
glBufferData
(
GL_ARRAY_BUFFER
,
18
*
sizeof
(
GLfloat
),
entrelazados
,
GL_STATIC_DRAW
);
glGenBuffers
(
1
,
&
idIBO
);
glGenBuffers
(
1
,
&
idIBO
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
idIBO
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
idIBO
);
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
3
*
sizeof
(
GLuint
),
indices
,
GL_STATIC_DRAW
);
glBufferData
(
GL_ELEMENT_ARRAY_BUFFER
,
3
*
sizeof
(
GLuint
),
indices
,
GL_STATIC_DRAW
);
...
...
Renderer.h
View file @
55f91e77
...
@@ -36,7 +36,8 @@ namespace PAG {
...
@@ -36,7 +36,8 @@ namespace PAG {
GLuint
idFS
=
0
;
// Identificador del Fragment Shader
GLuint
idFS
=
0
;
// Identificador del Fragment Shader
GLuint
idSP
=
0
;
// Identificador del Shader Program
GLuint
idSP
=
0
;
// Identificador del Shader Program
GLuint
idVAO
=
0
;
// Identificador del Vertex Array Object
GLuint
idVAO
=
0
;
// Identificador del Vertex Array Object
GLuint
idVBO
=
0
;
// Identificador del Vertex Buffer Object
GLuint
idVBO
=
0
;
// Identificador del Vertex Buffer Object (geometría si no entrelazada)
GLuint
idColor
=
0
;
// Idenfiticador del VBO de color (solo no entrelazada)
GLuint
idIBO
=
0
;
// Identificador del Index Buffer Object
GLuint
idIBO
=
0
;
// Identificador del Index Buffer Object
public
:
public
:
...
...
pag03-fs.glsl
View file @
55f91e77
#version 410
#version 410
out
vec4
colorFragmento
;
in
vec4
v_color
;
layout
(
location
=
0
)
out
vec4
colorFragmento
;
void
main
()
{
void
main
()
{
colorFragmento
=
v
ec4
(
1
.
0
,
.
4
,
.
2
,
1
.
0
)
;
colorFragmento
=
v
_color
;
}
}
pag03-vs.glsl
View file @
55f91e77
#version 410
#version 410
layout
(
location
=
0
)
in
vec3
posicion
;
layout
(
location
=
0
)
in
vec3
posicion
;
layout
(
location
=
1
)
in
vec3
color
;
out
vec4
v_color
;
void
main
()
{
void
main
()
{
v_color
=
vec4
(
color
,
1
.
0
);
gl_Position
=
vec4
(
posicion
,
1
);
gl_Position
=
vec4
(
posicion
,
1
);
}
}
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