|
From: Lloyd D. <ll...@ga...> - 2002-08-08 09:08:24
|
Hi Aron,
Maybe it's your second message, I don't know it seems my mail server has
problem this morning and I am in a hurry now, so I would be short.
A thread cannot be local to 2 context.
when you call grab() on it, as it is already current in an another context
it cause an error.
you should drop() (or IsCurrent = false) it when you no longer need it, so
it's available in othre conext.
This make me think I should do 2 things:
1. comment this in the FAQ
2. make a function to query if a context is use in some context and may be a
wait method...
bye & good luck
PS: watch the mailing list maybe a csgl update in 1 month....
----- Original Message -----
From: "Aron Ernvik" <ar...@se...>
To: <csg...@li...>
Sent: Wednesday, August 07, 2002 8:06 PM
Subject: [Csgl-users] problem using the same context in more than one thread
> CsGL users and developers,
>
> I hope you can help me out with the following problem! I'm using CsGL for
a
> volume rendering application. I use an external volume rendering library
> written in C++ for which I've written a managed wrapper. I've also created
a
> custom Control, VRTControl, which contains a ControlGLContext. In the
> constructor I do
>
> public VRTControl() {
> ...
> ctxt = new ControlGLContext(this, CreateDisplayType());
> ctxt.Grab();
>
> // set up the context
> GL.glShadeModel(GL.GL_SMOOTH);
> GL.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
> ...and so on
> }
>
> Then there's a method called Render() in this VRTControl class:
>
> public void Render() {
> ctxt.Grab();
> GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
> if (scene != null) {
> scene.Render(); // perform the actual volume rendering
> glDraw(); // overlay graphics
> GL.glFinish();
> OpenGLException.Assert();
> ctxt.SwapBuffer();
> }
> }
>
> scene.Render() performs the actual volume rendering and its output is sent
> to the OpenGL buffers. All this works perfectly when the same thread calls
> the constructor and VRTControl.Render(). It's been a pleasure working with
> CsGL so far! Now for the problem: the call to scene.Render() typically
takes
> a lot of time, so I want to call MyControl.Render() using a separate
thread.
> But when I try this, I get the error message "Can't make the context
> current" from the ctxt.Grab() call. When I try to recreate the context
using
> the rendering thread I get the error message "Invalid device context (DC)
> handle" when calling ctxt.Dispose() on the old one. Ignoring this message
> doesn't help - nothing ever shows on the context that is created by the
> rendering thread.
>
> What is the right way to have more than one thread using the same OpenGL
> context? Is it at all possible? Or is it at least possible to create a new
> ControlGLContext in a Control using another thread than the one that
created
> the control? (I haven't managed so far!)
>
> Thanks a lot for any help! And keep up the really good work with CsGL!
>
> Best regards,
>
> Aron Ernvik, Sweden
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Csgl-users mailing list
> Csg...@li...
> https://lists.sourceforge.net/lists/listinfo/csgl-users
>
|