Jump to content
  • Advertisement
Sign in to follow this  
jgdo

Find out if a point is rendered onto screen while rendering

This topic is 2533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

currently I'm rendering a point cloud by calling glVertex3f(p.x, p.y, p.z); on each point p inside a glBegin(GL_POINTS) block.

Now i need to compute the average projected z window coordinate of all visible points. I know that I can use gluProject() to find out window coordinates and sum them up, but if I do that, the window coordinates will be calculated twice per pixel: 1x in gluProject() and of course 1x in glVertex3f() itself, because to render a point it should be known where to render it on screen.

Is there a way to retrieve the window coordinates from glVertex3f() directly without calling gluProject() ?

- jgdo -

Share this post


Link to post
Share on other sites
Advertisement
Yes, it is called transform feedback. It writes transformed values to a VBO.

http://www.opengl.org/registry/specs/EXT/transform_feedback.txt
http://www.opengl.org/registry/specs/ARB/transform_feedback2.txt
http://www.opengl.org/registry/specs/ARB/transform_feedback3.txt

Share this post


Link to post
Share on other sites
Transform Feedback would work, but it's probably faster and easier to do this completely on the CPU.

Share this post


Link to post
Share on other sites
Perhaps. The only way to be sure is to do a live benchmark and select different paths in your program.

If you find gluProject slow, try my library. It has SSE version of the same function for mass data processing.

Share this post


Link to post
Share on other sites
Your cloud's bounds and centre (the cheapest kind of average, and likely works for your purposes) can all be computed in the cloud's relative coordinates and then that single point can be projected.

> currently I'm rendering a point cloud by calling glVertex3f(p.x, p.y, p.z); on each point p inside a glBegin(GL_POINTS) block.

Is likely your next target for optimisation ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!