




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、在SDL中顯示GBK點陣漢字 大家注意到?jīng)]有,RA2的中文版本使用的是GBK點陣字庫,這樣做有一個好處:不管玩家是用的簡體還是繁體都能識別顯示的文字。 GBK的意思大概是“國家標(biāo)準(zhǔn)漢字?jǐn)U展字符集”吧,記不清了。但它的確是個好東東,比GB2312、BIG5什么的強多了。因為它包括GB2312、GBK的所有字符而且還補充了很多字,另外,還包括日文、朝鮮文以及大量的符號字符。 我在UCDOS for win版本里面找到了GBK的點陣字庫(HZK12.GBK、HZK14.GBK、HZK16.GBK)。分析了一下,知道了結(jié)構(gòu)。這里是我寫的一個演示程序,程序編
2、譯需要有sdl庫。遵循“慣例”,按F4切換全屏/窗口狀態(tài),Esc退出。程序把標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)錯誤重定向到"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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 阿拉善職業(yè)技術(shù)學(xué)院《漢語概說》2023-2024學(xué)年第一學(xué)期期末試卷
- 隴南師范高等??茖W(xué)?!稊?shù)字剪輯》2023-2024學(xué)年第二學(xué)期期末試卷
- 陜西交通職業(yè)技術(shù)學(xué)院《中外建筑史C》2023-2024學(xué)年第一學(xué)期期末試卷
- 陜西國際商貿(mào)學(xué)院《教育神經(jīng)科學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 陜西工業(yè)職業(yè)技術(shù)學(xué)院《大學(xué)體育(三)》2023-2024學(xué)年第一學(xué)期期末試卷
- 陜西師范大學(xué)《生物餌料培養(yǎng)》2023-2024學(xué)年第二學(xué)期期末試卷
- 陜西服裝工程學(xué)院《物理專業(yè)實驗》2023-2024學(xué)年第二學(xué)期期末試卷
- 陜西省咸陽市興平市2024-2025學(xué)年三下數(shù)學(xué)期末教學(xué)質(zhì)量檢測試題含解析
- 陜西省咸陽市重點中學(xué)2025屆高三第二學(xué)期期末(一模)生物試題含解析
- 陜西省寶雞市2025屆高三下學(xué)期期末大聯(lián)考化學(xué)試題含解析
- 中國傳統(tǒng)飲食文化-《糯米糍粑》的制作與傳統(tǒng)意義
- 健身器材采購項目投標(biāo)方案(技術(shù)方案)
- 直播電商行業(yè)現(xiàn)狀、問題與未來發(fā)展策略探討
- 2023年海南高中學(xué)業(yè)水平合格考信息技術(shù)試卷試題(答案詳解)
- 混凝土配合比全自動計算書
- 起重設(shè)備(行車)安全檢查記錄
- 配電室安全巡查記錄表
- 供應(yīng)商評估打分表
- 康復(fù)評定量表
- 整套監(jiān)理工作流程圖(38張,visio編輯)
- 應(yīng)急第一響應(yīng)人線上理論考試
評論
0/150
提交評論