after searching this forum I still get stuck with this:
I want to test if a small object is visible in the window, as I want to put some 2D marker over it when it is. Say for instance several satellites orbiting a planet. The marker shouldn't be drawn when a satellite is behind the planet.
My first idea was to render all meshes, then calculate the 2D coordinates of the satellite and do a collision check on these coordinates with GetRayFromScreenCoordinates and GetCollisionPoint. This works, but the collision checking is far too slow, as I use very high resolution models (500k triangles) and have to check for every satellite. So my framerate drops drastically.
Fortunately, I thought of a faster solution: If I draw my satellite in a specific colour, I could check its visibility by simply checking the pixel colour at its 2D coordinates. So, I first render all meshes, then want to check some pixel values and then draw some 2D stuff on them.
There are a few problems with this, however:
1. When I render all meshes, I could use an endScene(), so everything is drawn to a window. And then I can use GetPixel on the device context to get the pixelvalues to see what markers have to be drawn and do another beginscene-endscene (without erasing the background) to add the 2d stuff to the screen. But this will lead to flickering of the 2D markers, as also an image without them is presented.
2. When I just use one begin-endscene, the pixelvalues of the previous render are taken. But if a marker has been drawn over my satellite, the pixelvalue has changed, so in the next render the marker won't be drawn. So this will also give flickering.
3. The best solution I can come up with now, is to draw all 3d objects, then do the getPixels on the backbuffer, and finally draw the 2D stuff. This should work, but I have no idea how to do a getpixel on the backbuffer.
And (finally
Any help greatly appreciated...