|
From: Lloyd D. <Ll...@5d...> - 2002-08-08 22:37:35
|
..mmhh.. I see.
Well it's simple.
I don't exactly understand why you are not able to create a new context,
maybe it fail because it doesn't want to have its pixelformat setted again,
when there is already a current GLContext, I should investigate.
Anyway, your problemis a context can't be current in multiple thread.
I saw you grab() the context but never drop() (or IsCurrent=false) it. so
when you try to make it current in another thread it is an error, it
complains, that normal.
But now, you have rthe solution, call drop at the end of OnPaint() or
whatever place you judge appropriate...
-----Original Message-----
From: csg...@li...
[mailto:csg...@li...]On Behalf Of Aron Ernvik
Sent: Wednesday, 7 August 2002 8:07
To: csg...@li...
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
|