Skip to main content
History: MinimalPracticalApplication
View published page
Source of version: 5
(current)
!!Minimal Application Using Custom Main Loop If you have any comments let me know. This code example is briefly discussed here [http://www.ogre3d.org/phpBB2/viewtopic.php?t=27924]. {CODE(wrap="1", colors="c++")} #include <Ogre.h> using namespace Ogre; void initResources(){ ResourceGroupManager &resources=ResourceGroupManager::getSingleton(); resources.addResourceLocation("data","FileSystem"); resources.initialiseAllResourceGroups(); } Root* initOgre(){ Root* root = new Root; #if defined(_DEBUG) root->loadPlugin("C:/OGRESDK/bin/debug/RenderSystem_GL_d.dll"); //Linux //root->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL_d"); #else root->loadPlugin("C:/OGRESDK/bin/release/RenderSystem_GL.dll"); //Linux //root->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL"); #endif const Ogre::RenderSystemList& rs = root->getAvailableRenderers(); if(&rs && rs.size()&&rs.at(0)->getName().compare("RenderSystem_GL")){ RenderSystem * r=rs.at(0); root->setRenderSystem(r); r->setConfigOption("Full Screen","No"); r->setConfigOption("Video Mode","800 x 600 @ 16-bit colour"); }else{ exit(1); } initResources(); return root; } Camera* createCamera(SceneManager *sceneMgr,RenderWindow *window){ Camera* cam = sceneMgr->createCamera("SimpleCamera"); cam->setPosition(Vector3(0.0f,0.0f,500.0f)); cam->lookAt(Vector3(0.0f,0.0f,0.0f)); cam->setNearClipDistance(5.0f); cam->setFarClipDistance(5000.0f); Viewport* v = window->addViewport(cam); v->setBackgroundColour(ColourValue(0.5,0.5,0.5)); cam->setAspectRatio(Real(v->getActualWidth())/v->getActualHeight()); return cam; } #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 #define WIN32_LEAN_AND_MEAN #include "windows.h" INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT){ #else int main(int argc, char **argv){ #endif Root *root=initOgre(); RenderWindow* window = root->initialise(true, "Simple Ogre App"); SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC); Camera *cam=createCamera(sceneMgr,window); sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(cam); int running=1000; while(running--) { WindowEventUtilities::messagePump(); root->renderOneFrame(); printf("%d\n",running); } delete root; return 0; } {CODE}
Search by Tags
Search Wiki by Freetags
Latest Changes
Projects using OGRE
Building Your Projects With CMake
Compiled API Reference
Overlay Editor
Introduction - JaJDoo Shader Guide - Basics
RT Shader System
RapidXML Dotscene Loader
One Function Ogre
One Function Ogre
...more
Search
Find
Online Users
136 online users
OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username
Password
CapsLock is on.
Remember me (for 1 year)
Log in