# 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.

## Recommended Posts

bool MainWindow::Reshape( long width, long height )
{
m_Width  = width;
m_Height = height;
std::ostringstream temp;
temp << "{ width="  << width;
temp << ", height=" << height << " }";
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
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 on other sites
I think u need frustum culling:
http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg5.htm

##### 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 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 on other sites
You can find the equations you want in this thread.

Enigma

• 18
• 29
• 11
• 21
• 16