dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Fonti

 
dev.gamez.lv Forum Index -> OpenGL
View previous topic :: View next topic  
Author Message
Angel



Joined: 02 Jan 2005
Posts: 113
Location: Latvija

PostPosted: Tue Feb 22, 2005 6:35 pm    Post subject: Fonti

Nez, kaapeez, (fonti pielaagoti no tutorial(laikam NeHe)) raada visaadas mulkiibas.... te kods:
Code:

UINT CFont2D::CreateGLFont(LPSTR strFontName, int height)
{
   UINT   fontListID   = 0;
   HFONT   hFont;
   font_Height = height;
   
   fontListID = glGenLists(MAX_CHARS);

   hFont = CreateFont(   height,            // Desired Height Of Font
                  0,               // The Width
                  0,               // Angle Of Escapement
                  0,               // Angle Of Orientation
                  FW_BOLD,         // Fonts Weight
                  false,            // Italic
                  false,            // Underline
                  false,            // StrikeOut
                  ANSI_CHARSET,      // Character Set
                  OUT_TT_PRECIS,      // Output Precision
                  CLIP_DEFAULT_PRECIS,// Clipping Precision
                  ANTIALIASED_QUALITY,// Quality Of The Font
                  FF_DONTCARE |
                  DEFAULT_PITCH,
                  strFontName);      // Font name

   hOldFont = (HFONT)SelectObject(window.hDC,hFont);
   
   // Build 255 Bitmaps
   wglUseFontBitmaps(window.hDC,0,MAX_CHARS-1,fontListID);

   return fontListID;                  // Return the ID Of Font For Later Use
}

void CFont2D::PositionText(int x, int y)
{
   glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );

   // Set Matrix To Projection Matrix And Push It
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();

   // Set Matrix To Modelview Matrix And Push It
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity();

   y = window.app.height - font_Height - y;

   glViewport(x-1,y-1,0,0);

   glRasterPos4f(0,0,0,1);

   glPopMatrix();
   glMatrixMode(GL_PROJECTION);
   glPopMatrix();

   glPopAttrib();
}

void CFont2D::DrawText(int x, int y,   const char *strString, ...)
{
   char   strText[256];                  // Hold Text To Display
   va_list   argumentPtr;                  // Hold A Pointer To The Argument List

   // Check If strString Have Any Text To Display
   if (strString==NULL) return;

   va_start(argumentPtr,strString);         // Parse Argument Out Of String

   vsprintf(strText,strString,argumentPtr);   // Now Add Arguments Into String

   va_end(argumentPtr);

   // Befor Draw Position Text
   PositionText(x,y);

   // Save List Base info
   glPushAttrib(GL_LIST_BIT);

   // Set List Base
   glListBase(FontListID);

   glCallLists(strlen(strText), GL_UNSIGNED_BYTE, strText);

   glPopAttrib();                        // Return the display list back to it's previous state
}

void CFont2D::DestroyFont()
{

   glDeleteLists(FontListID,MAX_CHARS);      // Free Display Lists
   SelectObject(window.hDC,hOldFont);
}

Taa es vinu Inicializeeju:
Code:

   font2d.CreateGLFont("ARIAL",16);

Un te vinsh staav ieksh render scene:
Code:

int sInit::DrawGLScene()   
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
   font2d.DrawText(0,0,"Current FPS:&d",(int)timer.getFPS());
   glLoadIdentity();

   Camera.Look();

Sorry, ka garsh posts, bet nesaprotu kaapeec neiet. HELP Neutral Neutral :|

Aaaa, te ir tas, ka raadaas:

Bttqqdms[kvadraats]EOR9%c
Back to top
View user's profile Send e-mail
Display posts from previous:   
dev.gamez.lv Forum Index -> OpenGL All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group