I want to retrieve the data from a storage buffer object. At first, I want to take advantage of glGetBufferSubData
. But it seems that this function does not exist in opengl es, though it does exist in opengl. Then I fall back on glMapBufferRange
.
It is perfect if I can interpret the information after retrieving the data from the buffer. But I think to do this I have to provide the exact layout, or even more information. For now, I do not need to do that much. What I want to do is that, under two different situations, I want to retrieve the buffer contents, and compare whether the contents are the same under the two situations.
The problem is, glMapBufferRange
returns a void *
type. I convert it to char *
and compare each char in hex value:
char *buffercontent = (char *)(glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 80, GL_MAP_READ_BIT)); //just read the first 80 characters. I'm sure the buffer data length is at least 80.
for(int i=0;i<20;i++)
{
printf("%X", *(buffercontent+i));
}
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
I feel confused because I can only see less that 20 characters printed out. Why? What is the problem? I'm sure the buffersize is large from other infomation.
Make sure that you multiply 80 (the size of array) by 8, seeing as OpenGL counts via array size * size of variable type in bytes (in this case, a single char).