Results 1 to 7 of 7

Thread: Texture Mapping

  1. #1
    Member Contributor
    Join Date
    Jul 2003
    Location
    va beach
    Posts
    63

    Texture Mapping

    I am making a screensaver, and I want to use texture mapping. I have all my basecode done, it compiles without error. The problem is that there is a blank screen displayed.

    void SetupAnimation(int Width, int Height)
    {
    glViewport(0,0,(GLsizei)Width,(GLsizei)Height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-300, 300, -240, 240, 25, 75);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0.0, 0.0, 50.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

    // background
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    }


    That is my code and setup for GL. Any thoughts?

  2. #2
    Member Contributor
    Join Date
    Jul 2003
    Location
    va beach
    Posts
    63

    Re: Texture Mapping

    Is there an OpenGL forum on Irc?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: Texture Mapping

    Can you post your drawing code as well?

  4. #4
    Member Contributor
    Join Date
    Jul 2003
    Location
    va beach
    Posts
    63

    Re: Texture Mapping

    void OnTimer(HDC hDC)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    spin = spin + 1;
    glPushMatrix();
    glRotatef(spin, 0.0, 0.0, 1.0);
    glPushMatrix();
    glTranslatef(150, 0, 0);


    if(bTumble)
    glRotatef(spin * -3.0, 0.0, 0.0, 1.0);
    else
    glRotatef(spin * -1.0, 0.0, 0.0, 1.0);


    float xvals[] = {-30.0, 0.0, 30.0, 0.0};
    float yvals[] = {0.0, -30.0, 0.0, 30.0};
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture[0]);

    glBegin(GL_QUADS);
    for(int i=0; i < 4; i++)
    glVertex2f(xvals[i],yvals[i]);


    // Front

    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Top right ( front )
    glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f); // top left ( front )
    glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f);
    glEnd();

    glPopMatrix();
    glFinish();
    SwapBuffers(hDC);
    glPopMatrix();
    }

  5. #5
    Member Contributor
    Join Date
    Jul 2003
    Location
    va beach
    Posts
    63

    Re: Texture Mapping

    Sorry in my cut n paste haste I nopped out the last line of my quad.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: Texture Mapping

    I don't think this will matter, but you should probably call glPopMatrix() before swapping buffers. I don't see why you should get a blank screen at first blush, but chapter 3 of the Red Book has a section at the very end called Troubleshooting Transformations, which describes several reasons why someone can get a blank screen:

    http://tassadar.physics.auth.gr/~cha.../chapter03.htm

  7. #7
    Member Contributor
    Join Date
    Jul 2003
    Location
    va beach
    Posts
    63

    Re: Texture Mapping

    Thank you starman. I greatly appreciate the help.

Similar Threads

  1. Texture mapping ::: 3D Face Mapping
    By 3render3 in forum OpenGL: General
    Replies: 2
    Last Post: 03-24-2013, 06:49 PM
  2. projective texture mapping and shadow mapping
    By phoenix_gl in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-08-2012, 08:00 PM
  3. Replies: 0
    Last Post: 01-09-2005, 05:53 PM
  4. Replies: 1
    Last Post: 01-09-2005, 05:50 PM
  5. Texture Mapping / Environmental Mapping.
    By imported_Andrew in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-09-2000, 01:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean