multithreading problem

Hi!

I implemented a multithreading application for out-of-core terrain visualization. In loader thread resources like terrain geometry and texture for visible tiles are loaded. In displaying thread resources are displayed. In loader thread function glGenTextures is called and returned invalid texture id that is zero. Can somebody advice me something?
Thank you.

Sebi.

You have a context current?
You have tried to make the same context current to both threads?
You have two contexts and didn’t issue wglShareLists? (shouldn’result in this error)
You never issued glDeleteTextures and ran out of 2^32-1 IDs?
You ran out of texture memory? (should not result in this error though)

Originally posted by Relic:
[b]You have a context current?
You have tried to make the same context current to both threads?

No. I have one context for displaying thread.
Do you think that I need two different context for each thread? Generaly is possibile what I want? If not then how is possibile to solve loading and rendering problems in separate threads?

You have two contexts and didn’t issue wglShareLists? (shouldn’result in this error)

Sorry but I don’t understand your question.

You never issued glDeleteTextures and ran out of 2^32-1 IDs?

No. Number of textures is big but is limited.

You ran out of texture memory? (should not result in this error though)[/b]

No. When I made loading and rendering in the same thread application worked without problems.

Thank you for your help.

If you have two threads using OpenGL on the same window at the same time they need to use two different OpenGL contexts, one per thread. Otherwise wglMakeCurrent would fail, because one context can only be current to one window at a time (read the wglMakeCurrent manual).
But two different OpenGL contexts can only share texture objects if you issued wglShareLists (under Win32) to let them reference the same texture objects.
If you didn’t do the above I don’t see how multithreading would help at all.
For less headaches, try to avoid situations where you have the same texture bound in one thread and updated in the second.

[This message has been edited by Relic (edited 07-12-2003).]

Originally posted by Relic:
one context can only be current to one window at a time

Perhaps a typo but it should be “one context can only be current to one thread at a time”.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_2u0k.asp

Yes, never edit posts without reading what you typed before.

Originally posted by Relic:
[b]If you have two threads using OpenGL on the same window at the same time they need to use two different OpenGL contexts, one per thread. Otherwise wglMakeCurrent would fail, because one context can only be current to one window at a time (read the wglMakeCurrent manual).
But two different OpenGL contexts can only share texture objects if you issued wglShareLists (under Win32) to let them reference the same texture objects.
If you didn’t do the above I don’t see how multithreading would help at all.
For less headaches, try to avoid situations where you have the same texture bound in one thread and updated in the second.

[This message has been edited by Relic (edited 07-12-2003).][/b]

Ok. Now multithread loading and displaying is working. Thank you very much.