I have initialized glewInit( ) and any other openGL stuff. all before i do any of these calls.
glGenBuffers( 1, &m_uiVertBufferHandle );
glBindBuffer( GL_ARRAY_BUFFER, m_uiVertBufferHandle );
glBufferData( GL_ARRAY_BUFFER, 0, 0, GL_READ_WRITE );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
this is how i create my buffer object i i did the glBufferData because i have read in openGL articles that you do not have any storage space at all if you do not call it at least once which would make glMapBuffer always give you 0x00000000.
later on i call glMapBuffer to get my storage location to start saving data when i use glMapBuffer i call it like this
void* buffer1;
glBindBuffer( GL_ARRAY_BUFFER, m_uiVertBufferHandle );
//make sure our buffer excists
buffer1 = glMapBuffer( GL_ARRAY_BUFFER, GL_READ_WRITE );
i always get 0x00000000 in my buffer1. Why is this? the only 2 causes i have found at all were that i didn't initialize glewInit properly which i have done and that i wasnt calling glBindBufferData at least once.
glBufferData( GL_ARRAY_BUFFER, 0, 0, GL_READ_WRITE );
GL_READ_WRITE
is not a valid usage for buffer objects. You use that for mapping, not the buffer object's usage. Usage parameters are stuff like GL_STATIC_DRAW
, or more reasonably for your "read/write" case, GL_DYNAMIC_READ
.
Because you passed an invalid enum, OpenGL gave you a GL_INVALID_ENUM
error and failed to execute this command. Also, 0 length buffer object is not a reasonable size for the buffer's storage. Try new int[0]
or malloc(0)
sometime and see what happens.
Please stop allocating miniscule or non-existent sizes of data. Allocate 4096 bytes or something if you really want to test this.