這是蓋莫游戲引擎中的坐標系統和輸入系統測試的小例子代碼如下所示:
1 #include <cstdlib>
2 #include <iostream>
3 #include <GEngine/Main.hpp>
4
5 using namespace std;
6 using namespace core;
7
8 int main(int argc, char *argv[])
9 {
10 Device *device = InitDevice("蓋莫引擎坐標系統測試");
11 device->SetClearColor(core::Color(80,100,230));
12 int x,y,z;
13 //! 使用Opengl坐標系統
14 core::CoordinateSystem cs(COORDINATE_OPENGL);
15 device->SetCoordinateSystem(cs);
16
17 //! 啟用2D渲染模式
18 device->Ortho2D();
19 //! 獲取資源管理器
20 core::ResourceManager* resmgr = device->GetResourceManager();
21 core::RefPtr<core::Text> defont= resmgr->GetText("default_font");
22
23 char text[255];
24 char fpstext[20];
25 float fps = device->GetFPS();
26 BEGIN_LOOP(device);
27 device->GetInput()->GetMousePosition(x,y,z);
28 sprintf(text,"mouse position is :x = %d, y = %d,z = %d",x,y,z);
29 fps = device->GetFPS();
30 sprintf(fpstext,"fps is:%f",fps);
31 defont->Render(20,20,text);
32 defont->Render(540,20,fpstext);
33 END_LOOP(device);
34
35 device->Close();
36 device->Drop();
37
38 system("PAUSE");
39 return EXIT_SUCCESS;
40 }
41
對于opengl坐標系,其原點位于屏幕左下角
當前字體的渲染坐標固定為x軸向右,y軸向下,以屏幕左上角為原點
這是貼圖 不過看上去幀速有點偏低