OpenGL tex parameter error

This is a discussion on OpenGL tex parameter error within the Game Programming forums, part of the General Programming Boards category; Compiler: Code::Blocks [Edit]Problem Fixed: See second thread Hey everyone, and thanks in advance for any help you can give me. ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    102

    OpenGL tex parameter error

    Compiler: Code::Blocks

    [Edit]Problem Fixed: See second thread

    Hey everyone, and thanks in advance for any help you can give me. I'm working on a game using OpenGL for my graphics. In rendering, I have to set the S and T wrap coordinates via glTexParameteri(2d, wraps/t, GL_CLAMP_TO_EDGE) in order to render a skybox correctly. However almost directly after, I have to render a plane using the GL_REPEAT parameter. Here's the code:

    Oh btw, PlayEnvironment is derived from Environment, it just contains a skybox and details to render it. The Play Environment also renders the table that I need.

    Code:
    void PlayEnvironment::draw()
    {
        Environment::draw();    //To environemnts draw first
    
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    
        std::cout << glGetError();
    
        tableTex->Set();
        tablePlane->drawGL();
    
    }
    Environment:

    Code:
    bool Environment::draw()
    {
        glDisable(GL_DEPTH_TEST);
        glDepthMask(GL_FALSE);
    
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
        glPushMatrix();
    
        glTranslatef(center[0], center[1], center[2]);
        glRotatef(rotate, 0.0f, 1.0f, 0.0f);
    
        for(int x = 0; x < 6; ++x)
        {
            planeTexs[x]->Set();
            planes[x]->drawGL();
        }
    
        glEnable(GL_DEPTH_TEST);
        glDepthMask(GL_TRUE);
    
        return true;
    }
    Now, I've noticed when I comment out the GL_CLAMP parameter call, it works fine on the table, however when it's in there it doesn't, and I do need the clamp to edge to call for the skybox.

    Anyway, bottom line, does anyone know why the GL_REPEAT parameter call isn't working as intended (it is basically skipped over, and clamp to edge is applied to the table) ?
    Last edited by JJFMJR; 11-26-2008 at 08:10 AM.
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

  2. #2
    Registered User
    Join Date
    Apr 2007
    Posts
    102
    Wow, Jeez I'm stupid.. NEVERMIND! lol, nevermind nevermind.. I can't believe I'm so stupid. Figured out the problem. Now that I thought about it, the tex parameter is specific to the bound texture. Which means, the repeat command wasnt applying to the tableTex because it hadn't been bound. Here's the fix:

    Code:
    void PlayEnvironment::draw()
    {
        Environment::draw();    //To environemnts draw first
    
        std::cout << glGetError();
    
        tableTex->Set();
        
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        
        tablePlane->drawGL();
    
    }
    My Favorite Programming Line:
    Code:
    #define true ((rand() % 2) ? true : false)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 02:29 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21