Jump to content
  • Advertisement
Sign in to follow this  
try_catch_this

OpenGL Dimensions of the opengl world space.

This topic is 5030 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

bool MainWindow::Reshape( long width, long height )
{
   m_Width  = width;
   m_Height = height;
   std::ostringstream temp;
   temp << "{ width="  << width;
   temp << ", height=" << height << " }";
   m_Console.AddLine( temp.str() );
   if( height < 1 ) // Prevent A Divide By Zero By
      height=1;
   ::glViewport( 0, 0, (GLsizei)(width), (GLsizei)(height) );
   ::glMatrixMode( GL_PROJECTION );
   ::glLoadIdentity();                                                  // Reset The Projection Matrix
   ::gluPerspective( m_FieldOfView, (GLfloat)(width)/(GLfloat)(height), // Calculate The Aspect Ratio Of The Window
                     0.010f, 1000.0f );
   ::glMatrixMode( GL_MODELVIEW );                                      // Select The Modelview Matrix
   ::glLoadIdentity();
   return false;
}

This is my reshape function. Given that I use this to setup a perspective vied how can I determine if I draw a particular primative at a given coordinate if it will be on the screen or not? If you need anymore information I will provide it. But I need a way to calculate if an object will be on the screen if I try to renderit at a particular point. {0,0-40} is on the screen but will be {-40,0,-40} on the screen? thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I think u need frustum culling:
http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg5.htm

Share this post


Link to post
Share on other sites


I need to do a calculation that will allow me to stick some numbers in a function and then find out where would the top left coordinate be in open gl coordinates.

If I give it the values I sent to gluperspective and a value for z then I should beable to calculate the dimensions and coordinates of the slice of the pyramid.

Share this post


Link to post
Share on other sites
Look at the tutorial that the AP gave you a link to. It will tell you how to determine if a sphere or cube is in the frustum, and it's easy enough to make it work for polys.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!