Results 1 to 7 of 7

Thread: Texture matrix problems

  1. #1

    Texture matrix problems

    I have 2 textures which one of them, I need to alter its matrix (scaling.). What I am currently doing is:

    bindthefirsttexture();

    glPushMatrix();
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();

    glScalef(2,2,0);
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    bindthesecondtexture();

    do some other stuff here.

    However, that matrix transformation is applied on the second texture too! What am i doing wrong here?
    Thanks

  2. #2
    Member Contributor
    Join Date
    Apr 2002
    Posts
    94

    Re: Texture matrix problems

    I think you need to reset your texture matrix before drawing the second one.

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    P4 2Ghz, GEFORCE4, 512 Meg RAM, WIN2000, VStudio 6.0

  3. #3
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: Texture matrix problems

    You need to push the matrix stack after loading the texture matrix, otherwise you're pushing the modelview stack.

    Edit: And pop the stack before switching back to the modelview.

    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glLoadIdentity();
    do stuff
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    do the other stuff

    Hope that helps

    [This message has been edited by yakuza (edited 12-08-2002).]

  4. #4

    Re: Texture matrix problems

    Thanks, makes sense.
    I will try that later and tell you.

  5. #5

    Re: Texture matrix problems

    That didnt work, it didnt scale the matrix. Any other ideas?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: Texture matrix problems

    Make sure you did your drawing after scaling the texture matrix, but before popping the texture matrix stack, otherwise you lose the changes you made.

    Code :
    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glLoadIdentity();
    glScalef();
    Draw_stuff_that_uses_scaled_texture_matrix();
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    do the other stuff

  7. #7

    Re: Texture matrix problems

    Correct, thanks!

Similar Threads

  1. Matrix Problems
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-07-2006, 11:31 PM
  2. Matrix Problems
    By tbc++ in forum OpenGL: General
    Replies: 1
    Last Post: 09-26-2004, 12:50 AM
  3. Vertex Program Problems: texture matrix tracking
    By knackered in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 01-31-2002, 03:00 PM
  4. Matrix Problems...
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-26-2001, 11:37 AM
  5. Matrix problems
    By KRONOS in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-22-2000, 02:54 AM

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