Frame selection

Hi everyone,i have some trouble in frame selection, when i select the primitives in the frame. it just select the visible primitives, but the invisible primitives con’be selected. there is my code,any answer is well received.

byte[] pixels = new byte[(width * 3) * height];
gl.ReadBuffer(0x405);
gl.PixelStorei(0xd05, 1);
gl.ReadPixels(x, num3, width, height, 0x1907, 0x1401, pixels);
int num7 = -1;
int num8 = width * height;
for (int i = 0; i < num8; i++)
{
int index = i * 3;
int item = (pixels[index] + (pixels[index + 1] << 8)) + (pixels[index + 2] << 0x10);
if ((item < base.entities.Count) && (item != num7))
{
if (!list.Contains(item))
{
list.Add(item);
}
num7 = item;
}
}

it just select the visible primitives, but the invisible primitives con’be selected

How can you select something which is invisible? By invisible do you mean ‘was not even rendered’?

the invisible primitive means that it is blocked by the visible one.

You have to use your own ray-casting code for this, since any data about previously drawn primitives is lost once it has been overwritten. You could use glRenderMode(GL_SELECT) for what you want, but this has been dropped from core OpenGL and can be very slow.