Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Why is my loaded BMP background white?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2003
    Location
    Kochi, Japan
    Posts
    29

    Why is my loaded BMP background white?

    My program is as following:
    GLuint LoadGLTextures(const char *filename)
    {
    int status=FALSE;
    AUX_RGBImageRec *TextureImage=NULL;
    GLuint texture=0;
    ZeroMemory(&TextureImage,sizeof(void*)*1);
    // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
    if ( TextureImage=LoadBMP( filename ) )
    { status=TRUE;
    glGenTextures( 1,&texture);

    // Typical Texture Generation Using Data From The Bitmap
    glBindTexture( GL_TEXTURE_2D, texture );
    glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );


    if ( TextureImage) {
    if (TextureImage -> data) {
    free( TextureImage-> data );
    };

    free( TextureImage);
    };

    };


    glEnable( GL_TEXTURE_2D );
    glBindTexture( GL_TEXTURE_2D,texture);
    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0.0f,0.0f,-0.2f);
    glBegin(GL_POLYGON);
    glTexCoord2f( 0.0f, 0.0f );
    glVertex3f( -0.6f, -0.5f, 0.5f );
    glTexCoord2f( 1.0f, 0.0f );
    glVertex3f( 0.6f, -0.5f, 0.5f );
    glTexCoord2f( 1.0f, 1.0f );
    glVertex3f( 0.6f, 0.5f, 0.5f );
    glTexCoord2f( 0.0f, 1.0f );
    glVertex3f( -0.6f, 0.5f, 0.5f );
    glEnd();
    glLoadIdentity();


    return texture;


    }

    AUX_RGBImageRec * LoadBMP(const char *Filename)
    {
    FILE *File = NULL;
    if ( !Filename ) {
    return NULL;
    };

    File = fopen( Filename,"r" );

    if ( File ) {
    fclose( File );
    return auxDIBImageLoad( Filename );
    };

    return NULL;
    }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Why is my loaded BMP background white?

    Do you have an OpenGL context created at the time you call your texture loading routines?
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: Why is my loaded BMP background white?

    Are texture sizes powers of two?

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2003
    Location
    Kochi, Japan
    Posts
    29

    Re: Why is my loaded BMP background white?

    Thank you for your help
    I have solved the problem;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •