Ejercicio 4 terminado, falta documentación

parent a3d3e2a2
...@@ -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);
......
...@@ -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:
......
#version 410 #version 410
out vec4 colorFragmento;
in vec4 v_color;
layout (location = 0) out vec4 colorFragmento;
void main() { void main() {
colorFragmento = vec4 ( 1.0, .4, .2, 1.0 ); colorFragmento = v_color;
} }
#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 );
} }
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