PDA

View Full Version : Problem with rendering to multiple windows on WIN98



krish
08-30-2000, 11:58 PM
I'm trying to port my 3D medical imaging tool from unix to Win98 and I am having problems rendering to multiple windows.

I am not using MFC and I am creating child windows (using CS_OWNDC) and associating a rendering context with each window. On startup my program creates three windows and renders different views in each of them. So far so good!

The problem is that as I update the views, sooner or later I start getting the wrong view rendered in one or more of the windows. Also at least one of the windows will not get updated at all. It's as if OpenGL is getting its RCs and HDCs mixed up, but as far as I can tell, everything is okay with my code. The problem appears to start at random intervals after startup - but sooner or later (usually sooner) it always occurs.

Here's what I am using:

Creative Blaster riva TNT (problem occurs with both Creative's original drivers, and detonator 3).

Visual C++ Developer Studio 4.2

I've tried the Opengl32.lib that comes with Developer Studio, and also I even built and used MesaGL. Still get the problems.

I am (I think) correctly using wGlMakeCurrent
and I tried using wGlMakeCurrent(NULL,NULL) before setting each context so that I can guarentee only one RC is active at any one time.

I recently came across a posting saying that it is a good idea to just have one RC for my program, but multiple DCs, so I tried this, but no joy.

My rendering contexts are doublebuffered, but I am remembering to use SwapBuffers.

Any suggestions would be greatly appreciated.

The frustrating thing is that I ported my code pretty quickly and easily, and the program almost works!

If anyone's interested, you can see examples of the unix version of my renderer at:
http://www.liv.ac.uk/mariarc/mri3dX/

ben
08-31-2000, 06:51 AM
It definitely sounds like you have a rendering context currency issue. One thing you might try, just to make sure things are working out correctly, is to place a call to wglGetCurrentContext right before you make the context for a window current. Put an assertion in your code that will fire if wglGetCurrentContext indicates that another rendering context. This will let you know if your wglMakeCurrent(NULL, NULL) calls are getting called at the right times.

El Jefe
08-31-2000, 09:31 AM
Hmmm, is it possible that the problem is just the inherent flakiness of OpenGL with win9x? ...anyway, it seems to me that a programmer at my current job had huge problems with getting a GL app to work with multiple contexts, but only on win95/98...it works perfectly on windows NT 4.0 and win2k.

In short, I wouldn't be surprised if there is nothing you can do to fix the problem.

JR
08-31-2000, 12:21 PM
I'm not positive this will solve your problems, but from what i understand windows can randomly switch the DC's on you.

To solve this and other problem of making sure only one view uses the "single" rc at a time I use the following code

BOOL CGLView::EnterGLSection()
{
if (m_gGLBUSY)
{
TRACE("gl is busy, ignoring\n");
m_gGLBUSY = false;
return false; // return true if we want to block
}
m_gGLBUSY = true;

if (m_hRC)
wglMakeCurrent(m_cDC->GetSafeHdc(), m_hRC );
return false;
}

void CGLView::ExitGLSection()
{
wglMakeCurrent(NULL,NULL);
m_gGLBUSY = false;
}

At the very least I think you should try using :
wglMakeCurrent(m_cDC->GetSafeHdc(), m_hRC );

I hope this is helpful

J.R.