outline font flips my normals

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 14, 2003 at 13:35

i use outline fonts to display 3d text,
the second they show , all other objects on screen have their normals flipped!
any suggestions?

22 Replies

Please log in or register to post a reply.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 14, 2003 at 13:46

a piece of code would be helpful…
anyway, merely displaying text can’t flip the normals of other faces…
maybe it’s a transformation or projection error you do ?

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 14, 2003 at 13:56

here is where i build the font…

GLvoid CObserverDoc::BuildOutLineFont()     // Build Our OutLine Font
{
    
    baseOutLine = glGenLists(256);    // Storage For 256 Characters
    HFONT   oldfont;        // Used For Good House Keeping

    OutLinefont = CreateFont(   -12,    // Height Of Font
   0,    // Width Of Font
   0,    // Angle Of Escapement
   0,    // Orientation Angle
   FW_BOLD,   // Font Weight
   FALSE,       // Italic
   FALSE,       // Underline
   FALSE,       // Strikeout
   ANSI_CHARSET,    // Character Set Identifier
   OUT_TT_PRECIS,   // Output Precision
   CLIP_DEFAULT_PRECIS,     // Clipping Precision
   ANTIALIASED_QUALITY,     // Output Quality
   FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch
   "Arial");   // Font Name

    oldfont = (HFONT)SelectObject(m_hDC, OutLinefont);      // Selects The Font We Created

    wglUseFontOutlines( m_hDC,      // Select The Current DC
   0,    // Starting Character
   255,     // Number Of Display Lists To Build
   baseOutLine,     // Starting Display Lists
   0.0f,    // Deviation From The True Outlines
   0.2f,    // Font Thickness In The Z Direction
   WGL_FONT_POLYGONS,  // Use Polygons, Not Lines
   gmf);    // Address Of Buffer To Recieve Data
    SelectObject(m_hDC, oldfont);       // Selects The Font We Want
    DeleteObject(OutLinefont);      // Delete The Font

}

here is how i print it

GLvoid CObserverDoc::glOutLinePrint(char *text, ...)    // Custom GL "Print" Routine
{
    float length=0;    // Used To Find The Length Of The Text
    char strText[256];      // This will hold our text to display
    va_list argumentPtr;    // This will hold the pointer to the argument list

    // First we need to check if there was even a string given
    if (text == NULL)       // Check if a string was given
 return;   // Don't render anything then

    // First we need to parse the string for arguments given
    // To do this we pass in a va_list variable that is a pointer to the list of arguments.
    // Then we pass in the string that holds all of those arguments.
    va_start(argumentPtr, text);    // Parse the arguments out of the string

    // Then we use a special version of sprintf() that takes a pointer to the argument list.
    // This then does the normal sprintf() functionality.
 vsprintf(strText, text, argumentPtr);  // Now add the arguments into the full string

    va_end(argumentPtr);   // This resets and frees the pointer to the argument list.

    
    for (unsigned int loop=0;loop<(strlen(text));loop++) // Loop To Find Text Length
    {
 length+=gmf[text[loop]].gmfCellIncX;   // Increase Length By Each Characters Width
    }

    glTranslatef(-length/2,0.0f,0.0f);      // Center Our Text On The Screen

    glPushAttrib(GL_LIST_BIT);      // Pushes The Display List Bits
 glListBase(baseOutLine);       // Sets The Base Character to 0
 glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text
    glPopAttrib();     // Pops The Display List Bits
    
}
0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 14, 2003 at 14:08

I’d do this:

glPushMatrix();

// Draw fonts

glPopMatrix();

That might help. If it doesn’t, try pushing and popping other things.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 14, 2003 at 14:29

doesn’t help.
if i comment the print call , all works fine so it has to be related to the printing of the outline font..

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 14, 2003 at 16:47

I didn’t mean to comment the draw fonts. That was just to indicate where it should go. I meant that you should put glPushMatrix()/glPopMatrix() around the font drawing line.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 14, 2003 at 17:10

i know i know.
i wrote it didnt work.
i said thad if i comment the draw fonts parts in my program the normals dont flip,
i thought this info could hint on the problem..

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 14, 2003 at 17:47

what exactly do you mean by flip ? a normal that previously pointed directly to the camera would suddenly face away from it ? i can’t imagine how text drawing could be related to this… check your modelview matrix…
also you might want to use the textured quad aproach for text rendering baldurk described in another thread to maintain platform independence

C24eb7e6aaefba78b94c831ddc7b4d0b
0
donBerto 101 Sep 15, 2003 at 02:57

try drawing all your objects _FIRST_ and call your font display VERY _LAST_

please let us know how that works out.

:yes:

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 15, 2003 at 08:26

nope , doesnt change a thing.
i want to post images to show what happens but i dont know how..
how do i post images??
to anubis- yes its wierd but the normals do flip
i changed the code to flip the normals (they are wrong in the begining)
and when the text appears the normals are right (flipped again)

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 15, 2003 at 09:07

one more thing
if i use wglUseFontOutlines(…,WGL_FONT_LINES,…)
the normals dont flip!
however if i use wglUseFontOutlines(…,WGL_FONT_POLYGONS,…)
the normals do flip

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 15, 2003 at 12:17

confusing… i don’t know… driver bug ???

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 15, 2003 at 13:01

thanks anyway , i think i’ll use bitmap fonts instead

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Sep 15, 2003 at 14:42

it’s better anyway… it gives you more freedom about how your fonts will look like

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 15, 2003 at 17:29

here is the topic anubis was talking about.

Fdbdc4176840d77fe6a8deca457595ab
0
dk 158 Sep 15, 2003 at 19:45

Textured fonts are proven to be faster though.
But bitmapped fonts are easier to use (at least in OpenGL).

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Sep 15, 2003 at 19:58

uhm, textured fonts are more easy imho.. if you wanna be crossplatform, that is:D

Edbb71790dd1151f9c1ff5d4eb6a856d
0
Disem 101 May 03, 2004 at 06:10

@urika

one more thing
if i use wglUseFontOutlines(…,WGL_FONT_LINES,…)
the normals dont flip!
however if i use wglUseFontOutlines(…,WGL_FONT_POLYGONS,…)
the normals do flip

I have run into a similar problem, where WGL_FONT_LINES works and displays the text in lines, without skewing anything. But if I use WGL_FONT_POLYGONS, the normals are skewed. Pushing and popping the matrixes have no effect. Any suggestions?

4ceb0567c621312534e637b3e5fae02a
0
Dwondong 101 Jan 16, 2005 at 08:23

@urika

how do i post images??
[snapback]4645[/snapback]

Just go somewhere like IMGme and upload your pic. then it gives you a forum code that you can just copy n paste into your posts.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Jan 16, 2005 at 09:28

dude… this thread is from 2003… what makes you think that your post has relevance here ?

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Jan 16, 2005 at 15:04

This thread has been resurrected twice now.

I’m tempted to close it so that it isn’t resurrected a third time :/.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Jan 16, 2005 at 16:22

we need an automated check for this. if the last post in a thread is older than a certain amount of time a warning message is given before the post is actually made

63d20945c926ff514343e72835dcadb9
0
void_crusader 101 Apr 25, 2007 at 03:51

Old topic, I know, but nobodys have correct answer and considering I stumbled into this, there is a chance it can be useful for someone else.

So, the problem is there is phuckin

glFrontFace(GL_CW)

in DL generated by wglUseFontOutlines. Don’t even ask how I come up with this.

So, to restore it to default just use glFrontFace(GL_CCW) and you are good to go.

Folks at MS have teh overdeveloped sense of humor, heh?