To keep it short: As we all know, opengl draws many triangles on the screen.
What I want to know:
If opengl draws triangles, it has to know, which triangle belongs to which pixel on the screen, right?
Can I get this information too? For example call a function after a draw (like gl_retrieve_object_map()
or anything similar) where I get to know which pixel shows which triangle?
its like doing picking for every pixel
I am thinking of an 2 dimensional array telling me the triangle index or whatever:
on a 10x10 pixel screen for example:
0 0 1 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 2 0
0 0 0 0 1 1 1 2 2 0
0 0 0 0 0 1 1 2 2 0
0 0 0 0 0 2 1 2 2 0
0 0 0 0 2 2 2 2 2 0
0 0 0 2 2 2 2 2 2 0
0 0 2 2 2 2 2 2 2 0
0 2 2 2 2 2 2 2 2 0
0 0 0 0 0 0 0 0 0 0
for an image like:
___
\ |
\ |
\|/|
/ |
/ |
/ |
/____|
is there anything that i could use?
OpenGL actually doesn’t have this information after something is drawn. OpenGL has a few buffers, including (among others) the color buffer and depth buffer, but it does not have a buffer that holds an index for each primitive drawn.
But that doesn’t mean you’re out of luck. One thing I have seen applications do is remove all lighting effects and give each object a unique color. Then, it renders the scene to an off-screen buffer. Then that off-screen buffer has exactly the information you want.