游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2068|回复: 0

:盖莫游戏引擎中的坐标系统和输入系统测试的小例子

[复制链接]

50

主题

69

帖子

69

积分

注册会员

Rank: 2

积分
69
发表于 2010-2-9 10:23:00 | 显示全部楼层 |阅读模式
这是盖莫游戏引擎中的坐标系统和输入系统测试的小例子代码如下所示:
#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(&quotAUSE");
    return EXIT_SUCCESS;
}
对于opengl坐标系,其原点位于屏幕左下角
当前字体的渲染坐标固定为x轴向右,y轴向下,以屏幕左上角为原点


这是贴图 不过看上去帧速有点偏低
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2024-5-12 03:40

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表