fonts and multiple windows

i have a problem when writing text when my app is using several windows (ie cview in my case).

It works well with a single windows (using wglUseFontBitmaps and display list).

But when there are several windows, text is written only for one window. It doesn’t work for other windows. And i don’t get any opengl errors.

any idea ?


ps : i’m not used to context and multi opengl windows in one app. But I feel it could come from the function to create text display lists, that is :


mPrevious2DObject = ::SelectObject(getNormalDC(), m2DFont);

m2DFontBase = glGenLists(256);
BOOL res = wglUseFontBitmaps(getNormalDC(), 0, 255, m2DFontBase);

I think it’s because your windows use different DC. But I cannot say more.

Hope that helps.

thanks for the answer. I search in that direction and found that :
when creating the display lists, I use the DC given by getNormalDC() (in wglUseFontBitmaps(getNormalDC()…)).

But when rendering, i’m using another DC.

Can this cause the display lists to render nothing ?

i’m lost in contexts…

i have two windows and for each, i call the following functions :

HDC hdc = getNormalDC();
HDC hdc2 = wglGetCurrentDC();
HGLRC hglrc = glGetCurrentContext();

i get two different values for hdc.
But hdc2 is always the same, whatever the window is. And i also always have the same hglrc. Is this normal ?

Display lists aren’t shared between two contexts but if you specify the context to be shared to the new context at the new context creation.
Under linux, it’s when using this style of function:

glXCreateContext (display, new_context,shared_existing_context,…);

But I still don’t know if this will work as I mainly used that under a multithreaded application. Also, the display has its importance.

Unfortunately, it’s been a while I didn’t program under W32 and I never made such stuff on that OS neither.

Hope that helps.

I have found that if you are using display lists in multiple viewports you must define the display list for each window context.

It seems that my rendering contexts are not updated correctly. I’m using SoWinViewer objects (Open Inventor widgets). The getNormalContext is supposed to give me the current context but i have to check that it’s compatible with wglCurrentContext :

if( getNormalContext() != wglGetCurrentContext())

I’m sure it could also works by sharing display lists among contexts with wglShareLists().

I remembered that wglShareList was discussed on a topic about some months ago. Try to make a research because I cannot help you more. But maybe others will.