Results 1 to 6 of 6

Thread: Textures are white, then they're not?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2007

    Textures are white, then they're not?

    I am attempting to load some largish textures (1024x1024). When I display them they show up as a big white rectangle, and then they magically appear correctly a few seconds later.

    I am doing a glFinish() immediately after calling glTexImage2D(...). I'm guessing that the texture just isn't completely loaded even though I call glFinish(), which is why it shows up correctly a few seconds later.

    I saw something about ARB_sync on a google search, but I'm not sure if that will fix my problem.

    Can someone point me in the direction of a solution?


  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008

    Re: Textures are white, then they're not?

    Your suspicion is possibly correct, but I'd be more suspicious that some OpenGL state that is not initialized properly to do with textures / pixel format is getting altered at some point in your main loop and that is when the texture appears..

    What kind of texture is it? Format etc.? And what GPU are you on?

  3. #3
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Bay Area, CA, USA

    Re: Textures are white, then they're not?

    That is bizarre. It may be an overly aggressive optimization aimed at asynchronous downloads but that would be pretty sophisticated and also non conformant. It wold be a bug. I think this is highly implausible for all sorts of reasons, especially when you consider the potential volatility of memory that the driver manages (I assume your'e not using PBOs).

    Are you sure you're not doing something else that invalidates the texture unit for the fetch. White basically means the texture is invalid and it can be invalid for many reasons.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2007

    Re: Textures are white, then they're not?

    I have tested it on two different NVIDIA graphics cards (8000 and 9000 series) and it works fine. This could just be coincidence because the GPUs are faster?

    The problem shows up when using the Intel graphics chipset on some of my friends' laptops. I can also reproduce this when running Windows in VMWare Fusion on my machine with an NVIDIA graphics card.

    Here is how I'm loading the texture.

    Code :
    LoadTexture() {
      [ get bitmap data ]
      unsigned char *pixbuf = new unsigned char[mBmp->GetWidth()*mBmp->GetHeight()*4];
      [ populate pixbuf with pixel values ]
      glGenTextures (1, &mTexid);
      glBindTexture(GL_TEXTURE_2D, mTexid);
      glTexImage2D(GL_TEXTURE_2D, 0, 4, mBmp->GetWidth(), mBmp->GetHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, pixbuf);

    I call this loading routine exactly once per image. Each texture is wrapped in an SSPic object. Once the loading routine is complete, the SSPic object is added to a vector of SSPic objects used by the drawing thread. A picture can only be in the vector of SSPic objects if its loading routine has returned success (where glFinish is executed). There is proper synchronization with respect to this vector of pictures so that only one of the drawing thread or picture loading thread can be using it at any one time.

    Even if you don't believe me that the synchronization around the vector works, I am only adding the SSPic object to the vector after the loading routine has completed.

    Essentially, if the picture is in the shared vector (meaning that it will be drawn), then glFinish must have returned.

    What am I missing? Do you need me to give more information? Thanks for your help.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2007

    Re: Textures are white, then they're not?

    I forgot to mention that I have two contexts. I will call them c0 and c1.

    The main drawing thread initializes the contexts and acquires c0 via

    Code :
    c0 = wglCreateContext(mDC);
    c1 = wglCreateContext(mDC);
    wglMakeCurrent(mDC, c0);

    The main drawing thread then immediately enables sharing between the contexts via

    Code :
    wglShareLists(c0, c1);

    When the image loading thread begins it immediately acquires c1 via

    Code :
    wglMakeCurrent(mDC, c1);

    The image loading thread loads textures in a loop. If it ever terminates then the image loading thread releases c1

    Code :
    wglMakeCurrent(NULL, NULL);

    Could there be some funky delay in sharing between the two contexts that would be causing the textures to show up as white for a few seconds?

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2007

    Re: Textures are white, then they're not?


    Does anyone have any clue as to why the textures would show up white for a few seconds?

Similar Threads

  1. white textures on ATI hardware...
    By jimmycox in forum OpenGL: User Software
    Replies: 1
    Last Post: 09-20-2010, 04:25 AM
  2. white textures on Vista, on XP everything fine
    By Alexander Alexander in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 04-26-2010, 05:07 PM
  3. My textures show up as white blocks - help!
    By Bryan Taylor in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-24-2007, 02:09 PM
  4. White Textures :(
    By 31337 in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 04-28-2003, 10:12 PM
  5. White textures if don't use mipmapping...
    By architekt in forum OpenGL: Advanced Coding
    Replies: 17
    Last Post: 08-05-2002, 11:37 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