Jump to content
  • Advertisement
Sign in to follow this  
icecubeflower

clipping plane glOrtho

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

Why is the planet still drawn in this example? (planet is drawn in last block of code, glOrtho is called near the beginning.):
void FPSDemo::drawSpace()
{
  mRotation+= mDeltaTime / 2000;

  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  glOrtho(0.0f, mWidth, mHeight, 0.0f, 1.0f, 0.0f);
  glEnable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, mStarsTexture);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  glColor3f(1.0f,1.0f,1.0f);
  glBegin(GL_QUADS);
    glTexCoord2f(1.0f, 0.0f);    glVertex3f(mWidth,0.0f,0.0f);
    glTexCoord2f(0.0f, 0.0f);    glVertex3f(0.0f,0.0f,0.0f);
    glTexCoord2f(0.0f, 1.0f);    glVertex3f(0.0f,mHeight,0.0f);
    glTexCoord2f(1.0f, 1.0f);    glVertex3f(mWidth,mHeight,0.0f);
  glEnd();

  glPopMatrix();

  glMatrixMode(GL_MODELVIEW);

  glPushMatrix();
  glTranslatef(0.0,0.0,-5.0);
  glRotatef(90,0.0, 1.0, 0.0);
  glRotatef(mRotation*39,0.0, 1.0, 0.0);
  glRotatef(90,1.0, 0.0, 0.0);
  glEnable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, mPlanetTexture);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  gluSphere(mQuad1, 1.0, 60, 60);
  glDisable(GL_TEXTURE_2D);
  glPopMatrix();
}


The clipping planes are from 1.0 to 0.0 in glOrtho. The planet is drawn at 5.0, that's 4.0 past the near clipping plane. (Or taking the radius into account the near side of the planet ranges from 4.0 to 3.0 past the near clipping plane.) Right? And why is the planet warped to whatever aspect ratio my window is using? Why isn't it a sphere?

Share this post


Link to post
Share on other sites
Advertisement
What values do mWidth and mHeight contain?

If they contain the same value you'll render the planet to a square region and would be distorted if that region is mapped to a non-square render target.


Where is your camera located?

Note that the projection matrix is applied to objects in eye space (i.e. relative to the "camera"), so if your planet is located at (0,0,5) and your camera is located at (0,0,4) the distance to the camera is 1.0.

Share this post


Link to post
Share on other sites
Camera is at 0,0,0. Nevermind glOrtho, I don't know what I was talking about. All I'm worried about now is the warped planet. mWidth is 1024 and mHeight is 768. I don't see why the planet is egg shaped.

Share this post


Link to post
Share on other sites
Oh in gluPerspective I was doing mWidth/mHeight but that was integer division. Duh, sorry.

Hey that's straight from the guichan fps demo. They're doing integer division. Their planet is all egg shaped because of the aspect ratio, you just can't tell because their planet is mostly off screen.

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!