Pass tangents vector to shaders (Closes: #240)

pull/249/head
Hleb Valoshka 2019-03-21 23:57:02 +03:00
parent 5b57f13e0e
commit b95bdee04c
1 changed files with 14 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <GL/glew.h>
#include "vecgl.h"
#include "lodspheremesh.h"
#include "shadermanager.h"
using namespace std;
using namespace Eigen;
@ -338,6 +339,9 @@ void LODSphereMesh::render(unsigned int attributes,
glDisableClientState(GL_COLOR_ARRAY);
if ((attributes & Tangents) != 0)
glEnableVertexAttribArray(CelestiaGLProgram::TangentAttributeIndex);
if (split == 1)
{
renderSection(0, 0, thetaExtent, ri);
@ -402,6 +406,9 @@ void LODSphereMesh::render(unsigned int attributes,
if ((attributes & Normals) != 0)
glDisableClientState(GL_NORMAL_ARRAY);
if ((attributes & Tangents) != 0)
glDisableVertexAttribArray(CelestiaGLProgram::TangentAttributeIndex);
for (i = 0; i < nTextures; i++)
{
tex[i]->endUsage();
@ -643,6 +650,13 @@ void LODSphereMesh::renderSection(int phi0, int theta0, int extent,
glTexCoordPointer(2, GL_FLOAT, stride, vertexBase + (tc * 2) + texCoordOffset);
}
if ((ri.attributes & Tangents) != 0)
{
glVertexAttribPointer(CelestiaGLProgram::TangentAttributeIndex,
3, GL_FLOAT, GL_FALSE,
stride, vertexBase + 3); // 3 == tangentOffset
}
// assert(ri.step >= minStep);
// assert(phi0 + extent <= maxDivisions);
// assert(theta0 + extent / 2 < maxDivisions);