Results 1 to 8 of 8

Thread: Textures (identical to BMP file)

  1. #1
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    15

    Textures (identical to BMP file)

    Hi,

    I'm playing around with Textures and would really appreciate it if someone could help me with the following:

    I have a 128x128 BMP file that I use as a texture. I want the texture to be shown in an openGL application exactly like the BMP image. That is I want the same RGB value for each pixels.

    In my application the texture looks quite similar to the BMP file. But when I look at it closer (pixel for pixel), I see there are small differences in the RGB values for each pixels.

    Is there some settings that can make the texture identical to the BMP image pixel for pixel?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Textures (identical to BMP file)

    completely disable bilinear filtering, disable lighting and blending, be sure to draw your texture at the exact size needed.

  3. #3
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    15

    Re: Textures (identical to BMP file)

    Thank you very much for your reply, but I still can not get it to work.

    I have disabled lighting and blending with the following:
    glDisable(GL_LIGHTING);
    glDisable(GL_BLEND);

    I don't know how to completly disable bilinear filtering, but I use the following lines:
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    The texture is also drawn in the exact same size as the BMP file, but the colors of the texture and BMP file still differs.

    Any other settings I can be missing?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Textures (identical to BMP file)

    No more ideas.
    screenshots please.

  5. #5
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    15

    Re: Textures (identical to BMP file)

    Original BMP file:

    OpenGL result:


    In another test I made, I created a BMP file with four rectangles.

    The RGB values for the rectangles in BMP were:
    100,100,100
    110,110,110
    120,120,120
    200,200,200

    In openGL texture the RGB values of the rectangles were:
    99,101,99
    107,109,107
    123,121,123
    206,203,206

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Textures (identical to BMP file)

    That is some pretty heavy color banding.
    Be sure to request (and get) at least 8 bits per color channel per pixel.
    If you draw a color gradient without texture, only with glColor from black to white, do you still see the color banding ?
    Check how you upload your texture to OpenGL (color bits parameters, etc).

    What is your video chip ? Nvidia, ATI, intel ?

  7. #7
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    15

    Re: Textures (identical to BMP file)

    The problem seemed to be number of bits per color channel.

    When I changed the internalFormat parameter for the glTexImage2D function from GL_RGB to GL_RGB8 everything worked fine.

    Thank you very much for your help! I really appreciate it!

  8. #8
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Textures (identical to BMP file)

    Indeed, GL_RGB is older and deprecated, as it does not specify the number of bits.

Similar Threads

  1. Drawing two identical shapes
    By MarcLS in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-07-2017, 06:56 PM
  2. Want to move only one of many identical objects. How?
    By thebigbo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-11-2014, 02:32 PM
  3. I have 5 identical pcs - only 1 has enabled OpenGL
    By HappyMomOfFive in forum OpenGL: User Software
    Replies: 5
    Last Post: 03-29-2012, 10:36 PM
  4. drawelements for many identical objects
    By xman84 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-26-2010, 12:56 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