toge's diary

コンピュータ関連の趣味をつらつらと。

サンプルゲーム linuxポート

id:xtalco:20070604#1180887432

Wineでも動くんだけど、やっつけでLinuxに移植して見ました。

$ diff -r xg.orig xg
diff -r xg.orig/source/main.cpp xg/source/main.cpp
1,3d0
<
< #include <windows.h>
<
46c43
<       MessageBoxW(0, message_buf, title_buf, MB_OK);
---
>     printf("[%s] %s\n", title_buf, message_buf);
172c169
< int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
---
> int main() {
192a190
>     return 0;
diff -r xg.orig/source/xg.cpp xg/source/xg.cpp
10c10,14
< #include <float.h>
---
> #if defined(WIN32)
>     #include <float.h>
> #elif defined(__linux__)
>     #include <fpu_control.h>
> #endif
24,25c28,29
< #include <gl/gl.h>
< #include <gl/glu.h>
---
> #include <GL/gl.h>
> #include <GL/glu.h>
849a854
>             Uint8* keyStats = SDL_GetKeyState(NULL);
851,852c856,857
<                       key_states_[key_state_pos_].buttons[0]=(GetAsyncKeyState(VK_LEFT) & 0x8000)!=0;
<                       key_states_[key_state_pos_].buttons[1]=(GetAsyncKeyState(VK_RIGHT) & 0x8000)!=0;
---
>                       key_states_[key_state_pos_].buttons[0]=keyStats[SDLK_LEFT]!=0;
>                       key_states_[key_state_pos_].buttons[1]=keyStats[SDLK_RIGHT]!=0;
893c898
<                               Sleep(st<0 ? 0 : (int)(st*1000));
---
>                               SDL_Delay(st<0 ? 0 : (int)(st*1000));
906c911
<                       Sleep(50);
---
>                       SDL_Delay(50);