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
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: MadMarx Tutorial 2
View page
Source of version: 8
(current)
!Foreword. If you prefer tutorials that come with a framework => check the other wiki tutorial series. If you prefer tutorials that go step by step without a framework => this page should be ok. I assume you know C++. If not, this tutorial will probably be hard to understand ! This tutorial presents only a few elements of Ogre3D. You can download the code and media for this tutorial at the bottom of this wiki page. This little tutorial is an extract of a bigger project which contains more tutorials & helper classes. This bigger project is avaible there : https://sourceforge.net/projects/so3dtools/ Also, make sure you read these tutorials in order! {maketoc} ! main.cpp {CODE(wrap="1",colors="c++")} // Here is exactly the same as the previous tutorial, but I have reorganized it a bit. // Things are separated between a class that does the initialisation, // and a main() that makes the application run. // If you don't understand what a class is, or what #ifndef means, you should learn C++ first :-). // I will use std::auto_ptr so I need to include 'memory'. // If you don't know std::auto_ptr, you should check some C++ tutorials/lesson on this matter. #include <memory> // I will check for std::exception. If you don't know what exception/try/catch means, you should learn C++ first. #include <exception> // These are some files that we need to include to use Ogre3D. Note that you can at the beginnings use directly "Ogre.h", to include lots of commonly used classes. #include "OGRE/OgreRoot.h" #include "OGRE/OgreRenderWindow.h" #include "OGRE/OgreWindowEventUtilities.h" //Here I include my other files, like the one for SimpleOgreInit... #include "SimpleOgreInit.h" #include "EasyDefines.h" // I declare a function in which I will make my whole application. // This is easy then to add more things later in that function. // The main will call this function and take care of the global try/catch. void AnOgreApplication() { // I construct my object that will allow me to initialise Ogre easily. OgreEasy::SimpleOgreInit lOgreInit; if(!lOgreInit.initOgre()) { MWARNING("Impossible to init Ogre correctly."); return; } // I wait until the window is closed. // The "message pump" thing is something you will see in most GUI application. // It allow the binding of messages between the application and the OS. // These messages are most of the time : keystroke, mouse moved, ... or window closed. // If I don't do this, the message are never caught, and the window won't close. while(!lOgreInit.mWindow->isClosed()) { Ogre::WindowEventUtilities::messagePump(); } return; } int main() { try { AnOgreApplication(); std::cout<<"end of the program"<<std::endl; }catch(Ogre::Exception &e) { MWARNING("!!!!Ogre::Exception!!!!\n" << e.what()); }catch(std::exception &e) { MWARNING("!!!!std::exception!!!!\n"<<e.what()); } OgreEasy::waitForUser(); return 0; } {CODE} Link to full source : http://sourceforge.net/projects/so3dtools/files/Ogre3DWiki/01_SimplestBeginning_Reorganized.7z/download
Search by Tags
Search Wiki by Freetags
Latest Changes
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
...more
Search
Find
Advanced
Search Help
Online Users
121 online users