Exposing normals to example framework.
This commit is contained in:
@ -56,7 +56,7 @@ void OpenGLWidget::initializeGL()
|
||||
if (!shader->addShaderFromSourceCode(QGLShader::Vertex, R"(
|
||||
#version 140
|
||||
|
||||
in vec4 position; //This will be the position of the vertex in model-space
|
||||
in vec4 position; // This will be the position of the vertex in model-space
|
||||
|
||||
uniform mat4 cameraToClipMatrix;
|
||||
uniform mat4 worldToCameraMatrix;
|
||||
@ -80,6 +80,7 @@ void OpenGLWidget::initializeGL()
|
||||
#version 130
|
||||
|
||||
in vec4 worldPosition; //Passed in from the vertex shader
|
||||
in vec4 worldNormal;
|
||||
|
||||
out vec4 outputColor;
|
||||
|
||||
@ -97,6 +98,7 @@ void OpenGLWidget::initializeGL()
|
||||
}
|
||||
|
||||
shader->bindAttributeLocation("position", 0);
|
||||
shader->bindAttributeLocation("normal", 1);
|
||||
|
||||
if (!shader->link())
|
||||
{
|
||||
|
@ -86,7 +86,10 @@ public:
|
||||
|
||||
//We need to tell OpenGL how to understand the format of the vertex data
|
||||
glEnableVertexAttribArray(0); //We're talking about shader attribute '0'
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(MeshType::VertexType), 0); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(MeshType::VertexType), (GLvoid*)(offsetof(MeshType::VertexType, position))); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
|
||||
|
||||
glEnableVertexAttribArray(1); //We're talking about shader attribute '1'
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(MeshType::VertexType), (GLvoid*)(offsetof(MeshType::VertexType, normal)));
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
Reference in New Issue
Block a user