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 00133 virtual void CopyInto (const void *data, size_t elementCount, 00134 size_t elemOffset = 0) = 0; 00135 00137 virtual int GetComponentCount () const = 0; 00138 00140 virtual csRenderBufferComponentType GetComponentType () const = 0; 00141 00143 virtual csRenderBufferType GetBufferType() const = 0; 00144 00146 virtual size_t GetSize() const = 0; 00147 00149 virtual size_t GetStride() const = 0; 00150 00152 virtual size_t GetElementDistance() const = 0; 00153 00155 virtual size_t GetOffset() const = 0; 00156 00158 virtual uint GetVersion () = 0; 00159 00166 virtual iRenderBuffer* GetMasterBuffer () const = 0; 00167 00169 virtual bool IsIndexBuffer() const = 0; 00171 virtual size_t GetRangeStart() const = 0; 00173 virtual size_t GetRangeEnd() const = 0; 00174 00176 virtual size_t GetElementCount() const = 0; 00177 }; 00178 00186 enum csRenderBufferName 00187 { 00188 CS_BUFFER_NONE = -1, 00190 CS_BUFFER_INDEX, 00192 CS_BUFFER_POSITION, 00194 CS_BUFFER_NORMAL, 00196 CS_BUFFER_COLOR, 00198 CS_BUFFER_COLOR_UNLIT, 00200 CS_BUFFER_TEXCOORD0, 00202 CS_BUFFER_TEXCOORD1, 00204 CS_BUFFER_TEXCOORD2, 00206 CS_BUFFER_TEXCOORD3, 00208 CS_BUFFER_TEXCOORD_LIGHTMAP, 00210 CS_BUFFER_GENERIC0, 00212 CS_BUFFER_GENERIC1, 00214 CS_BUFFER_GENERIC2, 00216 CS_BUFFER_GENERIC3, 00218 CS_BUFFER_TANGENT, 00220 CS_BUFFER_BINORMAL, 00221 00226 CS_BUFFER_COUNT 00227 }; 00228 00229 #define CS_BUFFER_MAKE_MASKABLE(x) (1<<(x)) 00230 00232 enum csRenderBufferNameMask 00233 { 00235 CS_BUFFER_INDEX_MASK = 1 << CS_BUFFER_INDEX, 00237 CS_BUFFER_POSITION_MASK = 1 << CS_BUFFER_POSITION, 00239 CS_BUFFER_NORMAL_MASK = 1 << CS_BUFFER_NORMAL, 00241 CS_BUFFER_COLOR_MASK = 1 << CS_BUFFER_COLOR, 00243 CS_BUFFER_COLOR_LIGHTING_MASK = 1 << CS_BUFFER_COLOR_UNLIT, 00245 CS_BUFFER_TEXCOORD0_MASK = 1 << CS_BUFFER_TEXCOORD0, 00247 CS_BUFFER_TEXCOORD1_MASK = 1 << CS_BUFFER_TEXCOORD1, 00249 CS_BUFFER_TEXCOORD2_MASK = 1 << CS_BUFFER_TEXCOORD2, 00251 CS_BUFFER_TEXCOORD3_MASK = 1 << CS_BUFFER_TEXCOORD3, 00253 CS_BUFFER_TEXCOORD_LIGHTMAP_MASK = 1 << CS_BUFFER_TEXCOORD_LIGHTMAP, 00255 CS_BUFFER_GENERIC0_MASK = 1 << CS_BUFFER_GENERIC0, 00257 CS_BUFFER_GENERIC1_MASK = 1 << CS_BUFFER_GENERIC1, 00259 CS_BUFFER_GENERIC2_MASK = 1 << CS_BUFFER_GENERIC2, 00261 CS_BUFFER_GENERIC3_MASK = 1 << CS_BUFFER_GENERIC3, 00263 CS_BUFFER_TANGENT_MASK = 1 << CS_BUFFER_TANGENT, 00265 CS_BUFFER_BINORMAL_MASK = 1 << CS_BUFFER_BINORMAL, 00267 CS_BUFFER_ALL_MASK = ~0 00268 }; 00269 00270 00276 struct iRenderBufferAccessor : public virtual iBase 00277 { 00278 SCF_INTERFACE (iRenderBufferAccessor,0,0,1); 00280 virtual void PreGetBuffer (csRenderBufferHolder* holder, 00281 csRenderBufferName buffer) = 0; 00282 }; 00283 00288 class csRenderBufferHolder : public csRefCount 00289 { 00290 public: 00292 csRenderBufferHolder() {accessorMask=0;} 00298 iRenderBuffer* GetRenderBuffer (csRenderBufferName bufferName) 00299 { 00300 if (bufferName < CS_BUFFER_INDEX) return 0; 00301 if (accessor && 00302 accessorMask & CS_BUFFER_MAKE_MASKABLE(bufferName)) 00303 accessor->PreGetBuffer (this, bufferName); 00304 00305 return buffers[bufferName]; 00306 } 00307 00312 iRenderBuffer* GetRenderBufferNoAccessor (csRenderBufferName bufferName) 00313 { 00314 if (bufferName < CS_BUFFER_INDEX) return 0; 00315 00316 return buffers[bufferName]; 00317 } 00318 00322 void SetRenderBuffer (csRenderBufferName bufferName, iRenderBuffer* buffer) 00323 { 00324 CS_ASSERT(bufferName >= 0 && bufferName < CS_BUFFER_COUNT); 00325 buffers[bufferName] = buffer; 00326 } 00327 00331 void SetAccessor (iRenderBufferAccessor* a, uint32 mask) 00332 { 00333 accessorMask = mask; 00334 accessor = a; 00335 } 00337 uint GetAccessorMask() const { return accessorMask; } 00339 iRenderBufferAccessor* GetAccessor() const { return accessor; } 00340 protected: 00341 uint32 accessorMask; 00342 csRef<iRenderBufferAccessor> accessor; 00343 csRef<iRenderBuffer> buffers[CS_BUFFER_COUNT]; 00344 }; 00345 00348 #endif // __CS_IVIDEO_RNDBUF_H__
Generated for Crystal Space by doxygen 1.4.7