PDA

View Full Version : outline font flips my normals


urika
09-14-2003, 07:35 AM
i use outline fonts to display 3d text,
the second they show , all other objects on screen have their normals flipped!
any suggestions?

anubis
09-14-2003, 07:46 AM
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 ?

urika
09-14-2003, 07:56 AM
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

}

baldurk
09-14-2003, 08:08 AM
I'd do this:


glPushMatrix();

// Draw fonts

glPopMatrix();


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

urika
09-14-2003, 08:29 AM
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..

baldurk
09-14-2003, 10:47 AM
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.

urika
09-14-2003, 11:10 AM
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..

anubis
09-14-2003, 11:47 AM
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

donBerto
09-14-2003, 08:57 PM
try drawing all your objects _FIRST_ and call your font display VERY _LAST_


please let us know how that works out.

:yes:

urika
09-15-2003, 02:26 AM
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)

urika
09-15-2003, 03:07 AM
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

anubis
09-15-2003, 06:17 AM
confusing... i don't know... driver bug ???

urika
09-15-2003, 07:01 AM
thanks anyway , i think i'll use bitmap fonts instead

anubis
09-15-2003, 08:42 AM
it's better anyway... it gives you more freedom about how your fonts will look like

baldurk
09-15-2003, 11:29 AM
here (http://www.devmaster.net/forums/index.php?showtopic=500) is the topic anubis was talking about.

Dia Kharrat
09-15-2003, 01:45 PM
Textured fonts are proven to be faster though.
But bitmapped fonts are easier to use (at least in OpenGL).

davepermen
09-15-2003, 01:58 PM
uhm, textured fonts are more easy imho.. if you wanna be crossplatform, that is:D

Disem
05-03-2004, 12:10 AM
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?

Dwondong
01-16-2005, 01:23 AM
how do i post images??

4645


Just go somewhere like IMGme (http://www.imgme.com) and upload your pic. then it gives you a forum code that you can just copy n paste into your posts.

anubis
01-16-2005, 02:28 AM
dude... this thread is from 2003... what makes you think that your post has relevance here ?

baldurk
01-16-2005, 08:04 AM
This thread has been resurrected twice now.

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

anubis
01-16-2005, 09:22 AM
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

void.crusader
04-24-2007, 09:51 PM
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?