Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: A question about perspective texture

  1. #1
    Intern Newbie
    Join Date
    Mar 2004
    Posts
    35

    A question about perspective texture

    Hi!
    Now I want to project a perspective texture onto a polygon, and get a orthographic view of

    the polygon. I did as following:
    1.Mapp the texture to the plane
    glTexCoord2f(0.0, 1.0);
    glVertex3f(-1.0,-1.0, -1600);
    glTexCoord2f(0.0, 0.0);
    glVertex3f(-1.0, 1.0,-1600);
    glTexCoord2f(1.0, 0.0);
    glVertex3f( 1.0, 1.0,-1600);
    glTexCoord2f(1.0, 1.0);
    glVertex3f( 1.0,-1.0,-1600);
    2.Set the texture matrix
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(0.5, 0.5, 0.0);
    glScalef(0.5, 0.5, 1.0);
    gluPerspective(20, 1, -1600, 1600);
    glRotatef(10, 1.0, 0.0, 0.0);
    glTranslatef(0.0, 0.0, -1600);
    3.render the scene
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 2000);
    DrawObject();
    But I got an undesired result. I want to know what's wrong with the method mentioned above?

    Can anyone give me some suggestions?
    Thank you in advance!

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: A question about perspective texture

    One problem is you have 2D texture coordinates not 3D, but also you should probably use texgen around the origin and divide by z using a glFrustum call on the texture matrix and translate & orient to the desired position.

    It'll take a bit of doing but there are online examples for you to look at that will help a lot.

    [This message has been edited by dorbie (edited 03-16-2004).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •