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 5 of 5

Thread: textures gone after init ?!?

  1. #1
    Guest

    textures gone after init ?!?

    I have a very strange problem. In my init call I load a texture like this:

    glBindTexture( GL_TEXTURE_2D, tex_num );
    glTexImage2D( GL_TEXTURE_2D, 0, 4, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);

    Then in my render loop I do the texture bind again before gl_begin. However, the texture is gone (although tex_num has the correct value, 10).

    When I put the texture loading into my main render loop everything works fine. However, this is a bad solution, since I'm loading my texture every frame and my tex_num constantly increases by one (I tested if I can access old bound textures, but they are gone which at least is consistent).

    I don't have any gldeletetextures or gldisable(gl_texture_2d) in my code. I haven't used glgentextures at all because I shouldn't need it (I manage my own texture names).

    Does any one have a clue what's going on? I'm at the limits of my wisdom here...

    Cheers, Christian

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    596

    Re: textures gone after init ?!?

    do you have an active opengl rendercontext before you init the textures?

  3. #3
    Guest

    Re: textures gone after init ?!?

    Thanks a 1000 times!!! This really drove my crazy. I had every thing in subfunctions and indeed had no render context (did that right after my init textures)...

    Just out of interest, I thought I only need the context to render to (obviously I need it for all gl operations, not just render ones!), why is that (why doesn't creating and binding them before making a context work)?

    Thanks again, lesson learnt for the future...

    Cheers, Christian

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    596

    Re: textures gone after init ?!?

    The render context is a container for both render stuff and all states and 'objects' that belongs to it..

    you can have 2 different RC in your program with different textures in them.. ( even on the same textureID)

  5. #5
    Guest

    Re: textures gone after init ?!?

    Makes sense. Many thanks...

Posting Permissions

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