Reputation: 185
I am trying to use glReadPixels() to read a window of 5 * 5 pixels. Here is the code.
const unsigned int WINDOW_SIZE = 5;
const unsigned int NB_COMPONENTS = 3;
GLubyte array[NB_COMPONENTS * WINDOW_SIZE * WINDOW_SIZE];
glReadPixels( 0, 0, WINDOW_SIZE, WINDOW_SIZE, GL_RGB, GL_UNSIGNED_BYTE, array);
Yet this code causes the following error in visual studio: "Stack around variable array was corrupted"
If I add +4 to the size of the array it works fine. Does someone knows why?
Upvotes: 1
Views: 291
Reputation: 52167
Since you're using GL_RGB
make sure GL_PACK_ALIGNMENT
is set to 1
.
Upvotes: 1