CrystalSpace

Public API Reference

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

renderbuffer.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2003-2005 by Marten Svanfeldt
00003                              Anders Stenberg
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public
00016   License along with this library; if not, write to the Free
00017   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSGFX_RENDERBUFFER_H__
00021 #define __CS_CSGFX_RENDERBUFFER_H__
00022 
00026 #include "csextern.h"
00027 #include "csutil/leakguard.h"
00028 #include "ivideo/rndbuf.h"
00029 
00034 SCF_VERSION (csRenderBuffer, 0, 2, 0);
00035 
00040 struct csInterleavedSubBufferOptions
00041 {
00043   csRenderBufferComponentType componentType;
00045   uint componentCount;
00046 };
00047 
00051 class CS_CSGFX_EXPORT csRenderBuffer : public iRenderBuffer
00052 {
00053 protected:
00057   csRenderBuffer (size_t size, csRenderBufferType type, 
00058     csRenderBufferComponentType componentType, uint componentCount, 
00059     size_t rangeStart, size_t rangeEnd, bool copy);
00060 public:
00061   SCF_DECLARE_IBASE;
00062   CS_LEAKGUARD_DECLARE (csRenderBuffer);
00063 
00067   virtual ~csRenderBuffer ();
00068 
00074   virtual void* Lock (csRenderBufferLockType lockType);
00075 
00077   virtual void Release();
00078 
00080   virtual void CopyInto (const void *data, size_t elementCount,
00081     size_t elemOffset = 0);
00082 
00084   virtual int GetComponentCount () const
00085   {
00086     return compCount;
00087   }
00088 
00090   virtual csRenderBufferComponentType GetComponentType () const 
00091   {
00092     return comptype;
00093   }
00094 
00096   virtual csRenderBufferType GetBufferType() const
00097   {
00098     return bufferType;
00099   }
00100 
00102   virtual size_t GetSize() const
00103   {
00104     return bufferSize;
00105   }
00106 
00108   virtual size_t GetStride() const 
00109   {
00110     return stride;
00111   }
00112 
00113   virtual size_t GetElementDistance() const
00114   {
00115     return stride ? stride :
00116       compCount * csRenderBufferComponentSizes[comptype];
00117   }
00118 
00119   virtual size_t GetOffset() const
00120   { return offset; }
00121 
00123   virtual uint GetVersion ()
00124   {
00125     return version;
00126   }
00127 
00128   virtual bool IsMasterBuffer ()
00129   {
00130     return !masterBuffer.IsValid();
00131   }
00132 
00133   virtual iRenderBuffer* GetMasterBuffer () const
00134   {
00135     return masterBuffer;
00136   }
00137 
00138   virtual bool IsIndexBuffer() const
00139   { return isIndex; }
00140 
00141   virtual size_t GetRangeStart() const
00142   { return rangeStart; }
00143   virtual size_t GetRangeEnd() const
00144   { return rangeEnd; }
00145 
00146   virtual size_t GetElementCount() const;
00147 
00160   static csRef<iRenderBuffer> CreateRenderBuffer (size_t elementCount, 
00161     csRenderBufferType type, csRenderBufferComponentType componentType, 
00162     uint componentCount, bool copy = true);
00177   static csRef<iRenderBuffer> CreateIndexRenderBuffer (size_t elementCount, 
00178     csRenderBufferType type, csRenderBufferComponentType componentType,
00179     size_t rangeStart, size_t rangeEnd, bool copy = true);
00202   static csRef<iRenderBuffer> CreateInterleavedRenderBuffers (size_t elementCount, 
00203     csRenderBufferType type, uint count, 
00204     const csInterleavedSubBufferOptions* elements, 
00205     csRef<iRenderBuffer>* buffers);
00206 
00211   static const char* GetDescrFromBufferName (csRenderBufferName bufferName);
00216   static csRenderBufferName GetBufferNameFromDescr (const char* name);
00217 protected:
00219   csRenderBufferType bufferType; 
00221   csRenderBufferComponentType comptype; 
00222   
00224   size_t bufferSize; 
00226   uint compCount;
00228   size_t stride;
00230   size_t offset; 
00231 
00233   size_t rangeStart; 
00235   size_t rangeEnd; 
00236   
00238   unsigned int version; 
00239 
00241   bool doCopy; 
00243   bool doDelete; 
00245   bool isLocked;
00247   bool isIndex; 
00248 
00250   unsigned char *buffer; 
00252   csRenderBufferLockType lastLock; 
00253   
00254   csRef<iRenderBuffer> masterBuffer;
00255 };
00256 
00259 #endif // __CS_CSGFX_RENDERBUFFER_H__

Generated for Crystal Space by doxygen 1.3.9.1