Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Dimensions of the opengl world space.

This topic is 5395 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
   ::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
   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
Guest Anonymous Poster
I think u need frustum culling:

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.

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!