I am working a simple DLL plugin where I call glReadPixels
to return the pixels on the screen.When calling the function in the DLL, it failed to work with error 1282 (GL_INVALID_OPERATION)
.
I decided to run the code as a console EXE
program but the error is still there.
What am I doing wrong? I am using Windows 10 with Retina screen and my code is below:
int x2 = GetSystemMetrics(SM_CXSCREEN);
int y2 = GetSystemMetrics(SM_CYSCREEN);
GLvoid *imagePixelsArray = malloc((x2 *x2)*(y2* y2)*4);
glReadPixels(0, 0,x2,y2, GL_RGBA, GL_UNSIGNED_BYTE, imagePixelsArray);
cout << "ERROR is " << glGetError() << endl;
I did x2 *x2
and (y2* y2)
because I am using Retina screen. Removing that didn't solve the problem either.