Click here to Skip to main content
15,900,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSending string (text or array of character) trough a socket-connection. Pin
SimCom5-Jan-05 9:22
SimCom5-Jan-05 9:22 
GeneralRe: Sending string (text or array of character) trough a socket-connection. Pin
Ravi Bhavnani5-Jan-05 10:13
professionalRavi Bhavnani5-Jan-05 10:13 
GeneralRe: Sending string (text or array of character) trough a socket-connection. Pin
SimCom5-Jan-05 23:55
SimCom5-Jan-05 23:55 
GeneralClass Confusion Pin
whitee5-Jan-05 7:57
whitee5-Jan-05 7:57 
GeneralRe: Class Confusion Pin
Gerald Schwab5-Jan-05 8:49
Gerald Schwab5-Jan-05 8:49 
GeneralDrawing rectangles, lines and arcs in directx Pin
SteQve5-Jan-05 7:51
SteQve5-Jan-05 7:51 
GeneralOpenGL question : wglUseFontBitmaps and glGenLists Pin
Maximilien5-Jan-05 4:55
Maximilien5-Jan-05 4:55 
GeneralRe: OpenGL question : wglUseFontBitmaps and glGenLists Pin
El Corazon5-Jan-05 7:03
El Corazon5-Jan-05 7:03 
Maximilien wrote:
1 - When using glGenLists to generate a number of empty display lists ( to be filled by wglUseFontBitmaps ), it returns the number (ID?) of the first display list ? so, should the argument to glListBase be ID + someArbitraryValue ? or will this be done automatically ?

What is actually happening is that the glListBase(n) is setting the base of the next set of calls to n. In your case your Display list base index for your font. the function glCallLists() will generate one call per ascii value, thus you generate a full 256 count for your font. But the actual call is the combination of the last glListBase(n) adding the ascii value from the glCallLists() for each character.


Maximilien wrote:
2- When using wglUseFontBitmaps, do I need to do something else if I want to recreate the display lists for a different font size ? can I reuse the same "font bitmaps" ?

I have 3 different font selections in my program. Remember that the callLists is the sum of the base plus the ascii value. So you allocate a new set of 256 lists, I would suggest switching to an index variable name that reflects the font so you don't get confused.

However, remember that your driver may handle display lists in system memory or compiled and stored on the graphics card. You are generating 256 bitmap image display lists for every font. If you want to have multiple fonts on the screen at the same time, you will need three different sets of display lists. If you want the user to choose his font, do so ahead of building the font, and generate only one from the user definition. Don't use more memory than you need to. You can also cheat, make sure the text is in 7bit form (0-127 ASCII) and only generate 128 display lists. If you do, don't forget to check the string or you will get unknown results for any >127 values.

I rewrote this code as I pasted to remove some "stuff" hope it helps. You can also look into texture based fonts which may be much faster on some hardware. Google for OpenGL tutorials at "Nehe" and you will find text tutorials.

<br />
int             BuildFont(char *fontname, int point, int bold)<br />
{<br />
  GLint           base;<br />
  HFONT__        *font;<br />
  struct HDC__   *h_DC;<br />
<br />
  base = glGenLists(256);<br />
  font = CreateFont(point,            // Height Of Font<br />
                    0,                 // Width Of Font<br />
                    0,                 // Angle Of Escapement<br />
                    0,                 // Orientation Angle<br />
                    bold ? FW_BOLD : FW_NORMAL, // Font Weight<br />
                    0,                 // Italic<br />
                    0,                 // Underline<br />
                    0,                 // Strikeout<br />
                    ANSI_CHARSET,      // Character Set Identifier<br />
                    OUT_TT_PRECIS,     // Output Precision<br />
                    CLIP_DEFAULT_PRECIS,  // Clipping Precision<br />
                    ANTIALIASED_QUALITY,  // Output Quality<br />
                    FIXED_PITCH,     // Family And Pitch<br />
                    fontname);         // Font Name<br />
<br />
  h_DC = GetDC(NULL);<br />
  SelectObject(h_DC, font);            // Selects The Font We Want<br />
<br />
  wglUseFontBitmaps(h_DC, 0, 256, base);  // Builds 256 Characters for font<br />
  return base;<br />
}<br />
  m_LargeTextBase = BuildFont("Arial Bold", LargeTextPitch, LargeTextBold);<br />
  m_SmallTextBase = BuildFont("Arial Bold", SmallTextPitch, SmallTextBold);<br />
  m_MediumTextBase = BuildFont("Arial Bold", MediumTextPitch, MediumTextBold);<br />
...<br />
  glListBase(m_SmallTextBase );<br />
  glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);<br />
...<br />
  glListBase(m_MediumTextBase);<br />
  glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);<br />
...<br />
  glListBase(m_LargeTextBase);<br />
  glCallLists(strlen(string), GL_UNSIGNED_BYTE, string);<br />
<br />


_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
GeneralRe: OpenGL question : wglUseFontBitmaps and glGenLists Pin
Maximilien5-Jan-05 7:21
Maximilien5-Jan-05 7:21 
GeneralFrom C to C++ Pointer Pin
jw815-Jan-05 4:55
jw815-Jan-05 4:55 
GeneralRe: From C to C++ Pointer Pin
David Crow5-Jan-05 5:24
David Crow5-Jan-05 5:24 
GeneralRe: From C to C++ Pointer Pin
jw815-Jan-05 5:26
jw815-Jan-05 5:26 
GeneralRe: From C to C++ Pointer Pin
David Crow5-Jan-05 5:54
David Crow5-Jan-05 5:54 
GeneralRe: From C to C++ Pointer Pin
jw815-Jan-05 15:38
jw815-Jan-05 15:38 
GeneralRe: From C to C++ Pointer Pin
Maximilien5-Jan-05 16:14
Maximilien5-Jan-05 16:14 
GeneralRe: From C to C++ Pointer Pin
jw815-Jan-05 17:16
jw815-Jan-05 17:16 
GeneralRe: From C to C++ Pointer Pin
ThatsAlok5-Jan-05 22:05
ThatsAlok5-Jan-05 22:05 
GeneralRe: From C to C++ Pointer Pin
Maximilien5-Jan-05 5:43
Maximilien5-Jan-05 5:43 
GeneralRe: How to draw static controls and check box buttons transparently ? Pin
rrrado5-Jan-05 3:41
rrrado5-Jan-05 3:41 
GeneralRe: How to draw static controls and check box buttons transparently ? Pin
YoSilver7-Jan-05 0:35
YoSilver7-Jan-05 0:35 
GeneralRe: How to draw static controls and check box buttons transparently ? Pin
rrrado11-Jan-05 4:04
rrrado11-Jan-05 4:04 
GeneralRe: How to draw static controls and check box buttons transparently ? Pin
YoSilver11-Jan-05 6:35
YoSilver11-Jan-05 6:35 
GeneralAccessing Large CMapStringToString's inside Critical Sections Pin
MJWhiteman25-Jan-05 2:56
MJWhiteman25-Jan-05 2:56 
GeneralRe: Accessing Large CMapStringToString's inside Critical Sections Pin
basementman5-Jan-05 4:38
basementman5-Jan-05 4:38 
GeneralCritical Sections Pin
MJWhiteman25-Jan-05 2:47
MJWhiteman25-Jan-05 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.