MinimalPracticalApplication
This is a minimal application using it's own main loop and plugin loading
Welcome to the new Ogre Wiki!
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
If you haven't done so already, be sure to visit the Wiki Portal to read about how the wiki works. Especially the Ogre Wiki Overview page.
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
.
#include <Ogre.h> using namespace Ogre; void initResources(){ ResourceGroupManager &resources=ResourceGroupManager::getSingleton(); resources.addResourceLocation("data","FileSystem"); resources.initialiseAllResourceGroups(); } Root* initOgre(){ Root* root = new Root; root->loadPlugin("/usr/local/lib/OGRE/RenderSystem_GL"); 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; }
Contributors to this page: jacmoe
and
Overburn
.
Page last modified on Saturday 02 of January, 2010 22:52:34 UTC by jacmoe
.
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.
Sidebar
Search box
Online users
77
online users

