Results 1 to 2 of 2

Thread: frustrating texturing problems

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2000
    Posts
    3

    frustrating texturing problems

    I've to make each class in my opengl program get it's own address from wglgetprocaddress for the multitexture extension (that's the only one I'm using so far). However, one of my classes isn't displaying the textures correctly. I know that the textures are loading correctly, but it displays a random texture on the skybox rather than the one I specified with the setTexture member functions. OGLWrapper is just a generic openGL wrapper that keeps track of wether lighting and blending have been enabled. I know that the viewer class works correctly too. Here's some of the code:

    class skybox{
    private:
    typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target);
    typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);

    PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
    PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;

    GLuint top;
    GLuint bottom;
    GLuint left;
    GLuint right;
    GLuint back;
    GLuint front;
    public:

    void setTop(GLuint newtexture);
    void setBottom(GLuint newtexture);
    void setLeft(GLuint newtexture);
    void setRight(GLuint newtexture);
    void setFront(GLuint newtexture);
    void setBack(GLuint newtexture);

    void drawBox(Viewer *me, OGLWrapper *OGLWrapper);

    void setExtensions();
    };

    //now here's the implementation for the class

    void skybox::drawBox(Viewer *me, OGLWrapper *OGLWrapper){


    GLfloat rotMatrix[ 16 ];
    me->camOrient.getMatrix( rotMatrix );

    glPushMatrix();
    glLoadIdentity();
    glMultMatrixf( rotMatrix );

    //glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    (*glActiveTextureARB)(GL_TEXTURE0_ARB);
    //glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, front);

    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.01f);
    glVertex3f(-40.0f, 40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.01f);
    glVertex3f(40.0f, 40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.99f);
    glVertex3f(40.0f, -40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.99f);
    glVertex3f(-40.0f, -40.0f, -40.0f);


    (*glActiveTextureARB)(GL_TEXTURE0_ARB);
    //glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, top);


    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.01f);
    glVertex3f(-40.0f, -40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.01f);
    glVertex3f(40.0f, -40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.99f);
    glVertex3f(40.0f, -40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.99f);
    glVertex3f(-40.0f, -40.0f, 40.0f);


    (*glActiveTextureARB)(GL_TEXTURE0_ARB);
    //glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, bottom);


    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.01f);
    glVertex3f(-40.0f, 40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.01f);
    glVertex3f(40.0f, 40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.99f);
    glVertex3f(40.0f, 40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.99f);
    glVertex3f(-40.0f, 40.0f, -40.0f);

    (*glActiveTextureARB)(GL_TEXTURE0_ARB);
    //glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, right);


    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.01f);
    glVertex3f(40.0f, -40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.01f);
    glVertex3f(40.0f, 40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.99f);
    glVertex3f(40.0f, 40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.99f);
    glVertex3f(40.0f, -40.0f, 40.0f);

    (*glActiveTextureARB)(GL_TEXTURE0_ARB);
    //glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, left);


    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.01f);
    glVertex3f(-40.0f, -40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.01f);
    glVertex3f(-40.0f, 40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.99f);
    glVertex3f(-40.0f, 40.0f, -40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.99f);
    glVertex3f(-40.0f, -40.0f, -40.0f);

    (*glActiveTextureARB)(GL_TEXTURE0_ARB);
    //glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, back);


    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.01f);
    glVertex3f(-40.0f, -40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.01f);
    glVertex3f(40.0f, -40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.99f, 0.99f);
    glVertex3f(40.0f, 40.0f, 40.0f);
    (*glMultiTexCoord2fARB)(GL_TEXTURE0_ARB, 0.01f, 0.99f);
    glVertex3f(-40.0f, 40.0f, 40.0f);

    glEnd();
    glPopMatrix();

    }

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2000
    Posts
    3

    Re: frustrating texturing problems

    I forgot to post the other member functions :P

    void skybox::setExtensions(){
    glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
    glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
    }


    void skybox::setTop(GLuint newtexture){
    top = newtexture;
    }
    void skybox::setBottom(GLuint newtexture){
    bottom = newtexture;
    }
    void skybox::setLeft(GLuint newtexture){
    left = newtexture;
    }
    void skybox::setRight(GLuint newtexture){
    right = newtexture;
    }
    void skybox::setFront(GLuint newtexture){
    front = newtexture;
    }
    void skybox::setBack(GLuint newtexture){
    back = newtexture;
    }

Similar Threads

  1. Vertex / pixel shader development: frustrating
    By VuurSnikkel in forum OpenGL: GLSL
    Replies: 5
    Last Post: 08-08-2004, 03:13 PM
  2. The frustrating glFrustum
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-15-2003, 05:57 AM
  3. Up and running? Very frustrating...
    By mvendramini in forum OpenGL: Linux
    Replies: 9
    Last Post: 03-11-2003, 02:47 PM
  4. Texturing problems;
    By LordOfTheUniverse in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-03-2002, 02:39 PM
  5. Very strange, very frustrating problem >:-(
    By sw@T in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 10-12-2002, 11:06 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