在Ubuntu 12.04上搭建OGRE的开发环境使用命令:
sudo apt-get install libogre-dev
建立一个文件夹helloogre然后创建main.cpp,文件内容如下:
#include "OGRE/ExampleApplication.h"
class Example1 : public ExampleApplication
{
public:
void createScene()
{
//Set the scene's ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f,0.5f,0.5f));
//Create an Entity
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head","ogrehead.mesh");
//Create a SceneNode and attach to Entity to it
Ogre::SceneNode *headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
headNode->attachObject(ogreHead);
//Create a Light and set its position
Ogre::Light *light = mSceneMgr->createLight("MainLight");
light->setPosition(20,80,50);
}
};
int main(int argc, char *argv[])
{
Example1 app;
app.go();
return 0;
}
然后通过命令编译:
g++ -o app main.cpp `pkg-config --libs OGRE OIS`
所有代码上传到github上:
https://github.com/chaiwizard/learn_ogre