Jump to content
  • Advertisement
Sign in to follow this  
TreveonMaxwell

Object to Screen Coordinates

This topic is 2644 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 Forum.

Here is the function I'm using in my Entity class that should get the object's screen coordinates.

[source='cpp'] void CEntity::GetScreenCoord() { glGetDoublev( GL_MODELVIEW, modelview ); glGetDoublev( GL_PROJECTION, projection ); glGetIntegerv( GL_VIEWPORT, viewport ); gluProject( (GLdouble)Position.x,(GLdouble)Position.y, (GLdouble)Position.z, modelview, projection, viewport, WindowPosX, WindowPosY, WindowPosZ ); }[/source]

Now for a while when I attempted this, my program would compile and immediately crash with an unhandled exception that I thought I fixed, but now when I compile, it runs yet I have the Entity objects world position and screen position displayed with cout in the console window. No matter where the object moves, his world position is updated, but his screen position always remains 0, 0, 0. The modelview, projection, and viewport arrays have been been externed in another file, not sure if that matters. What am I doing wrong?

I'm working on a Quadtree class and I need to get an object's screen position to pass it to the Octree, in case you are wondering why I need this info. Quadtree is coming along nicely but this is the most important step and I can't figure it out. Been working on this for a few weeks now. I need the window position in pixels not in normals. Thanks for reading.

Share this post


Link to post
Share on other sites
Advertisement
We need to see more context, preferably in terms of code. Can you strip this down to a minimal example that reproduces the problem, and post that?

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!