Your vertex positions sizes don't match
Code :glVertexAttribPointer(vertexId, 2, GL_FLOAT, GL_FALSE, sizeof(vertices), 0)
size 2
Code :attribute vec4 vertex;
size 4
Your vertex positions sizes don't match
Code :glVertexAttribPointer(vertexId, 2, GL_FLOAT, GL_FALSE, sizeof(vertices), 0)
size 2
Code :attribute vec4 vertex;
size 4
I did not find any line in my code that binds the VBO to the shader program, is it possible that it's missing, or the code is complete and correct?
VBOs aren't bound to a shader. VBOs even need not be bound at all to source data from their data store. You can associate a vertex buffer object with an index in the range [0 .. GL_MAX_VERTEX_ATTRIBS] via glVertexAttribPointer (and other means with GL4.3, but since you're obviously on a lower version you shouldn't bother until you get a hold of the concept. You then bind that index to a corresponding location in your shader, either via glBindAttribLocation or, more preferably, via explicit assignment in the shader. For more details, please read this.that binds the VBO to the shader program
Also, I refer you to the corresponding wiki page.
Thanks for the reference.
The shape I rendered is merely what I wanted. Though, 1/4 of the circle is rendered. (I need to find where that comes from).
Now, let's say I need to change the value of colors in my program. I know that for this I need to use glMapBuffer() & glUnmapBuffer().
This code gives me a segmentation fault. Could you tell me the correct way of accessing and modifying the colors variable please.
Code :float* colors = (float *) glMapBuffer( GL_ARRAY_BUFFER, GL_WRITE_ONLY ); int k = segmentIndex * RANGE_COUNT * 6; for(int i = 0; i < RANGE_COUNT; ++i) { float rnd = ((rand() + segmentIndex) % 10000) / 10000.0f; colors[k++] = rnd; colors[k++] = rnd; colors[k++] = rnd; colors[k++] = rnd; colors[k++] = rnd; colors[k++] = rnd; } glUnmapBuffer( GL_ARRAY_BUFFER );
I want to copy only a specified portion everytime, so this way I think I should use the write() function as glMapBuffer() copies the whole buffer. could explain this to me with a sample please.
Last edited by saman_artorious; 07-01-2013 at 03:19 AM.