View Full Version : textures gone after init ?!?

06-01-2003, 06:36 PM
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 );

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

06-01-2003, 10:30 PM
do you have an active opengl rendercontext before you init the textures?

06-01-2003, 10:51 PM
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

06-01-2003, 11:22 PM
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)

06-02-2003, 06:02 PM
Makes sense. Many thanks...