Hi all,
what's the best way of combining OpenGL rendering with GDI overlays? I'm
working on a volume rendering application where the volume rendering
sometimes takes a lot of time. I would like to be able to change the overlay
graphics (currently some lines and short text strings) without having to
rerender the whole OpenGL scene, and preferably it should all be
doublebuffered. I.e. I would like to render to an offscreen bitmap and then,
in the OnPaint method do
DrawImageUnscaled(renderedBitmap);
DrawOverlays();
So far, I've been using a ControlGLContext but ControlGLContext.ToImage()
throws an exception ("Invalid parameter used" from the Bitmap constructor).
I've been looking at GDIGLContext (which feels like the right way to go?)
and I have been able to make it work, but the rendering takes about twice
the time compared to that when I use a ControlGLContext - event if the code
in OnPaint() is never run. In fact, if I only change this:
ctxt = new ControlGLContext(this);
into this:
bitmap = new Bitmap(width, height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
new GDIGLContext(Graphics.FromImage(renderedBitmap));
the following call, which in the first case makes the image appear on screen
and in the second case does not, takes twice the time:
scene.Render();
scene is a volume rendering scene. Does this make sense to you guys!? To me,
it does not!
I would like to use CsGL 1.4.0 but using this version, the volumes rendered
using 2D and 3D textures have way too large distances between the textures
(the distance between the textures - i.e. the number of textures - varies
with the object's distance to the camera). Also, the problem above isn't
solved by using 1.4.0. So I stick to CsGL 1.3.2. Any ideas or suggestions?
Best regards,
Aron Ernvik
|