資源簡介
C++用opengl繪制出的二維坐標,簡單明了,很容易理解,并且各個部分均有注釋
代碼片段和文件信息
//GLfont.cpp:?implementation?of?the?GLfont?class.
//
//////////////////////////////////////////////////////////////////////
#include?“GLfont.h“
#include?“gl/gl.h“
#include?“stdio.h“
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
GLfont::GLfont()
{??????????????
LOGFONT?lf;
lf.lfHeight?=?12;
lf.lfWidth?=?0;???????
lf.lfEscapement?=?0;??
lf.lfOrientation?=?0;?
lf.lfWeight?=?FW_DONTCARE;
lf.lfItalic?=?false;
lf.lfUnderline?=?false;
lf.lfStrikeOut?=?false;
lf.lfCharSet?=?DEFAULT_CHARSET;
lf.lfOutPrecision?=?OUT_TT_PRECIS;?
lf.lfClipPrecision?=?CLIP_DEFAULT_PRECIS;?
lf.lfQuality?=?PROOF_QUALITY;?
lf.lfPitchAndFamily?=?VARIABLE_PITCH?|?TMPF_TRUETYPE?|?FF_MODERN;?
strcpy(lf.lfFaceName“宋體“);
//?創建字體
m_hFont?=?CreateFontIndirect(&lf);
}
GLfont::~GLfont()
{
if(m_hFont)?Deleteobject(m_hFont);??
glDeleteLists(base?96);
}?
void?GLfont::BuildEnglishFont(HDC?hDCint?size) //?Build?Our?Bitmap?Font
{
HFONT font; ? //?Windows?Font?ID
HFONT oldfont;? //?Used?For?Good?House?Keeping
base?=?glGenLists(96);? //?Storage?For?96?Characters
font?=?::CreateFont(-size???????? //?Height?Of?Font
????????????????0 //?Width?Of?Font
????????????????0 //?Angle?Of?Escapement
????????????????0 //?Orientation?Angle
????????????????FW_DONTCARE //?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(hDC?font);???????????//?Selects?The?Font?We?Want
wglUseFontBitmaps(hDC?32?96?base); //?Builds?96?Characters?Starting?At?Character?32
Selectobject(hDC?oldfont); //?Selects?The?Font?We?Want
Deleteobject(font); //?Delete?The?Font
}
void?GLfont::glPrintEnglish(float?xfloat?yfloat?rfloat?gfloat?bconst?char?*fmt?...) //?Custom?GL?“Print“?Routine
{????????????????????
????????glDisable(GL_LIGHTING);
????????glDisable(GL_TEXTURE);
????????glMatrixMode(GL_MODELVIEW);
????????glPushMatrix();
????????glLoadIdentity();
char text[256];?? //?Holds?Our?String
va_list ap; //?Pointer?To?List?Of?Arguments
if?(fmt?==?NULL) ???????? //?If?There‘s?No?Text
return; //?Do?Nothing
va_start(ap?fmt); ????? //?Parses?The?String?For?Variables
????vsprintf(text?fmt?ap);?? //?And?Converts?Symbols?To?Actual?Numbers
va_end(ap); //?Results?Are?Stored?In?Text
glPushAttrib(GL_LIST_BIT);???? //?Pushes?The?Display?List?Bits
glListbase(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-03-25?14:02??openGL~~\
?????目錄???????????0??2013-03-25?14:02??openGL~~\Debug\
?????文件???????48128??2013-03-24?11:59??openGL~~\Debug\openGL.exe
?????文件??????455548??2013-03-24?11:59??openGL~~\Debug\openGL.ilk
?????文件??????494592??2013-03-24?11:59??openGL~~\Debug\openGL.pdb
?????目錄???????????0??2013-03-25?14:02??openGL~~\ipch\
?????目錄???????????0??2013-03-25?14:02??openGL~~\ipch\opengl-11ef6804\
?????文件????33816576??2013-03-24?11:07??openGL~~\ipch\opengl-11ef6804\opengl-bcb87db1.ipch
?????目錄???????????0??2013-03-25?14:02??openGL~~\openGL\
?????目錄???????????0??2013-03-25?14:02??openGL~~\openGL\Debug\
?????文件???????24618??2013-03-24?11:59??openGL~~\openGL\Debug\CL.read.1.tlog
?????文件????????1178??2013-03-24?11:59??openGL~~\openGL\Debug\CL.write.1.tlog
?????文件????????1330??2013-03-24?11:59??openGL~~\openGL\Debug\cl.command.1.tlog
?????文件???????37836??2013-03-24?11:59??openGL~~\openGL\Debug\glFont.obj
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
?????文件???????????2??2013-03-24?11:59??openGL~~\openGL\Debug\li
............此處省略28個文件信息
評論
共有 條評論