0
\$\begingroup\$

I'm making a minecraft style game and I decided to add a VBO with the texture atkas coordinates of the vertices but it is appearing all white. However I'm following the same process as another VBO for the block positions which works

the one that works

glBindBuffer(GL_ARRAY_BUFFER,chunk->posOffsetVBO);
glBufferData(GL_ARRAY_BUFFER,sizeof(glm::vec3)*65536,NULL,GL_DYNAMIC_DRAW);

glVertexAttribPointer(2,3,GL_FLOAT,GL_FALSE,3*sizeof(GLfloat),(GLvoid*)0);
glEnableVertexAttribArray(2);
glVertexAttribDivisor(2,1);

then I fill it with glm::vec3s like this

glBindBuffer(GL_ARRAY_BUFFER,adjacentChunks[1][1]->posOffsetVBO);

glBufferSubData(GL_ARRAY_BUFFER,0,sizeof(posOffsets),&posOffsets[0]);

this is the one with the texture coordinates that doesn't work

glBindBuffer(GL_ARRAY_BUFFER,chunk->texCoordVBO);
glBufferData(GL_ARRAY_BUFFER,sizeof(glm::vec2)*36*1000,NULL,GL_DYNAMIC_DRAW);

glVertexAttribPointer(1,2,GL_FLOAT,GL_FALSE,2*sizeof(GLfloat),(GLvoid*)0);
glEnableVertexAttribArray(1);

then fill It with 36 glm::vec2s for each block so one per vertex

glBindBuffer(GL_ARRAY_BUFFER,adjacentChunks[1][1]->texCoordVBO);

glBufferSubData(GL_ARRAY_BUFFER,0,sizeof(texCoords),&texCoords[0]);

Is there a reason why the texture one doesn't work?

\$\endgroup\$
  • \$\begingroup\$ Are you calling glGenBuffers to create the new buffer object? \$\endgroup\$ – Maximus Minimus Jan 4 '17 at 17:54
  • \$\begingroup\$ Yes I am at the top \$\endgroup\$ – Ben Beazley Jan 4 '17 at 19:06
  • \$\begingroup\$ I meant at the top \$\endgroup\$ – Ben Beazley Jan 4 '17 at 20:13
0
\$\begingroup\$

I feel stupid, after hours of trying to solve this problem I looked in the vertex shader for the umpteenth time and noticed that I was setting the output texture coordinate to itself. Now it works.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.