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 #ifndef __NEVERTEXBUFFER_H
00028 #define __NEVERTEXBUFFER_H
00029
00030
00037 #include "base.h"
00038 #include "vertexdecl.h"
00039 #include "buffer.h"
00040 #include "util.h"
00041
00042
00043 namespace NeoEngine
00044 {
00045
00046
00052 class NEOENGINE_API VertexBuffer : public Buffer
00053 {
00054 friend class RenderDevice;
00055
00056 protected:
00057
00059 VertexDeclaration *m_pkVertexFormat;
00060
00062 unsigned int m_uiVertexFormatSize;
00063
00065 unsigned char *m_pucBuffer;
00066
00068 unsigned char *m_pucVertices;
00069
00070
00075 virtual bool AcquireLock() { m_pucVertices = m_pucBuffer; return true; }
00076
00080 virtual void ReleaseLock() { m_pucVertices = 0; }
00081
00082
00083
00084
00085 public:
00086
00093 VertexBuffer( unsigned int uiType, unsigned int uiNumVertices, const VertexDeclaration *pkFormat, const void *pData = 0 );
00094
00097 virtual ~VertexBuffer();
00098
00105 virtual void AllocateVertices( unsigned int uiNumVertices, const VertexDeclaration *pkFormat, const void *pData = 0 );
00106
00112 inline void LoadVertexData( const void *pData ) { fmemcpy( m_pucVertices, pData, m_uiVertexFormatSize * m_uiNumCurrent ); }
00113
00118 inline void *GetVertex( unsigned int uiElement = 0 ) { return( m_pucVertices + ( m_uiVertexFormatSize * uiElement ) ); }
00119
00123 inline const VertexDeclaration *GetVertexFormat() const { return m_pkVertexFormat; }
00124
00129 inline unsigned int GetVertexSize() const { return m_uiVertexFormatSize; }
00130
00136 virtual const void *GetRenderData() { return m_pucBuffer; }
00137 };
00138
00139
00140 #ifndef __HAVE_SMARTPOINTER_NEVERTEXBUFFER
00141
00142 # ifdef _MSC_VER
00143 # pragma warning( disable : 4231 )
00144 # endif
00145 SmartPointer( VertexBuffer );
00146 # define __HAVE_SMARTPOINTER_NEVERTEXBUFFER
00147 #endif
00148
00149
00150 };
00151
00152
00153 #endif