History: QuickGUI Integration Tutorial
Source of version: 8
Copy to clipboard
!Introduction
This tutorial explains how QuickGUI works on a high level, and includes what is needed by QuickGUI in order to be used in your application. For those who would like to see a full solution, a ''QuickGUIOgreDemo'' application is packaged with QuickGUI, which shows how Ogre and QuickGUI are used together.
!History
Previously QuickGUI was built using Ogre as its primary method of rendering UI, however in this new version rendering has been abstracted out of the library. QuickGUI introduces many abstract classes that must be implemented and passed in for QuickGUI to operate. Not only does this remove QuickGUI's dependency on Ogre, but it gives the developer control over how rendering occurs. This is especially useful if you work in an environment with certain limitations, ie power of 2 texture sizes, or use a specific or custom graphics library. In any case, you are in complete control of the rendering, so you can always adjust it without modifying QuickGUI source!
!!What if I don't know how to write a solution using Ogre for manual rendering?
In this tutorial I will provide __an implementation__ that uses Ogre 1.7. It's important to realize that you can write your own rendering solution, and that the provided solution may not be the most efficient for all scenarios.
!Creating QuickGUI Core
The Core class is similar to Ogre's Root class, providing access to all main subsystems within QuickGUI, and allowing creation and destruction of __Interface__ objects. An __Interface__ is a class that represents a collection of __Window__ and __RenderTarget__ objects, and will be covered in another tutorial.
Core constructor:
{CODE(wrap="1", colors="c++")}
/**
* Constructor. The passed in ResourceManager and SkinEffectCreator classes will NOT be owned by QuickGUICore, as
* they might be part of a class with scope larger than QuickGUI. Passing in a NULL value for the SkinEffectCreator
* is valid, as long as your UI Skins do not have any Skin Effects.
*/
Core(ResourceManager* m, SkinEffectManager* sem);
{CODE}
NOTE: Both the constructor and destructor are public, and should be created/destroyed by your application.
As seen in the comments, a __ResourceManager__ and __SkinEffectManager__ are required. The __SkinEffectManager__ is part of the Skinning system, and will be covered in another tutorial. Passing in NULL for the SkinEffectManager is perfectly acceptable, provided you don't use any __SkinEffect__'s. (which should be covered in the same tutorial as the __SkinEffetManager__(:smile:))
!!!ResourceManager
The __ResourceManager__ class is an abstract class in QuickGUI, and meant to be derived and implemented by your application code. It performs the following functionality:
* Access to __Image__s by name. An __Image__ is a class representing an image file on disk, and gives read-only access to pixel data. Depending on your implementation, this could also work for Images in memory.
* Creation and destruction of __RenderTexture__ objects. This class represents a texture in memory that supports drawing of __Image__s and rectangles to it.
* Creation and destruction of __Texture__ objects. A __Texture__ represents a image in memory, and provides both read and write access to pixel data.
!!!Image
A recognized QuickGUI __Image__ must have the following interface:
{CODE(wrap="1", colors="c++")}
public:
/**
* Returns the ColorValue of the pixel at the position specified.
*/
virtual ColorValue getColorAtPosition(const Position& p) = 0;
/**
* Gets the name of this Image.
*/
virtual std::string getName() = 0;
/**
* Gets the size of this Image, in pixels.
*/
virtual Size getSize() = 0;{CODE}
Here is the provided implementation used by the QuickGUIOgreDemo application:
[http://stormsonggames.com/downloads/IntegrationTutorial/Image.h|Image.h]
!!!RenderTexture
The RenderTexture interface is quite large. Here are a few of the APIs required by the class:
* clear
* drawLine
* drawImage
* drawRect
* drawTiledImage
* getClippingBounds
* setClippingBounds
* writeContentsToFile
Here is the provided implementation used by the QuickGUIOgreDemo application:
[http://stormsonggames.com/downloads/IntegrationTutorial/RenderTexture.h|Image.h]
[http://stormsonggames.com/downloads/IntegrationTutorial/RenderTexture.h|RenderTexture.cpp]
It is strongly recommended to look through the source of these files to gain a better understanding of __one approach__ to providing an implementation for this class.
!!!Texture