#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include "PVRShell.h"
#include "PVRShellAPI.h"
using namespace std;
//注意,编译器的搜索路径中必须包括 FTGL freetype两个文件夹
//而且附加库中也要有ftgl和freetype两个库才行
//工程属性中添加ftgl_dynamic_MTD_d.lib(Debug版本)或者ftgl_dynamic_MTD.lib(Release版本)
#include <ftgles.h>
#include <FTGLPixmapFont.h>
FTGLPixmapFont *freeTypeFont = NULL;
void init(void)
{
//FTGL初始化
char filePath[256]={0};
sprintf(filePath, "C:\\WINDOWS\\Fonts\\SIMKAI.TTF");
freeTypeFont = new FTGLPixmapFont(filePath);
if(freeTypeFont == NULL)
{
char buf[] = "Font C:\\WINDOWS\\Fonts\\simhei.ttf can not be fond.\r\n";
printf("%s", buf);
exit(0);
}
else
{
freeTypeFont->FaceSize(72); // 必须
}
return;
}
wchar_t str[128]=L"景色真是不错。。。";
class CLesson2 : public PVRShell
{
public:
virtual bool InitApplication();
virtual bool InitView();
virtual bool ReleaseView();
virtual bool QuitApplication();
virtual bool RenderScene();
};
bool CLesson2::InitApplication()
{
return true;
}
bool CLesson2::QuitApplication()
{
return true;
}
bool CLesson2::InitView()
{
glEnable(GL_TEXTURE_2D);
init();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0,PVRShellGet(prefWidth),-PVRShellGet(prefHeight)/2,PVRShellGet(prefHeight) / 2,0,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return true;
}
bool CLesson2::ReleaseView()
{
return true;
}
PVRShell * NewDemo(void)
{
return new CLesson2();
}
bool CLesson2::RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
freeTypeFont->Render(str);
return true;
}
(cr0_3) |