HWIndex.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 *<
00003 FILE: HWIndex.h
00004 
00005 DESCRIPTION: Hardware Index Interface Implementation
00006 
00007 CREATED BY: Peter Watje
00008 
00009 HISTORY: Created June 13, 2008
00010 
00011 Copyright 2008 Autodesk, Inc.  All rights reserved.
00012 
00013 Use of this software is subject to the terms of the Autodesk license agreement 
00014 provided at the time of installation or download, or which otherwise accompanies 
00015 this software in either electronic or hard copy form.   
00016 
00017 **********************************************************************/
00018 
00019 
00020 #pragma once
00021 #include "export.h"
00022 #include "maxheap.h" 
00023 #include "tab.h" 
00024 
00025 namespace GFX_MESH
00026 {
00027 
00029 enum PrimitiveType { kLineList = 2, kTriangleList = 3};
00030 
00032 
00037 class HWIndex32Bit : public  MaxHeapOperators
00038 {
00039 public:
00041 
00044     DllExport HWIndex32Bit(unsigned int indicesPerElement);
00045 
00047 
00051     DllExport void SetBuffer(DWORD *buffer);
00052 
00054 
00055     DllExport const unsigned int Count();
00056 
00058 
00062     DllExport DWORD& operator[](int i);
00063     DllExport const DWORD& operator[](int i) const;
00064 
00065 
00066 private:
00067     int mCount;             //number of indices per element
00068     DWORD *mIndex;          //pointer to the actual raw index array
00069     static DWORD errorIndex;
00070 
00071 };
00072 
00074 
00078 class HWIndex16Bit : public  MaxHeapOperators
00079 {
00080 public:
00082 
00085     DllExport HWIndex16Bit(unsigned int indicesPerElement);
00086 
00088 
00092     DllExport void SetBuffer(WORD *buffer);
00093 
00095 
00096     DllExport const unsigned int Count();
00097 
00099 
00103     DllExport WORD& operator[](int i);
00104     DllExport const WORD& operator[](int i) const;
00105 
00106 private:
00107     int mCount;     //number of indices per element
00108     WORD *mIndex;   //pointer to the actual raw index array
00109 };
00110 
00112 
00114 class HWIndexBuffer : public  MaxHeapOperators
00115 {
00116 public:
00117 
00119 
00124         DllExport HWIndexBuffer(unsigned int count, unsigned int indicesPerPrimitive, bool use16Bit);
00126         DllExport ~HWIndexBuffer();
00127 
00129 
00130         DllExport void FreeBuffer();
00131 
00133 
00134         DllExport const unsigned int NumberPrimitives();
00135 
00137 
00138         DllExport const unsigned int IndicesPerPrimitive();
00139 
00142         DllExport const unsigned int Size();
00143 
00145 
00150         DllExport bool SetNumberPrimitives(unsigned int ct);
00151 
00153 
00155         DllExport bool Is16Bit();
00156 
00157 
00159 
00163         DllExport  HWIndex32Bit GetHWIndex32Bit(int index);
00164 
00166 
00169         DllExport  HWIndex16Bit GetHWIndex16Bit(int index);
00170 
00171 
00173 
00174         DllExport  const DWORD *GetRawBufferPointer();
00176 
00177         DllExport  const WORD *GetRawBufferPointer16Bit();
00178 
00179 private:
00180 
00181     PrimitiveType   mPrimitiveType;     //the primitive type
00182 
00183     int mPrimitiveCount;                    //Number of elements in the buffers
00184     int mIndicesPerPrimitive;       //Number of indices per element
00185     bool mUse16Bit;             //whether to use 16 or 32 bit index buffers
00186     Tab<DWORD> mIndices32Bit;           // the actual raw pointer to the 32 bit buffer
00187     Tab<WORD> mIndices16Bit;        // the actual raw pointer to the 16 bit buffer
00188 
00189 };
00190 }