Jump to content
  • Advertisement
Sign in to follow this  
DumitruSorin

VBO ?

This topic is 3885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I do this everything works fine:
glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[0]);
glVertexPointer(3, GL_FLOAT,0, &my_mesh.get()->vertex[0]);

glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[1]);
glNormalPointer(GL_FLOAT,0, &my_mesh.get()->normals[0]);

glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[2]);
glTexCoordPointer(2, GL_FLOAT,0, &my_mesh.get()->texcoords[0]);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, my_mesh->buffID[3]);
glDrawElements(GL_TRIANGLES, (GLsizei) my_mesh.get()->triangles.size(), GL_UNSIGNED_INT, &my_mesh->triangles[0]);

But when I try to use VBOs like this:
glGenBuffers(4,buffID);
//SENDING VERTEX DATA
glBindBuffer(GL_ARRAY_BUFFER,buffID[0]);		glBufferData(GL_ARRAY_BUFFER,sizeof(float)*vertex.size(),&vertex[0],GL_STATIC_DRAW);
//SENDING NORMAL DATA
glBindBuffer(GL_ARRAY_BUFFER,buffID[1]);		glBufferData(GL_ARRAY_BUFFER,sizeof(float)*normals.size(),&normals[0],GL_STATIC_DRAW);
//SENDING TEXCOORDS DATA
glBindBuffer(GL_ARRAY_BUFFER,buffID[2]);		glBufferData(GL_ARRAY_BUFFER,sizeof(float)*texcoords.size(),&texcoords[0],GL_STATIC_DRAW)
//SENDING INDEX DATA
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,buffID[3]);		glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(GLuint)*triangles.size(),&triangles[0],GL_STATIC_DRAW);
...
glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[0]);
glVertexPointer(3, GL_FLOAT,0, 0);

glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[1]);
glNormalPointer(GL_FLOAT,0, 0);

glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[2]);
glTexCoordPointer(2, GL_FLOAT,0, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, my_mesh->buffID[3]);
glDrawElements(GL_TRIANGLES, (GLsizei) my_mesh.get()->triangles.size(), GL_UNSIGNED_INT, 0);

my program terminates imediatly so it doesn't work. Am I doing something wrong?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by DumitruSorin

my program terminates imediatly so it doesn't work.
Am I doing something wrong?


It simply amazes me how many people make posts like this.
What have you done to find an error?
Checked the docs?
Tried a OpenGL call tracker (http://glintercept.nutty.org/ or http://www.gremedy.com)?
Tried to check for errors yourself using glGetError()?

http://www.catb.org/~esr/faqs/smart-questions.html

Quote:

Before You Ask

Before asking a technical question by e-mail, or in a newsgroup, or on a website chat board, do the following:

1.

Try to find an answer by searching the archives of the forum you plan to post to.
2.

Try to find an answer by searching the Web.
3.

Try to find an answer by reading the manual.
4.

Try to find an answer by reading a FAQ.
5.

Try to find an answer by inspection or experimentation.
6.

Try to find an answer by asking a skilled friend.
7.

If you're a programmer, try to find an answer by reading the source code.

When you ask your question, display the fact that you have done these things first; this will help establish that you're not being a lazy sponge and wasting people's time. Better yet, display what you have learned from doing these things. We like answering questions for people who have demonstrated they can learn from the answers.

Share this post


Link to post
Share on other sites
Quote:
Original post by dmail
Quote:
Original post by DumitruSorin

my program terminates imediatly so it doesn't work.
Am I doing something wrong?


It simply amazes me how many people make posts like this.
What have you done to find an error?
Checked the docs?
Tried a OpenGL call tracker (http://glintercept.nutty.org/ or http://www.gremedy.com)?
Tried to check for errors yourself using glGetError()?

http://www.catb.org/~esr/faqs/smart-questions.html

Quote:

Before You Ask

Before asking a technical question by e-mail, or in a newsgroup, or on a website chat board, do the following:

1.

Try to find an answer by searching the archives of the forum you plan to post to.
2.

Try to find an answer by searching the Web.
3.

Try to find an answer by reading the manual.
4.

Try to find an answer by reading a FAQ.
5.

Try to find an answer by inspection or experimentation.
6.

Try to find an answer by asking a skilled friend.
7.

If you're a programmer, try to find an answer by reading the source code.

When you ask your question, display the fact that you have done these things first; this will help establish that you're not being a lazy sponge and wasting people's time. Better yet, display what you have learned from doing these things. We like answering questions for people who have demonstrated they can learn from the answers.



maybe I tried that and havn't got an answer/

Share this post


Link to post
Share on other sites
Maybe you did maybe you did not, but how is anybody to know?
Quote:

When you ask your question, display the fact that you have done these things first; this will help establish that you're not being a lazy sponge and wasting people's time...

Share this post


Link to post
Share on other sites
You need to use gl{Enable,Disable}ClientState.

    void Geometry::DrawBuffers()
{
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, posBuffer);
glVertexPointer(3, GL_FLOAT, 0, 0);

glEnableClientState(GL_NORMAL_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, normalBuffer);
glNormalPointer(GL_FLOAT, 0, 0);

glEnableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glColorPointer(4, GL_FLOAT, 0, 0);

glClientActiveTexture(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, texcoordBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, 0);

glClientActiveTexture(GL_TEXTURE1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, tangentBuffer);
glTexCoordPointer(3, GL_FLOAT, 0, 0);

glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(VertexCount()));

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

Share this post


Link to post
Share on other sites
sorry for not giving any aditional information.

1. I did use glEnable/DisableClientState

2. glError says invalid enumerant here:

glBindBuffer(GL_ARRAY_BUFFER, my_mesh->buffID[0]);

though i don't see why it should say that because bufID[0] exist and buffID[2,3,4] works fine(it doesn't give any errors), so i'm thinking the problem is somewhere else

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!