Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

vertexbuffer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002             vertexbuffer.h  -  Vertex buffers with flexible format
00003                              -------------------
00004     begin                : Tue Oct 30 2001
00005     copyright            : (C) 2001 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, vertexbuffer.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2001
00023  Reality Rift Studios. All Rights Reserved.
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    //Define smart pointer
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

Generated on Wed Jan 21 14:21:07 2004 for NeoEngine by doxygen 1.3.5