Results 1 to 2 of 2

Thread: Textures not working

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    Textures not working

    I can't get textures working for the life of me. I'm trying to put a texture on a square, but its just showing up as a plain white square. I read some trouble shooting tips but none of them fixed the problem.

    Here's my code. First an initialization function:

    Code :
    void initializeTexture(char * file, unsigned int * texture)
    {
    	glEnable(GL_TEXTURE_2D);
     
    	texImage=new BMP_OBJ(file);
     
    	glGenTextures(1,texture);
    	glBindTexture(GL_TEXTURE_2D,*texture);
     
     
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
    	glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
     
    	glTexImage2D(GL_TEXTURE,0,GL_RGB,texImage->width,texImage->height,
    		0,GL_RGB,GL_UNSIGNED_INT,texImage->image);
    }

    heres my drawing function:

    Code :
    void drawTexQuad(float x, float y, float z, float width)
    {
    	glDisable(GL_LIGHTING);
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D,texture);
    	glBegin(GL_QUADS);
    	glTexCoord2d(0.0,0.0); glVertex3f(x, y, z);
    	glTexCoord2d(1.0,0.0); glVertex3f(x+width/2, y, z);
    	glTexCoord2d(1.0,1.0); glVertex3f(x+width/2, y+width/2, z);
    	glTexCoord2d(0.0,1.0); glVertex3f(x, y+width/2, z);
    	glEnd();
    	glDisable(GL_TEXTURE_2D);
    }

    can anyone see what the problem could be?
    Striving for proficiency...

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    Re: Textures not working

    nevermind.. it was just two subtle typos.. i used GL_TEXTURE instead of GL_TEXTURE_2D and GL_UNSIGNED_INT instead of GL_UNSIGNED_BYTE.

    Silly me!
    Striving for proficiency...

Similar Threads

  1. glReadPixels() not working with textures
    By Incasegy in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-07-2013, 03:54 AM
  2. Textures not working
    By Esben in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-13-2009, 09:15 AM
  3. nVidia: Array Textures not working in GL3 ?
    By Jan in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 05-05-2009, 10:48 AM
  4. Resident Textures Not Working
    By tomjscott in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-25-2004, 03:06 PM
  5. 3dfx textures not working
    By Siwko in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 08-07-2000, 12:36 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