Ogre最简单的系统

OgreSDK的环境配置这里不谈,大家可以在网上找到很多文章

这里只列出构建一个Ogre最最简单的系统所需要的代码


/* ===================================================== */
//	
//    ◢█████◣               ◢██████◣
// ◢◤             ◥◣         ◢◤             ◥◣ 
// ◤                 ◥◣     ◢◤                 █ 
// ▎      ◢█◣       ◥◣◢◤       ◢█◣       █
// ◣     ◢◤  ◥◣               ◢◣   ◥◣   ◢ 
// ◥██◤   ◢◤                   ◥◣   ◥█◤
//          █   ●               ●    █ 
//          █   〃       ▄       〃   █ 
//           ◥◣       ╚╩╝       ◢◤ 
//             ◥█▅▃▃   ▃▃▅█◤ 
//               ◢◤       ◥◣  
//               █           █  
//             ◢◤▕       ▎◥◣
//           ▕▃◣◢▅▅▅◣◢▃▎
//            
//                 Author : Wangxu
//            Create Date :				
//            Description : 
//
/* ===================================================== */	

#pragma warning(disable: 4251)
#pragma warning(disable: 4193)
#pragma warning(disable: 4275)

#include <Ogre/Ogre.h>

// 链接基本的类和函数
#pragma comment(lib,"OgreMain_d.lib")
using namespace Ogre;


int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in LPSTR lpCmdLine, __in int nShowCmd )
{
	// 构造一个Root类,使用min_plugins.cfg作为插件的配置文件
	Root* root = new Root("min_plugins.cfg");
	// 弹出设置对话框
	if(!root->showConfigDialog())
	{
		return -1;
	}
	// 初始化,创建显示窗口
	RenderWindow* window = root->initialise(true);
	// 得到场景管理器
	SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC);
	// 得到摄像机
	Camera* cam = sceneMgr->createCamera("MainCamera");
	// 得到与该摄像机和窗口关联的视口
	Viewport* viewport = window->addViewport(cam);
	// 设置摄像机的基本属性
	cam->setAspectRatio((Ogre::Real)viewport->getActualWidth() / (Ogre::Real)viewport->getActualHeight());
	cam->setNearClipDistance(5);
	cam->setPosition(0,0,600);

	// 显示窗口,开始渲染,进入无限循环
	root->startRendering();

	return 0;
}

配置文件:min_plugins.cfg

# Defines plugins to load
# Define plugin folder
PluginFolder=.
# Define plugins
Plugin=RenderSystem_Direct3D9_d


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值