• Create Account

### #Actualk.pedersen

Posted 12 April 2012 - 10:28 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);



Also... I see another issue.
glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));


should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

That is also why it is displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

http://www.opengl.or...lDrawArrays.xml
(cant remember the exact code myself, but let me know if you have any issues)

### #6k.pedersen

Posted 12 April 2012 - 10:21 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);



In your shader, are you using attribute values or inbuilt gl_Vertex, because if so, be aware that afaik glVertexAttribPointer is deprecated.

Also... I see another issue.
glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));


should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

That is also why it is displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

http://www.opengl.or...lDrawArrays.xml
(cant remember the exact code myself, but let me know if you have any issues)

### #5k.pedersen

Posted 12 April 2012 - 10:21 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);



In your shader, are you using attribute values or inbuilt gl_Vertex, because if so, be aware that afaik glVertexAttribPointer is deprecated.

Also... I see another issue.
glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));


should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

That is also why it is displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

http://www.opengl.or...lDrawArrays.xml
(cant remember the exact code myself, but let me know if you have any issues)

### #4k.pedersen

Posted 12 April 2012 - 10:20 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);



In your shader, are you using attribute values or inbuilt gl_Vertex, because if so, be aware that afaik glVertexAttribPointer is deprecated.

Also... I see another issue.
glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));


should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

Also that is why it may be displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

http://www.opengl.or...lDrawArrays.xml
(cant remember the exact code myself, but let me know if you have any issues)

### #3k.pedersen

Posted 12 April 2012 - 10:18 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);



Also... I see another issue.
glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));


should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

Also that is why it may be displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

http://www.opengl.or...lDrawArrays.xml
(cant remember the exact code myself, but let me know if you have any issues)

### #2k.pedersen

Posted 12 April 2012 - 10:18 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);



Ok, next issue I see.

glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));

should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

Also that is why it may be displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

http://www.opengl.or...lDrawArrays.xml
(cant remember the exact code myself, but let me know if you have any issues)

PARTNERS