View Full Version : newbie needs help on VBOs
10-16-2006, 07:05 AM
I don't understand I do exactly as told in this tutorial:
But my program keeps crashing on
I'm sure it worked before. Can anyone tell me, what header to include and what not, and what needs to be done before this statement.
it worked yesterday on a nother project, I'm doing exactly the same, i'm getting mad!
10-16-2006, 09:53 AM
Did you tested if your graphic card supports this extension?
10-16-2006, 10:03 AM
Something else which throws people off is, you can't load extensions, even using WGL, until you've created and loaded an OpenGL context. More than likely, though, speed is right. There's no mention of using the extension string (glGetString(GL_EXTENSIONS)) to see if GL_ARB_vertex_buffer exists, nor is there even a simple check, like:
cout << "Vertex Buffers NOT supported!" << endl;
10-16-2006, 10:19 AM
Using that code snippet, I get the message VertexBuffer are NOT supported.
Bit weird, I have A NVIDIA Geforce 6800GT, and latest drivers installed..
NM, i fixed it, had to do with order of gl, glext and glew
10-16-2006, 10:15 PM
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, GL_STATIC_DRAW_ARB);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(colors), colors, GL_STATIC_DRAW_ARB);
glColorPointer(4, GL_FLOAT, 0, colors);
glVertexPointer(3, GL_FLOAT, 0, verts);
delete colors;Question, why can't I delete colors and verts, after sending them to the GPU?
10-16-2006, 10:28 PM
That code contains too many errors. Look at Nehe tutorial (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=45) or at example from the specification (http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt)
10-17-2006, 07:07 PM
Originally posted by Dylan:
Question, why can't I delete colors and verts, after sending them to the GPU? You need to bind (hook) the VBO before copying data. The order of VBO initialization looks like;
Notice that the last param of glColorPointer() and glVertexPointer() is now the starting offset in VBO, NOT actual memory addresses (pointers). Therefore, if vertex (or colour) data are stored at the beginning of VBO, then it would be 0.
If you want to have a single VBO to store both vertices and colours, the size of VBO would be sizeof(verts)+ sizeof(colors). In other way, you can create 2 VBOs to store vertices and colours separately.
Here is an example to store both vertice and colours in one VBO;
// create a VBO
// hook the created VBO
// reserve buffer space with NULL pointer
glBufferData(GL_ARRAY_BUFFER, sizeof(verts)+sizeof(colors), NULL, GL_STATIC_DRAW);
// first, copy vertex data with glBufferSubData()
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(verts), verts);
// second, copy colours (Notice the offset)
glBufferSubData(GL_ARRAY_BUFFER, sizeof(verts), sizeof(colors), colors);
// it is safe now to delete local arrays
delete  verts;
delete  colors;
...Take a look at VBO note (http://songho.ca/opengl/gl_vbo.html) .
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.