texture objects in multithreded program

Hello , i am coding an opengl program in win nt, that loads textures and data at first. It workes for normal operation well but when i make this loading in a thread the texture objects does not bound, it shows white as textures. What can cause this? can someone has an idea? only thing i change is making the general initilization fuction as a thread this males the texture object creation null functionning…
Thanks for all…
Mehmet

OpenGL only creates Contexts for the current thread.
So what you need to do, is to bind the textures in the same thread as OpenGL was created.
You could have texture fileIO in another thread, but the binding itself.

The same applies for drawing, you can’t use OpenGL draw commands in other threads than the original one.

Originally posted by IsaackRasmussen:
[b]

The same applies for drawing, you can’t use OpenGL draw commands in other threads than the original one.[/b]

Are you sure, I thought it only applied to the creation of the context and the resources?

Yeah, I pretty sure of that.
You can’t create OpenGL in Thread1 and then call glBegin/glEnd’s in Thread2.

Because glBegin/ checks current thread-context and since there’s none for thread2, it won’t draw.

I would love to be corrected on it though

I have made research on msdn and there is what I have found :

I am sure that :

an HWND is valid in all threads.
The message pump for a window can only be in the thread that created the window.

a thread can use opengl commands if :

  1. wglMakeCurrent is called from the thread.
  2. the context used in (1) is not current in any other threads.

I am not sure yet if DC and contexts can be shared between threads. The documention seems to point to that, put is it not explicit. I guess Markun you should try that.

I will also try it later.

[This message has been edited by Gorg (edited 05-24-2001).]

You can share texture objects between contexts in the same process but different threads, just as you can share display lists.

  • Matt

Originally posted by mcraighead:
[b]You can share texture objects between contexts in the same process but different threads, just as you can share display lists.

  • Matt[/b]

So calling wglShareLists also enable sharing of texture objects?

I believe that’s how you do it.

  • Matt

When i changed the Binding part into main(the one created window,and OGL rendering contex) the texture objects are created. Thanks for the helping…