织梦CMS - 轻松建站从此开始!

罗索

opengles ftgl demo

落鹤生 发布于 2012-03-15 09:35 点击:次 
编译器的搜索路径中必须包括 FTGL freetype两个文件夹,而且附加库中也要有ftgl和freetype两个库才行,工程属性中添加ftgl_dynamic_MTD_d.lib(Debug版本)或者ftgl_dynamic_MTD.lib(Release版本)
TAG:

#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)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201203/15830.html]
本文出处:百度博客 作者:cr0_3 原文
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容