00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _CEGUIOgreGeometryBuffer_h_
00029 #define _CEGUIOgreGeometryBuffer_h_
00030
00031 #include "../../CEGUIGeometryBuffer.h"
00032 #include "CEGUIOgreRenderer.h"
00033 #include "../../CEGUIRect.h"
00034
00035 #include <OgreMatrix4.h>
00036 #include <OgreColourValue.h>
00037 #include <OgreRenderOperation.h>
00038
00039 #include <utility>
00040 #include <vector>
00041
00042
00043 namespace Ogre
00044 {
00045 class RenderSystem;
00046 }
00047
00048
00049 namespace CEGUI
00050 {
00052 class OGRE_GUIRENDERER_API OgreGeometryBuffer : public GeometryBuffer
00053 {
00054 public:
00056 OgreGeometryBuffer(OgreRenderer& owner, Ogre::RenderSystem& rs);
00058 virtual ~OgreGeometryBuffer();
00059
00061 const Ogre::Matrix4& getMatrix() const;
00062
00063
00064 void draw() const;
00065 void setTranslation(const Vector3& v);
00066 void setRotation(const Vector3& r);
00067 void setPivot(const Vector3& p);
00068 void setClippingRegion(const Rect& region);
00069 void appendVertex(const Vertex& vertex);
00070 void appendGeometry(const Vertex* const vbuff, uint vertex_count);
00071 void setActiveTexture(Texture* texture);
00072 void reset();
00073 Texture* getActiveTexture() const;
00074 uint getVertexCount() const;
00075 uint getBatchCount() const;
00076 void setRenderEffect(RenderEffect* effect);
00077 RenderEffect* getRenderEffect();
00078
00079 protected:
00081 Ogre::RGBA colourToOgre(const colour& col) const;
00083 void updateMatrix() const;
00085 void syncHardwareBuffer() const;
00087 void initialiseTextureStates() const;
00088
00090 struct OgreVertex
00091 {
00092 float x, y, z;
00093 Ogre::RGBA diffuse;
00094 float u, v;
00095 };
00096
00098 OgreRenderer& d_owner;
00100 Ogre::RenderSystem& d_renderSystem;
00102 OgreTexture* d_activeTexture;
00104 Rect d_clipRect;
00106 Vector3 d_translation;
00108 Vector3 d_rotation;
00110 Vector3 d_pivot;
00112 RenderEffect* d_effect;
00114 Vector2 d_texelOffset;
00116 mutable Ogre::Matrix4 d_matrix;
00118 mutable bool d_matrixValid;
00120 mutable Ogre::RenderOperation d_renderOp;
00122 mutable Ogre::HardwareVertexBufferSharedPtr d_hwBuffer;
00124 mutable bool d_sync;
00126 typedef std::pair<Ogre::TexturePtr, uint> BatchInfo;
00128 typedef std::vector<BatchInfo> BatchList;
00130 BatchList d_batches;
00132 typedef std::vector<OgreVertex> VertexList;
00134 VertexList d_vertices;
00135 };
00136
00137
00138 }
00139
00140 #endif // end of guard _CEGUIOgreGeometryBuffer_h_