随笔 - 96  文章 - 255  trackbacks - 0
<2008年3月>
2425262728291
2345678
9101112131415
16171819202122
23242526272829
303112345

E-mail:zbln426@163.com QQ:85132383 长期寻找对战略游戏感兴趣的合作伙伴。

常用链接

留言簿(21)

随笔分类

随笔档案

SDL相关网站

我的个人网页

我的小游戏

资源下载

搜索

  •  

积分与排名

  • 积分 - 485062
  • 排名 - 37

最新评论

阅读排行榜

评论排行榜

Windows only. Linux needn't.

//UVi Soft ( 2008 )
//Long Fei ( lf426 ), E-mail: zbln426@163.com
//Laboratory of ZaiBieLiunNian
//http://www.cppblog.com/lf426/

//FileName: SDL_render_Chinese.h
//For Windows only

#ifndef RENDER_CHINESE_H
#define RENDER_CHINESE_H

#include 
"gb2312_to_Unicode.h"
#include 
"SDL/SDL_ttf.h"

SDL_Surface
* myTTF_RenderString_Blended(TTF_Font* font, const std::string& str, SDL_Color fg);
SDL_Surface
* myTTF_RenderString_Solid(TTF_Font* font, const std::string& str, SDL_Color fg);
SDL_Surface
* myTTF_RenderString_Shaded(TTF_Font* font, const std::string& str, SDL_Color fg, SDL_Color bg);

#endif

//UVi Soft ( 2008 )
//Long Fei ( lf426 ), E-mail: zbln426@163.com
//Laboratory of ZaiBieLiunNian
//http://www.cppblog.com/lf426/

//FileName: SDL_render_Chinese.cpp
//For Windows only

#include 
"SDL_render_Chinese.h"

SDL_Surface
* myTTF_RenderString_Blended(TTF_Font* font, const std::string& str, SDL_Color fg)
{
    SDL_Surface
* textbuf;
    
//Get Unicode
    std::vector<Uint16> unicodeUnit;
    
if ( getUnicode(str, unicodeUnit) == false )
        
return 0;
    
int arraySize = unicodeUnit.size();
    Uint16
* perOne = new Uint16[arraySize+1];
    
for ( int i = 0; i < arraySize; i++ )
        perOne[i] 
= unicodeUnit[i];
    perOne[arraySize] 
= 0;

    
    
//Render the new text
    textbuf = TTF_RenderUNICODE_Blended(font, perOne, fg);

    
//Free the text buffer and return
    delete [] perOne;
    
return textbuf;
}

SDL_Surface
* myTTF_RenderString_Solid(TTF_Font* font, const std::string& str, SDL_Color fg)
{
    SDL_Surface
* textbuf;
    
//Get Unicode
    std::vector<Uint16> unicodeUnit;
    
if ( getUnicode(str, unicodeUnit) == false )
        
return 0;
    
int arraySize = unicodeUnit.size();
    Uint16
* perOne = new Uint16[arraySize+1];
    
for ( int i = 0; i < arraySize; i++ )
        perOne[i] 
= unicodeUnit[i];
    perOne[arraySize] 
= 0;

    
    
//Render the new text
    textbuf = TTF_RenderUNICODE_Solid(font, perOne, fg);

    
//Free the text buffer and return
    delete [] perOne;
    
return textbuf;
}

SDL_Surface
* myTTF_RenderString_Shaded(TTF_Font* font, const std::string& str, SDL_Color fg, SDL_Color bg)
{
    SDL_Surface
* textbuf;
    
//Get Unicode
    std::vector<Uint16> unicodeUnit;
    
if ( getUnicode(str, unicodeUnit) == false )
        
return 0;
    
int arraySize = unicodeUnit.size();
    Uint16
* perOne = new Uint16[arraySize+1];
    
for ( int i = 0; i < arraySize; i++ )
        perOne[i] 
= unicodeUnit[i];
    perOne[arraySize] 
= 0;

    
    
//Render the new text
    textbuf = TTF_RenderUNICODE_Shaded(font, perOne, fg, bg);

    
//Free the text buffer and return
    delete [] perOne;
    
return textbuf;
}

lib: iconv.lib
     SDL_ttf.lib
     SDL.lib, SDLmain.lib

dll: iconv.dll
     SDL_ttf.dll, libfreetype-6.dll, zlib1.dll
     SDL.dll

last update: 2008-05-12
posted on 2008-04-14 13:24 lf426 阅读(1482) 评论(0)  编辑 收藏 引用 所属分类: mySDL_GameEngine

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理