Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
E:/Programming/MyProject/K_Game_hg/GameEngine/include/render/VertexBuffer.h
Go to the documentation of this file.
00001 // Copyright 2006-2011 by Kat'Oun
00002 
00003 #ifndef _VERTEX_BUFFER_H_
00004 #define _VERTEX_BUFFER_H_
00005 
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008 #include <resource/Buffer.h>
00009 
00010 #include <list>
00011 #include <map>
00012 
00013 namespace render
00014 {
00015 
00017 enum VertexElementSemantic
00018 {
00019         VES_POSITION,                           
00020         VES_NORMAL,                                     
00021         VES_BLEND_WEIGHTS,                      
00022         VES_BLEND_INDICES,                      
00023         VES_DIFFUSE,                            
00024         VES_SPECULAR,                           
00025         VES_TEXTURE_COORDINATES,        
00026         VES_BINORMAL,                           
00027         VES_TANGENT                                     
00028 };
00029 
00031 enum VertexElementType
00032 {
00033         VET_FLOAT1,
00034         VET_FLOAT2,
00035         VET_FLOAT3,
00036         VET_FLOAT4,
00037         VET_COLOR,
00038         VET_SHORT1,
00039         VET_SHORT2,
00040         VET_SHORT3,
00041         VET_SHORT4
00042 };
00043 
00053 class ENGINE_PUBLIC_EXPORT VertexElement
00054 {
00055 public:
00057         VertexElement(u16 source, u32 offset, VertexElementType theType, VertexElementSemantic semantic, u16 index = 0);
00058 
00059         inline bool operator== (const VertexElement& rhs) const;
00060         
00062         u16 getSource() const;
00064         u32 getOffset() const;
00066         VertexElementType getType() const;
00068         VertexElementSemantic getSemantic() const;
00070         u16 getIndex() const;
00072         u32 getSize() const;
00074         static u32 getTypeSize(VertexElementType etype);
00076         static u16 getTypeCount(VertexElementType etype);
00079         static VertexElementType multiplyTypeCount(VertexElementType baseType, unsigned short count);
00080 
00081 protected:
00082 
00084         u16 mSource;
00086         u32 mOffset;
00088         VertexElementType mType;
00090         VertexElementSemantic mSemantic;
00092         u16 mIndex;
00093 };
00094 
00110 class ENGINE_PUBLIC_EXPORT VertexDeclaration
00111 {
00112 public:
00114         VertexDeclaration();
00115         virtual ~VertexDeclaration();
00116 
00117         inline bool operator== (const VertexDeclaration& rhs) const;
00118         
00120         const std::list<VertexElement*>& getElements() const;
00121 
00131         virtual const VertexElement* addElement(u16 source, u32 offset, VertexElementType theType, VertexElementSemantic semantic, u16 index = 0);
00132 
00134         virtual void removeElement(u16 elem_index);
00135 
00141         virtual void removeElement(VertexElementSemantic semantic, u16 index = 0);
00142 
00144         virtual void removeAllElements();
00145 
00147         virtual void modifyElement(u16 elem_index, u16 source, u32 offset, VertexElementType theType, VertexElementSemantic semantic, u16 index = 0);
00148 
00150         virtual const VertexElement* findElementBySemantic(VertexElementSemantic sem, u16 index = 0);
00151 
00153         virtual std::list<VertexElement*> findElementsBySource(u16 source);
00154 
00156         virtual u32 getVertexSize(u16 source);
00157 
00158 protected:
00159 
00160         std::list<VertexElement*> mVertexElements;
00161 };
00162 
00164 class ENGINE_PUBLIC_EXPORT VertexBuffer: public resource::Buffer
00165 {
00166 public:
00167 
00168         VertexBuffer(u32 vertexSize, u32 numVertices, resource::BufferUsage usage, bool systemMemory, bool useShadowBuffer);
00169 
00170         virtual ~VertexBuffer();
00171 
00173         u32 getNumVertices();
00175         u32 getVertexSize();
00176 
00177 protected:
00178         
00179         u32 mNumVertices;
00180         u32 mVertexSize;
00181 };
00182 
00190 class ENGINE_PUBLIC_EXPORT VertexBufferBinding
00191 {
00192 public:
00193 
00194         VertexBufferBinding();
00195         virtual ~VertexBufferBinding();
00196 
00198         virtual const std::map<u16, VertexBuffer*>& getBindings() const;
00199 
00207         virtual void setBinding(u16 index, VertexBuffer* buffer);
00209         virtual void unsetBinding(u16 index);
00210 
00212         virtual void unsetAllBindings();        
00213 
00215         virtual VertexBuffer* getBuffer(u16 index);
00216 
00221         virtual u16 getNextIndex();
00222 
00223 protected:
00224 
00225         std::map<u16, VertexBuffer*> mBindingMap;
00226         u16 mHighIndex;
00227 };
00228 
00229 }// end namespace render
00230 
00231 #endif// _VERTEXBUFFER_H_

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:05 by Doxygen (1.7.4)