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\$
3
  • \$\begingroup\$ Are you calling glGenBuffers to create the new buffer object? \$\endgroup\$ Jan 4, 2017 at 17:54
  • \$\begingroup\$ Yes I am at the top \$\endgroup\$ Jan 4, 2017 at 19:06
  • \$\begingroup\$ I meant at the top \$\endgroup\$ Jan 4, 2017 at 20:13

1 Answer 1

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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .