成员变量区:GLuintbase;GLfloatcnt1;GLfloatcnt2; 成员函数区:GLvoidCOpenGLDemoView::glPrint(constchar*fmt,)//CustomGL"Print"Routine{chartext[256];//HoldsOurStringva_listap;//PointerToListOfArgumentsif(fmt==NULL)//IfThere'sNoTextreturn;//DoNothingva_start(ap,fmt);//ParsesTheStringForVariablesvsprintf(text,fmt,ap);//AndConvertsSymbolsToActualNumbersva_end(ap);//ResultsAreStoredInTextglPushAttrib(GL_LIST_BIT);//PushesTheDisplayListBitsglListBase(base);//SetsTheBaseCharacterto32glCallLists(strlen(text),GL_UNSIGNED_BYTE,text);//DrawsTheDisplayListTextglPopAttrib();//PopsTheDisplayListBits}GLvoidCOpenGLDemoView::BuildFont(GLvoid){HFONTfont;//WindowsFontIDHFONToldfont;//UsedForGoodHouseKeepingbase=glGenLists(96);//StorageFor96Charactersfont=CreateFont(-24,//HeightOfFont0,//WidthOfFont0,//AngleOfEscapement0,//OrientationAngleFW_BOLD,//FontWeightFALSE,//ItalicFALSE,//UnderlineFALSE,//StrikeoutANSI_CHARSET,//CharacterSetIdentifierOUT_TT_PRECIS,//OutputPrecisionCLIP_DEFAULT_PRECIS,//ClippingPrecisionANTIALIASED_QUALITY,//OutputQualityFF_DONTCARE|DEFAULT_PITCH,//FamilyAndPitch"CourierNew");//FontNameHDChDC=::GetDC(this->m_hWnd);oldfont=(HFONT)SelectObject(hDC,font);//SelectsTheFontWeWantwglUseFontBitmaps(hDC,0,255,base);//Builds96CharactersStartingAtCharacter32SelectObject(hDC,oldfont);//SelectsTheFontWeWantDeleteObject(font);//DeleteTheFont}GLvoidCOpenGLDemoView::KillFont(GLvoid){glDeleteLists(base,96);}GLvoidCOpenGLDemoView::KillFont(GLvoid){glDeleteLists(base,96);}intCOpenGLDemoView::DrawGLScene(){//Here'sWhereWeDoAllTheDrawingglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//ClearScreenAndDepthBufferglLoadIdentity();//ResetTheCurrentModelviewMatrixglTranslatef(0.0f,0.0f,-1.0f);//MoveOneUnitIntoTheScreen//PulsingColorsBasedOnTextPositionglColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));//PositionTheTextOnTheScreenglRasterPos2f(-0.45f+0.05f*float(cos(cnt1)),0.32f*float(sin(cnt2)));glPrint("ActiveOpenGLText-%7.2f",cnt1);//PrintGLTextToTheScreencnt1+=0.051f;//IncreaseTheFirstCountercnt2+=0.005f;//IncreaseTheFirstCounterreturnTRUE;//EverythingWentOK//EverythingWentOK}