CrystalSpace

Public API Reference

ivideo/rndbuf.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2002 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_IVIDEO_RNDBUF_H__
00021 #define __CS_IVIDEO_RNDBUF_H__
00022 
00027 #include "csutil/scf.h"
00028 #include "csutil/strset.h"
00029 #include "csutil/refcount.h"
00030 
00035 class csVector3;
00036 class csVector2;
00037 class csColor;
00038 class csReversibleTransform;
00039 struct iTextureHandle;
00040 struct iMaterialWrapper;
00041 class csRenderBufferHolder;
00042 
00048 enum csRenderBufferType
00049 {
00051   CS_BUF_DYNAMIC,
00053   CS_BUF_STATIC,
00055   CS_BUF_STREAM
00056 };
00057 
00059 // NOTE: this is stored on disk by cssynldr! *Modify with care!*
00060 enum csRenderBufferComponentType
00061 {
00062   CS_BUFCOMP_BYTE = 0,
00063   CS_BUFCOMP_UNSIGNED_BYTE,
00064   CS_BUFCOMP_SHORT,
00065   CS_BUFCOMP_UNSIGNED_SHORT,
00066   CS_BUFCOMP_INT,
00067   CS_BUFCOMP_UNSIGNED_INT,
00068   CS_BUFCOMP_FLOAT,
00069   CS_BUFCOMP_DOUBLE,
00070 
00071   CS_BUFCOMP_TYPECOUNT
00072 };
00073 
00077 enum csRenderBufferLockType
00078 {
00080   CS_BUF_LOCK_READ = 1,
00082   CS_BUF_LOCK_NORMAL
00083 };
00084 
00085 #include "csutil/win32/msvc_deprecated_warn_off.h"
00086 
00087 namespace CS
00088 {
00089   namespace Deprecated
00090   {
00091     struct CS_DEPRECATED_TYPE_MSG("You shouldn't use CS_BUF_LOCK_NOLOCK in "
00092       "the first place")
00093       CS_BUF_LOCK_NOLOCK
00094     {
00095       static const uint value = 0;
00096     };
00097   }
00098 }
00099 
00100 #include "csutil/win32/msvc_deprecated_warn_on.h"
00101 
00102 #define CS_BUF_LOCK_NOLOCK      CS::Deprecated::CS_BUF_LOCK_NOLOCK::value
00103 
00107 static const size_t csRenderBufferComponentSizes[CS_BUFCOMP_TYPECOUNT] = 
00108 {
00109   sizeof (char), sizeof (unsigned char), 
00110   sizeof (short), sizeof (unsigned short),
00111   sizeof (int), sizeof (unsigned int),
00112   sizeof (float),
00113   sizeof (double)
00114 };
00115 
00116 struct iRenderBuffer;
00117 
00122 struct iRenderBufferCallback : public virtual iBase
00123 {
00124   SCF_INTERFACE (iRenderBufferCallback, 1,0,0);
00128   virtual void RenderBufferDestroyed (iRenderBuffer* buffer) = 0;
00129 };
00130 
00141 struct iRenderBuffer : public virtual iBase
00142 {
00143   SCF_INTERFACE (iRenderBuffer, 2, 1, 1);
00144 
00152   virtual void* Lock(csRenderBufferLockType lockType) = 0;
00153 
00158   virtual void Release() = 0;
00159 
00166   virtual void CopyInto (const void *data, size_t elementCount,
00167     size_t elemOffset = 0) = 0;
00168 
00170   virtual int GetComponentCount () const = 0;
00171 
00173   virtual csRenderBufferComponentType GetComponentType () const = 0;
00174 
00176   virtual csRenderBufferType GetBufferType() const = 0;
00177 
00179   virtual size_t GetSize() const = 0;
00180 
00182   virtual size_t GetStride() const = 0;
00183 
00185   virtual size_t GetElementDistance() const = 0;
00186 
00188   virtual size_t GetOffset() const = 0;
00189 
00191   virtual uint GetVersion () = 0;
00192 
00199   virtual iRenderBuffer* GetMasterBuffer () const = 0;
00200 
00202   virtual bool IsIndexBuffer() const = 0;
00204   virtual size_t GetRangeStart() const = 0;
00206   virtual size_t GetRangeEnd() const = 0;
00207 
00209   virtual size_t GetElementCount() const = 0;
00210 
00212   virtual void SetCallback (iRenderBufferCallback* cb) = 0;
00213 
00224   virtual void SetData (const void *data) = 0;
00225 };
00226 
00234 enum csRenderBufferName
00235 {
00236   CS_BUFFER_NONE = -1,
00238   CS_BUFFER_INDEX,
00240   CS_BUFFER_POSITION,
00242   CS_BUFFER_NORMAL,
00244   CS_BUFFER_COLOR,
00246   CS_BUFFER_COLOR_UNLIT,
00248   CS_BUFFER_TEXCOORD0,
00250   CS_BUFFER_TEXCOORD1,
00252   CS_BUFFER_TEXCOORD2,
00254   CS_BUFFER_TEXCOORD3,
00256   CS_BUFFER_TEXCOORD_LIGHTMAP,
00258   CS_BUFFER_GENERIC0,
00260   CS_BUFFER_GENERIC1,
00262   CS_BUFFER_GENERIC2,
00264   CS_BUFFER_GENERIC3,
00266   CS_BUFFER_TANGENT,
00268   CS_BUFFER_BINORMAL,
00269 
00274   CS_BUFFER_COUNT
00275 };
00276 
00277 #define CS_BUFFER_MAKE_MASKABLE(x) (1<<(x))
00278 
00280 enum csRenderBufferNameMask
00281 {
00283   CS_BUFFER_INDEX_MASK = 1 << CS_BUFFER_INDEX,
00285   CS_BUFFER_POSITION_MASK = 1 << CS_BUFFER_POSITION,
00287   CS_BUFFER_NORMAL_MASK = 1 << CS_BUFFER_NORMAL,
00289   CS_BUFFER_COLOR_MASK = 1 << CS_BUFFER_COLOR,
00291   CS_BUFFER_COLOR_LIGHTING_MASK = 1 << CS_BUFFER_COLOR_UNLIT,
00293   CS_BUFFER_TEXCOORD0_MASK = 1 << CS_BUFFER_TEXCOORD0,
00295   CS_BUFFER_TEXCOORD1_MASK = 1 << CS_BUFFER_TEXCOORD1,
00297   CS_BUFFER_TEXCOORD2_MASK = 1 << CS_BUFFER_TEXCOORD2,
00299   CS_BUFFER_TEXCOORD3_MASK = 1 << CS_BUFFER_TEXCOORD3,
00301   CS_BUFFER_TEXCOORD_LIGHTMAP_MASK = 1 << CS_BUFFER_TEXCOORD_LIGHTMAP,
00303   CS_BUFFER_GENERIC0_MASK = 1 << CS_BUFFER_GENERIC0,
00305   CS_BUFFER_GENERIC1_MASK = 1 << CS_BUFFER_GENERIC1,
00307   CS_BUFFER_GENERIC2_MASK = 1 << CS_BUFFER_GENERIC2,
00309   CS_BUFFER_GENERIC3_MASK = 1 << CS_BUFFER_GENERIC3,
00311   CS_BUFFER_TANGENT_MASK = 1 << CS_BUFFER_TANGENT,
00313   CS_BUFFER_BINORMAL_MASK = 1 << CS_BUFFER_BINORMAL,
00315   CS_BUFFER_ALL_MASK = ~0
00316 };
00317 
00318 
00324 struct iRenderBufferAccessor : public virtual iBase
00325 {
00326   SCF_INTERFACE (iRenderBufferAccessor,0,0,1);
00328   virtual void PreGetBuffer (csRenderBufferHolder* holder, 
00329     csRenderBufferName buffer) = 0;
00330 };
00331 
00336 class csRenderBufferHolder : public csRefCount
00337 {
00338 public:
00340   csRenderBufferHolder() {accessorMask=0;}
00346   iRenderBuffer* GetRenderBuffer (csRenderBufferName bufferName)
00347   {
00348     if (bufferName < CS_BUFFER_INDEX) return 0;
00349     if (accessor && 
00350         accessorMask & CS_BUFFER_MAKE_MASKABLE(bufferName))
00351       accessor->PreGetBuffer (this, bufferName);
00352 
00353     return buffers[bufferName];
00354   }
00355 
00360   iRenderBuffer* GetRenderBufferNoAccessor (csRenderBufferName bufferName)
00361   {
00362     if (bufferName < CS_BUFFER_INDEX) return 0;
00363     
00364     return buffers[bufferName];
00365   }
00366 
00370   void SetRenderBuffer (csRenderBufferName bufferName, iRenderBuffer* buffer)
00371   {
00372     CS_ASSERT(bufferName >= 0 && bufferName < CS_BUFFER_COUNT);
00373     buffers[bufferName] = buffer;
00374   }
00375 
00379   void SetAccessor (iRenderBufferAccessor* a, uint32 mask)
00380   {
00381     accessorMask = mask;
00382     accessor = a;
00383   }
00385   uint GetAccessorMask() const { return accessorMask; }
00387   iRenderBufferAccessor* GetAccessor() const { return accessor; }
00388 protected:
00389   uint32 accessorMask;
00390   csRef<iRenderBufferAccessor> accessor;
00391   csRef<iRenderBuffer> buffers[CS_BUFFER_COUNT];
00392 };
00393 
00396 #endif // __CS_IVIDEO_RNDBUF_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3