Results 1 to 3 of 3

Thread: Textured Cube: Diff tex. on each side

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    California
    Posts
    4

    Textured Cube: Diff tex. on each side

    hi,

    I was reading the textured cube tutorial on NEHE.gamedev.net lesson 6

    He shows you how to a single textured cube. I tried to extend this to have 2 textures but it's not working. Only one texture works and the other faces of the cube are 'white'.

    Im almost positive that the trouble is w/ the texture binding. here's a summary of what I did there.

    #--------------

    AUX_RGBImageRec *TextureImage[2]; // Storage space for our Texture


    if ( TextureImage[0]=LoadBMP("data/crate.bmp"))
    {
    Status=TRUE;

    //Here it looks like we are creating storage and type of texture then assigning the bitmap data to it.
    glGenTextures(1, &texture[0]); // Create the texture
    glBindTexture(GL_TEXTURE_2D, texture[0]); // Texture generation using data from the bitmap
    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->data);

    if( TextureImage[1]=LoadBMP("data/nehe.bmp") )
    {
    Status= TRUE;
    glGenTextures(1, &texture[1]); // Create the texture
    glBindTexture(GL_TEXTURE_2D, texture[1]); // Texture generation using data from the bitmap
    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE, TextureImage[1]->data);

    }


    #-------
    Can anyone see what' going wrong here?

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    California
    Posts
    4

    Re: Textured Cube: Diff tex. on each side

    Ok I found that I have an extra glGenTextures
    and then I only created one texture. I fixed this by deleting the second glGenTextures
    then editing the first w/
    glGenTextures(2, &texture[0]); but that still didnt help.

    anyone know why?

    thanx

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: Textured Cube: Diff tex. on each side

    Check glGetError() for errors while creating the second texture.
    Verify that the second texture has the right dimensions, color-depth etc.

    Have you tried creating the second texture as an exact copy of the first one (should produce the same results as with using just one texture?

    BTW, both of your solutions using glGenTextures() should work: it makes no difference asking for a single name twice or for two names once.

    HTH

    Jean-Marc

Similar Threads

  1. Lateral side of the cube being lit by specular light
    By YardenJ2R in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 06-16-2017, 05:59 PM
  2. multiple textured cube
    By Romulo in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-03-2014, 02:34 PM
  3. Incorrectly textured cube
    By cpp_someone in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-15-2013, 05:07 AM
  4. Rotating a Cube randomly - which side is on top?
    By meonline in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-08-2008, 02:13 PM
  5. Lighting a textured cube(how);
    By Phillfrog in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-30-2002, 05:29 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