|
这是盖莫游戏引擎中的坐标系统和输入系统测试的小例子代码如下所示:
#include <cstdlib>
#include <iostream>
#include <GEngine/Main.hpp>
using namespace std;
using namespace core;
int main(int argc, char *argv[])
{
Device *device = InitDevice("盖莫引擎坐标系统测试");
device->SetClearColor(core::Color(80,100,230));
int x,y,z;
//! 使用Opengl坐标系统
core::CoordinateSystem cs(COORDINATE_OPENGL);
device->SetCoordinateSystem(cs);
//! 启用2D渲染模式
device->Ortho2D();
//! 获取资源管理器
core::ResourceManager* resmgr = device->GetResourceManager();
core::RefPtr<core::Text> defont= resmgr->GetText("default_font");
char text[255];
char fpstext[20];
float fps = device->GetFPS();
BEGIN_LOOP(device);
device->GetInput()->GetMousePosition(x,y,z);
sprintf(text,"mouse position is :x = %d, y = %d,z = %d",x,y,z);
fps = device->GetFPS();
sprintf(fpstext,"fps is:%f",fps);
defont->Render(20,20,text);
defont->Render(540,20,fpstext);
END_LOOP(device);
device->Close();
device->Drop();
system("AUSE");
return EXIT_SUCCESS;
}
对于opengl坐标系,其原点位于屏幕左下角
当前字体的渲染坐标固定为x轴向右,y轴向下,以屏幕左上角为原点
这是贴图 不过看上去帧速有点偏低 |
|