下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、在SDL中显示GBK点阵汉字 大家注意到没有,RA2的中文版本使用的是GBK点阵字库,这样做有一个好处:不管玩家是用的简体还是繁体都能识别显示的文字。 GBK的意思大概是“国家标准汉字扩展字符集”吧,记不清了。但它的确是个好东东,比GB2312、BIG5什么的强多了。因为它包括GB2312、GBK的所有字符而且还补充了很多字,另外,还包括日文、朝鲜文以及大量的符号字符。 我在UCDOS for win版本里面找到了GBK的点阵字库(HZK12.GBK、HZK14.GBK、HZK16.GBK)。分析了一下,知道了结构。这里是我写的一个演示程序,程序编
2、译需要有sdl库。遵循“惯例”,按F4切换全屏/窗口状态,Esc退出。程序把标准输出和标准错误重定向到"stdout.txt"和"stderr.txt"中。 #include time.h> #include stdio.h> #include stdlib.h> #include string.h>#include "SDL.h" #include "SDL_image.h" /- #define STDOUT_FILE "stdout.txt" #define STD
3、ERR_FILE "stderr.txt" SDL_Surface *screen; Uint32 fps; Uint32 AppStartTime = 0; Uint32 frame_count = 0; static Uint32 frames; SDL_Event event; SDL_Surface * SetMode( int Width, int Height, int BPP, int Flags ); SDL_Surface * LoadBMP( char * filename ); void MainLoops( int ( * EventFunc)( )
4、, void ( * DrawFunc )( ), int DelayTime ); void Blt( SDL_Surface * image, int x, int y ); void TileBlt( SDL_Surface * image, int x, int y ); void SetTransparentColor( SDL_Surface * sprite, int R, int G, int B ); void IoRedirect( ); void cleanup_output( ); void initfps(); /- Uint8 HZK12574560; Uint8
5、HZK16766080; bool HZ_Init(); bool HZ_TextOut( SDL_Surface * image, int x, int y, int width, int space, const char * str ); /- int ProcessEvent( ); void DrawFrame( ); SDL_Surface * bg, * font; int ix, iy, jx, jy; int Width = 640; int Height = 480; int bpp = 16; int ScreenMode = 0; int main() char Tim
6、eString256; time_t timer; struct tm *tblock; HZ_Init(); frames = 0; timer = time(NULL); tblock = localtime(&timer); strftime( TimeString, 256, "Time=%Z: %Y-%m-%d %a %H:%M:%S", tblock ); printf( "%sn", TimeString ); SetMode( Width, Height, bpp, SDL_SWSURFACE|ScreenMode ); SDL_
7、ShowCursor(0); SDL_WM_SetCaption( "demo", "demo" ); bg = IMG_Load( "2k_bg.jpg" ); ix=iy=0; jx=jy= Height>>1; srand( (Uint32)timer ); MainLoops( ProcessEvent, DrawFrame, 0 ); printf( "ScreenMode=%d*%d*%dnFPS=%u", Width, Height, bpp, fps ); return 0; int P
8、rocessEvent( ) Uint8 *keystate; keystate = SDL_GetKeyState( NULL ); if ( ( keystateSDLK_ESCAPE ) | ( keystateSDLK_q ) ) return 0; return 1; void DrawFrame( ) char tmp256; int step = 4; / sprintf( tmp, "TotalFrame=%u", frames ); TileBlt( bg, 0, 0 ); if ( rand( ) % 400 < 2 ) jx = rand( )
9、% ( Width - 10 ); jy = rand( ) % ( Height - 10 ); sprintf( tmp, "FPS=%d", fps ); HZ_TextOut( screen, 10, 300, 12, 0, "正面面板"); HZ_TextOut( screen, 10, 318, 12, 0, "电子对抗显示" ); HZ_TextOut( screen, 10, 334, 12, 0, "陈青山" ); HZ_TextOut( screen , 10, 380, 12, 0, &quo
10、t;高度表 ");ix += step; iy += step; /- /- SDL_Surface * SetMode( int Width, int Height, int BPP, int Flags ) /* Initialize the SDL library */ if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) fprintf(stderr, "Couldn't initialize SDL: %sn", SDL_GetError( ) ); return NULL; /* Clean up on exit *
11、/ atexit(SDL_Quit); /* Initialize the display in a 640x480 8-bit palettized mode */ screen = SDL_SetVideoMode( Width, Height, BPP, Flags ); if ( screen = NULL ) fprintf( stderr, "Couldn't set %dx%dx%d video mode: %sn", Width, Height, BPP, SDL_GetError( ) ); return screen; /- void initfps( ) AppStartTime = SDL_GetTicks(); frame_count = 0; /- void MainLoops( int ( * EventFunc)( ), void ( * DrawFunc)( ), int DelayTime
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025云南世博元阳哈尼梯田文化旅游开发有限责任公司人才招聘招37人笔试历年参考题库附带答案详解
- 2025中国西电集团西安西电电力系统有限公司招聘笔试历年参考题库附带答案详解
- 2026 六年级下册美术《画波浪形小河流》课件
- 2026 一年级上册语文《拼拼音小火车》课件
- 2026九年级道德与法治上册 民族振兴使命
- 2026三年级下《两位数乘两位数》知识点梳理
- 废机油回收利用合同协议合同
- 消防栓日常检查与维护
- 班次轮换排班优化方案
- 施工临电设备维护保障方案
- T-ZGCMCA 007-2024 国家工业互联网大数据中心体系 产业链编码规则
- 淋浴器安装施工方案
- 2025年陕西省中考化学试卷真题(含答案)
- DB32/T 3582-2019水运工程水泥土搅拌桩复合地基质量检测及评定规程
- DB37-T2118-2025高温熔融金属道路运输安全技术要求
- 常见的逻辑谬误分析试题及答案
- 商铺租赁协议
- 钢结构墙板拆除施工方案
- 第十一章-中国古代史学课件
- 全国统一市政工程预算定额
- 智能可穿戴服装研究
评论
0/150
提交评论