darron
1
I can draw pixels to RED, GREEN, BLUE and ALPHA partion by using:
GLubye buf[512][512];
glDrawBuffer(GL_FRONT);
glDrawPixels(512,512,GL_RED, GL_UNSIGNED_BYTE, buf)
But I encounter a segment fault when I tried to draw pixel to RGBA partion. The following is what my code look like:
GLuint buf[512][512];
glDrawBuffer(GL_FRONT);
glDrawPixels(512,512,GL_RGBA, GL_UNSIGNED_INT, buf)
What could be wrong here?
Please help! Thanks a lot
flo
2
Well, you need an int for each red, green, blue, and alpha value. So you must allocate four ints for each pixel, i.E.:
GLuint buf[512][512][4];
zen
3
That would be a 4sizeof(int)=432=128bit framebuffer.So a byte for each component should do.
GLubyte buf[512][512][4];
or
char buf[5125124]
flo
4
Yes, if the command to draw pixels is invoked with (darron used GL_UNSIGNED_INT):
glDrawPixels(512, 512, GL_RGBA, GL_UNSIGNED_BYTE, buf)
This makes more sense anyway, since the accuracy of unsigned int is overkill anyway, and will slow down rendering.
system
Closed
5
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.