|
-
August 29th, 2008, 02:35 AM
#2
Re: Can i use <vector> arrays with "vertex arrays" of opengl?
Yes, you may use std::vector class in style like you use plain C buffers, but you have to keep some things in mind:
- to pass a buffer, you need to use following construct:
Code:
vector<float> vertexArray;
fillWithSomeData(vertexArray);
//use vertex list with example function (no idea if it is gl-correct :D )
glBufferDataARB( GL_ARRAY_BUFFER_ARB, vertexArray.size()*sizeof(float), &vertexArray[0], GL_STATIC_DRAW_ARB );
- function receiving buffer must not reallocate it (i.e. grow, move, etc), nor free it, but it may modify its content
- buffer pointer received this way becomes useless when vector grows, because it might be reallocated by internal mechanisms of vector class. The best way is to not store this address, just get it every time it is needed.
Cheers
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|