wgl font on Windows (+MFC)

wgl font on Windows (+MFC)

Post by Mickael ABBA » Fri, 15 Jun 2001 05:34:30



Hi !

Is anybody has an idea of why this code doesn't work ?
It seems very strange !

// Begin code - Creation of an OpenGL font
HFONT   font;
BOOL    bReturn;
GLint   base;
base = glGenLists (255);
font = CreateFont(      -100,   // 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
                        ANTIALIASED_QUALITY,    // Output Quality
                        FF_DONTCARE|DEFAULT_PITCH,      //
                        "Courier New");               // Font Name
SelectObject(m_hDC,font);
bReturn=wglUseFontBitmaps(m_hDC, 0, 255, base);         // Builds 96 Characters
Starting
DWORD dwError;
dwError=GetLastError();

// End Code

The code returns:
bReturn = 0;
dwWord = 87  (The parameter is incorrect.)

And, of course, nothing is displayed on the screen (by a rendering
function that works correctly with points, lines and polygons) as:

// Begin rendering function
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     // Clear The Screen
glLoadIdentity();                               // Reset The View

// Position The Text On The Screen
glColor3f(1,1,1);
glRasterPos2f(0,0);

glListBase(base);

glCallLists(5, GL_UNSIGNED_BYTE, "What");

glFlush();

glDrawBuffer(GL_BACK);

Thank you if you have an idea !

 
 
 

wgl font on Windows (+MFC)

Post by Joel Parri » Fri, 15 Jun 2001 06:40:04


You can find a working example of exactly what you are trying to do at my
MFC & OpenGL website.

http://pws.prserv.net/mfcogl/


Quote:> Hi !

> Is anybody has an idea of why this code doesn't work ?
> It seems very strange !

> // Begin code - Creation of an OpenGL font
> HFONT font;
> BOOL bReturn;
> GLint base;
> base = glGenLists (255);
> font = CreateFont( -100, // 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
> ANTIALIASED_QUALITY, // Output Quality
> FF_DONTCARE|DEFAULT_PITCH, //
> "Courier New"); // Font Name
> SelectObject(m_hDC,font);
> bReturn=wglUseFontBitmaps(m_hDC, 0, 255, base); // Builds 96 Characters
> Starting
> DWORD dwError;
> dwError=GetLastError();

> // End Code

> The code returns:
> bReturn = 0;
> dwWord = 87  (The parameter is incorrect.)

> And, of course, nothing is displayed on the screen (by a rendering
> function that works correctly with points, lines and polygons) as:

> // Begin rendering function
> glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen
> glLoadIdentity(); // Reset The View

> // Position The Text On The Screen
> glColor3f(1,1,1);
> glRasterPos2f(0,0);

> glListBase(base);

> glCallLists(5, GL_UNSIGNED_BYTE, "What");

> glFlush();

> glDrawBuffer(GL_BACK);

> Thank you if you have an idea !


 
 
 

wgl font on Windows (+MFC)

Post by Mickael ABBA » Fri, 15 Jun 2001 15:39:28


Quote:> http://pws.prserv.net/mfcogl/

Zip file is not present on the server ;-)))
 
 
 

wgl font on Windows (+MFC)

Post by V-ma » Sat, 16 Jun 2001 05:54:16


From MSDN
HDC    hdc;  // A TrueType font has already been selected HGLRC  hglrc;
GLYPHMETRICSFLOAT agmf[256];
// Make hglrc the calling thread's current rendering context
wglMakeCurrent(hdc, hglrc);
// create display lists for glyphs 0 through 255 with 0.1 extrusion
// and default deviation. The display list numbering starts at 1000
// (it could be any number) wglUseFontOutlines(hdc, 0, 255, 1000, 0.0f,
0.1f,
            WGL_FONT_POLYGONS, &agmf);
// Set up transformation to draw the string glLoadIdentity();
glTranslate(0.0f, 0.0f, -5.0f) glScalef(2.0f, 2.0f, 2.0f);  // Display a
string
glListBase(1000); // Indicates the start of display lists for the glyphs
// Draw the characters in a string
glCallLists(24, GL_UNSIGNED_BYTE, "Hello Win32 OpenGL World.");

Be sure to call glRasterPos every time when you render.

V-man


> > http://pws.prserv.net/mfcogl/

> Zip file is not present on the server ;-)))

 
 
 

wgl font on Windows (+MFC)

Post by Joel Parri » Sat, 16 Jun 2001 06:17:15


Opps, sorry about that and thank you for calling it to my attention.  I
fixed the broken link it should work for you now.

Quote:> > http://pws.prserv.net/mfcogl/

> Zip file is not present on the server ;-)))