isEmpty function?

is there any function in openGL like isEmpty in which we give a coordinate and it returns false if there is an object on that specific coordinate, or something equivalent?

thank you in advance

no

so, there is no way to check a certain coordinate, even indirectly?

Of course there is = glReadPixels.

Ok, so was thinking of a test if a 3D coordinate is inside of an object, V-man seems to have interpreted the question as if it’s possible to check if a 2D screen coordinate is covered by something rendered (for which glReadPixels is a valid solution as long as the clear color does not occur on rendered images or you test the z-values).

So what exactly do you want to test?

I want to test if a certain 3d coordinate is inside (or on the border) of an object

OpenGL, in general, will not help you with that. All OpenGL does is render objects. Actually, it doesn’t even do that; it renders triangles.

so, if I have a matrix that represents a board, there’s no way to check if a certain position is free or occupied? I ust know that beforehand and set the matrix myself?

Yeah. So it’s better to think of it transiently, once you’ve displayed information to openGL, you can’t get it back, nor should you. When you plot something, you should already know where it is. Sometimes it makes shortcuts like the one you describe more difficult, but that would require it to retain the model in 3D AFTER representing it on the screen, which would be ludicrously ineffecient.

ok, thank you very much for the help

so, if I have a matrix that represents a board, there’s no way to check if a certain position is free or occupied?

Why don’t you know if a position is free or occupied? You drew something in that position, yes? Therefore, you must know if it is free or occupied.

That is, if you are creating a board game, like chess, you need to keep track of free positions in your own data structures. It may very well be possible to get the result from OpenGL (read pixels, examine the depth buffer, use queries, etc), but it is not the recommended way to do it.

If you have a more complex scenario, with lots of piceses, then I would recommend that you use a quadtree or octree to detect collisions. This is also done outside of OpenGL.