Stack Overflow Error when using glReadPixel

87 views Asked by At

I'm building a Tetris clone for a university project and I'm running into a slight issue. The way I'm checking if a brick can move into an area is that I check the area it's supposed to be moving into and see if the colour of that is black (The background colour), if it is black then the brick is moved there.

To check the colour I'm using the following code :

        for (int i = 0; i < 4; i++)
    {
        unsigned char pixel[4];
        glReadPixels(x[ShapeXC[i]], y[ShapeYC[i]], 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
        if (((int)pixel[0] == 0) && ((int)pixel[1] == 0) && ((int)pixel[2] == 0))
            temp[i] = 1;
    }

Temp[i] is a boolean check for every brick location. ShapeXC and ShapeYC are a new co-ordinate system I've established which basically contains a multiple of 60, when you put ShapeXC and ShapeYC of a brick together then you get the bottom-right x/y co-ordinates of a brick.

I hope this is enough information, the exact error was : Unhandled exception at 0x697DF6A7 (atioglxx.dll) in bSlayer.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00FF2000).

If more of my code or so is needed please let me know and I can provide the entire file.

For reference, I adapted my code from How to get color from the pixel? OpenGL

0

There are 0 answers