PDA

View Full Version : fonts and multiple windows



adrien
06-07-2005, 01:17 AM
Hello,
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 ?

Adrien

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 :

m2DFont = ::CreateFont(15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE|DEFAULT_PITCH, _T("Courier New") );

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

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

jide
06-07-2005, 01:31 AM
I think it's because your windows use different DC. But I cannot say more.

Hope that helps.

adrien
06-07-2005, 04:36 AM
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 ?

adrien
06-07-2005, 05:03 AM
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 ?

jide
06-07-2005, 07:12 AM
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.

t3jem
06-07-2005, 02:21 PM
I have found that if you are using display lists in multiple viewports you must define the display list for each window context.

adrien
06-07-2005, 10:49 PM
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())
{
wglMakeCurrent(getNormalDC(),getNormalContext());
}

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

jide
06-08-2005, 12:51 AM
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.