## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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 enum csRenderBufferComponentType
    00060 {
    00061   CS_BUFCOMP_BYTE = 0,
    00062   CS_BUFCOMP_UNSIGNED_BYTE,
    00063   CS_BUFCOMP_SHORT,
    00064   CS_BUFCOMP_UNSIGNED_SHORT,
    00065   CS_BUFCOMP_INT,
    00066   CS_BUFCOMP_UNSIGNED_INT,
    00067   CS_BUFCOMP_FLOAT,
    00068   CS_BUFCOMP_DOUBLE,
    00069
    00070   CS_BUFCOMP_TYPECOUNT
    00071 };
    00072
    00076 enum csRenderBufferLockType
    00077 {
    00078   CS_BUF_LOCK_NOLOCK = 0,
    00080   CS_BUF_LOCK_READ,
    00082   CS_BUF_LOCK_NORMAL
    00083 };
    00084
    00088 static const size_t csRenderBufferComponentSizes[CS_BUFCOMP_TYPECOUNT] =
    00089 {
    00090   sizeof (char), sizeof (unsigned char),
    00091   sizeof (short), sizeof (unsigned short),
    00092   sizeof (int), sizeof (unsigned int),
    00093   sizeof (float),
    00094   sizeof (double)
    00095 };
    00096
    00107 struct iRenderBuffer : public virtual iBase
    00108 {
    00109   SCF_INTERFACE (iRenderBuffer, 2, 0, 0);
    00110
    00117   virtual void* Lock(csRenderBufferLockType lockType) = 0;
    00118
    00123   virtual void Release() = 0;
    00124
    00130   virtual void CopyInto (const void *data, size_t elementCount,
    00131     size_t elemOffset = 0) = 0;
    00132
    00134   virtual int GetComponentCount () const = 0;
    00135
    00137   virtual csRenderBufferComponentType GetComponentType () const = 0;
    00138
    00140   virtual csRenderBufferType GetBufferType() const = 0;
    00141
    00143   virtual size_t GetSize() const = 0;
    00144
    00146   virtual size_t GetStride() const = 0;
    00147
    00149   virtual size_t GetElementDistance() const = 0;
    00150
    00152   virtual size_t GetOffset() const = 0;
    00153
    00155   virtual uint GetVersion () = 0;
    00156
    00163   virtual iRenderBuffer* GetMasterBuffer () const = 0;
    00164
    00166   virtual bool IsIndexBuffer() const = 0;
    00168   virtual size_t GetRangeStart() const = 0;
    00170   virtual size_t GetRangeEnd() const = 0;
    00171
    00173   virtual size_t GetElementCount() const = 0;
    00174 };
    00175
    00183 enum csRenderBufferName
    00184 {
    00185   CS_BUFFER_NONE = -1,
    00187   CS_BUFFER_INDEX,
    00189   CS_BUFFER_POSITION,
    00191   CS_BUFFER_NORMAL,
    00193   CS_BUFFER_COLOR,
    00195   CS_BUFFER_COLOR_UNLIT,
    00197   CS_BUFFER_TEXCOORD0,
    00199   CS_BUFFER_TEXCOORD1,
    00201   CS_BUFFER_TEXCOORD2,
    00203   CS_BUFFER_TEXCOORD3,
    00205   CS_BUFFER_TEXCOORD_LIGHTMAP,
    00207   CS_BUFFER_GENERIC0,
    00209   CS_BUFFER_GENERIC1,
    00211   CS_BUFFER_GENERIC2,
    00213   CS_BUFFER_GENERIC3,
    00215   CS_BUFFER_TANGENT,
    00217   CS_BUFFER_BINORMAL,
    00218
    00223   CS_BUFFER_COUNT
    00224 };
    00225
    00226 #define CS_BUFFER_MAKE_MASKABLE(x) (1<<(x))
    00227
    00229 enum csRenderBufferNameMask
    00230 {
    00232   CS_BUFFER_INDEX_MASK = 1 << CS_BUFFER_INDEX,
    00234   CS_BUFFER_POSITION_MASK = 1 << CS_BUFFER_POSITION,
    00236   CS_BUFFER_NORMAL_MASK = 1 << CS_BUFFER_NORMAL,
    00238   CS_BUFFER_COLOR_MASK = 1 << CS_BUFFER_COLOR,
    00240   CS_BUFFER_COLOR_LIGHTING_MASK = 1 << CS_BUFFER_COLOR_UNLIT,
    00242   CS_BUFFER_TEXCOORD0_MASK = 1 << CS_BUFFER_TEXCOORD0,
    00244   CS_BUFFER_TEXCOORD1_MASK = 1 << CS_BUFFER_TEXCOORD1,
    00246   CS_BUFFER_TEXCOORD2_MASK = 1 << CS_BUFFER_TEXCOORD2,
    00248   CS_BUFFER_TEXCOORD3_MASK = 1 << CS_BUFFER_TEXCOORD3,
    00250   CS_BUFFER_TEXCOORD_LIGHTMAP_MASK = 1 << CS_BUFFER_TEXCOORD_LIGHTMAP,
    00252   CS_BUFFER_GENERIC0_MASK = 1 << CS_BUFFER_GENERIC0,
    00254   CS_BUFFER_GENERIC1_MASK = 1 << CS_BUFFER_GENERIC1,
    00256   CS_BUFFER_GENERIC2_MASK = 1 << CS_BUFFER_GENERIC2,
    00258   CS_BUFFER_GENERIC3_MASK = 1 << CS_BUFFER_GENERIC3,
    00260   CS_BUFFER_TANGENT_MASK = 1 << CS_BUFFER_TANGENT,
    00262   CS_BUFFER_BINORMAL_MASK = 1 << CS_BUFFER_BINORMAL,
    00264   CS_BUFFER_ALL_MASK = ~0
    00265 };
    00266
    00267
    00273 struct iRenderBufferAccessor : public virtual iBase
    00274 {
    00275   SCF_INTERFACE (iRenderBufferAccessor,0,0,1);
    00277   virtual void PreGetBuffer (csRenderBufferHolder* holder,
    00278     csRenderBufferName buffer) = 0;
    00279 };
    00280
    00285 class csRenderBufferHolder : public csRefCount
    00286 {
    00287 public:
    00289   csRenderBufferHolder() {accessorMask=0;}
    00295   iRenderBuffer* GetRenderBuffer (csRenderBufferName bufferName)
    00296   {
    00297     if (bufferName < CS_BUFFER_INDEX) return 0;
    00298     if (accessor &&
    00299         accessorMask & CS_BUFFER_MAKE_MASKABLE(bufferName))
    00300       accessor->PreGetBuffer (this, bufferName);
    00301
    00302     return buffers[bufferName];
    00303   }
    00304
    00308   void SetRenderBuffer (csRenderBufferName bufferName, iRenderBuffer* buffer)
    00309   {
    00310     CS_ASSERT(bufferName >= 0 && bufferName < CS_BUFFER_COUNT);
    00311     buffers[bufferName] = buffer;
    00312   }
    00313
    00317   void SetAccessor (iRenderBufferAccessor* a, uint32 mask)
    00318   {
    00319     accessorMask = mask;
    00320     accessor = a;
    00321   }
    00323   uint GetAccessorMask() const { return accessorMask; }
    00325   iRenderBufferAccessor* GetAccessor() const { return accessor; }
    00326 protected:
    00327   uint32 accessorMask;
    00328   csRef<iRenderBufferAccessor> accessor;
    00329   csRef<iRenderBuffer> buffers[CS_BUFFER_COUNT];
    00330 };
    00331
    00334 #endif // __CS_IVIDEO_RNDBUF_H__