成员变量区:
GLuintbase;
GLfloatcnt1;
GLfloatcnt2;
成员函数区:
GLvoidCOpenGLDemoView::glPrint(constchar*fmt,
)//CustomGL"Print"Routine

{
chartext[256];//HoldsOurString
va_listap;//PointerToListOfArguments
if(fmt==NULL)//IfThere'sNoText
return;//DoNothing
va_start(ap,fmt);//ParsesTheStringForVariables
vsprintf(text,fmt,ap);//AndConvertsSymbolsToActualNumbers
va_end(ap);//ResultsAreStoredInText
glPushAttrib(GL_LIST_BIT);//PushesTheDisplayListBits
glListBase(base);//SetsTheBaseCharacterto32
glCallLists(strlen(text),GL_UNSIGNED_BYTE,text);//DrawsTheDisplayListText
glPopAttrib();//PopsTheDisplayListBits
}
GLvoidCOpenGLDemoView::BuildFont(GLvoid)

{
HFONTfont;//WindowsFontID
HFONToldfont;//UsedForGoodHouseKeeping
base=glGenLists(96);//StorageFor96Characters
font=CreateFont(-24,//HeightOfFont
0,//WidthOfFont
0,//AngleOfEscapement
0,//OrientationAngle
FW_BOLD,//FontWeight
FALSE,//Italic
FALSE,//Underline
FALSE,//Strikeout
ANSI_CHARSET,//CharacterSetIdentifier
OUT_TT_PRECIS,//OutputPrecision
CLIP_DEFAULT_PRECIS,//ClippingPrecision
ANTIALIASED_QUALITY,//OutputQuality
FF_DONTCARE|DEFAULT_PITCH,//FamilyAndPitch
"CourierNew");//FontName
HDChDC=::GetDC(this->m_hWnd);
oldfont=(HFONT)SelectObject(hDC,font);//SelectsTheFontWeWant
wglUseFontBitmaps(hDC,0,255,base);//Builds96CharactersStartingAtCharacter32
SelectObject(hDC,oldfont);//SelectsTheFontWeWant
DeleteObject(font);//DeleteTheFont
}
GLvoidCOpenGLDemoView::KillFont(GLvoid)

{
glDeleteLists(base,96);
}
GLvoidCOpenGLDemoView::KillFont(GLvoid)

{
glDeleteLists(base,96);
}
intCOpenGLDemoView::DrawGLScene()

{//Here'sWhereWeDoAllTheDrawing
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//ClearScreenAndDepthBuffer
glLoadIdentity();//ResetTheCurrentModelviewMatrix
glTranslatef(0.0f,0.0f,-1.0f);//MoveOneUnitIntoTheScreen
//PulsingColorsBasedOnTextPosition
glColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));
//PositionTheTextOnTheScreen
glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)),0.32f*float(sin(cnt2)));
glPrint("ActiveOpenGLText-%7.2f",cnt1);//PrintGLTextToTheScreen
cnt1+=0.051f;//IncreaseTheFirstCounter
cnt2+=0.005f;//IncreaseTheFirstCounter
returnTRUE;//EverythingWentOK
//EverythingWentOK
}
4439

被折叠的 条评论
为什么被折叠?



