Ok I drew a simple maze and what I am doing for collision to determine if you can move is use glReadPixels which I offset by the width of the square starting at the coordinates of the player which is passed to the function.
Here is the function should someone wish to help me out here.
GLfloat pixel[3];
bool CheckCollision(string Dir, float posX, float posY, float offset)
{
if (Dir == "Left")
{
glReadPixels((int)(posX - (offset * 2)), (int)(posY + offset), 2, 2, GL_RGB, GL_BYTE, &pixel);
if (pixel[0] == 255)
{
if (pixel[1] == 255)
{
if (pixel[2] == 255)
{
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return true;
}
} else if (Dir == "Right")
{
glReadPixels((int)(posX + (offset * 2)), (int)(posY + offset), 2, 2, GL_RGB, GL_BYTE, &pixel);
if (pixel[0] == 255)
{
if (pixel[1] == 255)
{
if (pixel[2] == 255)
{
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return true;
}
} else if (Dir == "Up")
{
glReadPixels((int)(posX + offset), (int)(posY + (offset * 2)), 2, 2, GL_RGB, GL_BYTE, &pixel);
if (pixel[0] == 255)
{
if (pixel[1] == 255)
{
if (pixel[2] == 255)
{
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return true;
}
} else if (Dir == "Down")
{
glReadPixels((int)(posX + offset), (int)(posY - (offset * 2)), 2, 2, GL_RGB, GL_BYTE, &pixel);
if (pixel[0] == 255)
{
if (pixel[1] == 255)
{
if (pixel[2] == 255)
{
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return true;
}
}
}
As you can tell I want the glReadPixels result to store to the variable pixels and be whatever format it requires to test the value for color. Walls are white so im testing for a white pixel as to that means they cant move that direction.