nux-1.14.0
GLResource.h
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef GLRESOURCE_H
00024 #define GLRESOURCE_H
00025 
00026 #include "NuxCore/NuxCore.h"
00027 #include "NuxCore/SystemTypes.h"
00028 #include "NuxCore/Error.h"
00029 #include "NuxCore/FilePath.h"
00030 #include "NuxCore/Color.h"
00031 #include "NuxCore/Rect.h"
00032 #include "NuxCore/Point.h"
00033 #include "NuxCore/Size.h"
00034 #include "NuxImage/BitmapFormats.h"
00035 #include "NuxCore/Parsing.h"
00036 #include "NuxCore/Object.h"
00037 #include "NuxCore/ObjectPtr.h"
00038 
00039 #include "NuxCore/Math/MathUtility.h"
00040 #include "NuxCore/Math/Constants.h"
00041 #include "NuxCore/Math/Vector3.h"
00042 #include "NuxCore/Math/Vector4.h"
00043 #include "NuxCore/Math/Matrix3.h"
00044 #include "NuxCore/Math/Matrix4.h"
00045 #include "NuxCore/Math/Spline.h"
00046 #include "NuxCore/Math/MathFunctions.h"
00047 
00048 #include "NuxImage/ImageSurface.h"
00049 
00050 namespace nux
00051 {
00052   class IOpenGLResource;
00053 
00054   class BaseTexture;
00055   class Texture2D;
00056   class TextureRectangle;
00057   class TextureCube;
00058   class TextureVolume;
00059   class TextureFrameAnimation;
00060 
00061   class BaseMeshBuffer;
00062   class NIndexBuffer;
00063 
00064   class CachedTexture2D;
00065   class CachedTextureRectangle;
00066   class CachedTextureCube;
00067   class CachedTextureVolume;
00068   class CachedTextureFrameAnimation;
00069   class FontTexture;
00070 
00071 }
00072 
00073 #define NUX_ENABLE_CG_SHADERS 0
00074 
00075 #if defined(NUX_OS_WINDOWS)
00076   #include "GL/glew.h"
00077   #include "GL/wglew.h"
00078 
00079   GLEWContext *glewGetContext();
00080   WGLEWContext *wglewGetContext();
00081 
00082   #if (NUX_ENABLE_CG_SHADERS)
00083   #include "CG/cg.h"
00084   #include "CG/cgGL.h"
00085   #pragma comment( lib, "cg.lib" )
00086   #pragma comment( lib, "cgGL.lib"  )
00087   #endif
00088 
00089 #elif defined(NUX_OS_LINUX)
00090 
00091   #ifdef NUX_OPENGLES_20
00092     #ifndef GLEW_MX
00093       #define GLEW_MX
00094     #endif
00095     #include "EGL/egl.h"
00096     #include "GLES2/gl2.h"
00097   #else
00098     #ifndef GLEW_MX
00099       #define GLEW_MX
00100     #endif
00101     #include "GL/glew.h"
00102     #include "GL/glxew.h"
00103     
00104     GLEWContext *glewGetContext();
00105     GLXEWContext *glxewGetContext();
00106 
00107     #if (NUX_ENABLE_CG_SHADERS)
00108       #include "Cg/cg.h"
00109       #include "Cg/cgGL.h"
00110     #endif
00111   #endif
00112 
00113 #endif
00114 
00115 #include "RunTimeStats.h"
00116 #include "NuxGraphicsResources.h"
00117 #include "FontTexture.h"
00118 #include "GlobalGraphicsInitializer.h"
00119 
00120 #include "GLError.h"
00121 
00122 #define CG_FRAGMENT_PROFILE CG_PROFILE_FP30
00123 #define CG_VERTEX_PROFILE CG_PROFILE_VP30
00124 
00125 #define NUX_BUFFER_OFFSET(i) ((BYTE *)NULL + (i))
00126 
00127 
00128 namespace nux
00129 {
00130 
00131   enum
00132   {
00133     OGL_OK = 0,
00134     OGL_ERROR,
00135     OGL_ERROR_UNKNOWN,
00136     OGL_INVALID_SURFACE_LEVEL,
00137     OGL_INVALID_CALL,
00138     OGL_INVALID_LOCK,
00139     OGL_INVALID_UNLOCK,
00140     OGL_INVALID_TEXTURE,
00141     OGL_FORCE_DWORD            = 0x7fffffff /* force 32-bit size enum */
00142   };
00143 
00144   extern const TCHAR *OGLDeviceErrorMessages[];
00145 
00146 #define OGL_OK 0
00147 #define OGL_CALL(call)              \
00148     {                               \
00149         int Result = call;          \
00150         if(Result != OGL_OK)          \
00151         {nuxError(TEXT("OGL Object Error: Error # %d - (%s) "), Result,  *OGLDeviceErrorMessages[Result] );}   \
00152     }
00153 
00154 //if(Result!=OGL_OK) {nuxError(TEXT("OGL Object Error: Error # %d - %s"), Result, OGLDeviceErrorMessages[Result]);}
00155 
00156   enum TEXTURE_FORMAT
00157   {
00158     TEXTURE_FMT_UNKNOWN              = 0,
00159     TEXTURE_FMT_ALPHA                = GL_ALPHA,
00160     TEXTURE_FMT_ALPHA8               = GL_ALPHA8,
00161     TEXTURE_FMT_ALPHA16              = GL_ALPHA16,
00162 
00163     TEXTURE_FMT_LUMINANCE            = GL_LUMINANCE,
00164     TEXTURE_FMT_LUMINANCE8           = GL_LUMINANCE8,
00165     TEXTURE_FMT_LUMINANCE16          = GL_LUMINANCE16,
00166 
00167     TEXTURE_FMT_LUMINANCE_ALPHA      = GL_LUMINANCE_ALPHA,
00168     TEXTURE_FMT_LUMINANCE8_ALPHA8    = GL_LUMINANCE8_ALPHA8,
00169     TEXTURE_FMT_LUMINANCE16_ALPHA16  = GL_LUMINANCE16_ALPHA16,
00170 
00171     TEXTURE_FMT_INTENSITY            = GL_INTENSITY,
00172     TEXTURE_FMT_INTENSITY8           = GL_INTENSITY8,
00173     TEXTURE_FMT_INTENSITY16          = GL_INTENSITY16,
00174 
00175     TEXTURE_FMT_GL_DEPTH_COMPONENT   = GL_DEPTH_COMPONENT,
00176     TEXTURE_FMT_GL_DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24,
00177 
00178     TEXTURE_FMT_RGBA                 = GL_RGBA,
00179     TEXTURE_FMT_RGBA8                = GL_RGBA8,
00180     TEXTURE_FMT_RGBA16               = GL_RGBA16,
00181 
00182     TEXTURE_FMT_RGBA16F_ARB          = GL_RGBA16F_ARB,
00183     TEXTURE_FMT_RGBA32F_ARB          = GL_RGBA32F_ARB,
00184     TEXTURE_FMT_RGB                  = GL_RGB,
00185     TEXTURE_FMT_RGB8                 = GL_RGB8,
00186     TEXTURE_FMT_RGB16                = GL_RGB16,
00187     TEXTURE_FMT_RGB16F_ARB           = GL_RGB16F_ARB,
00188     TEXTURE_FMT_RGB32F_ARB           = GL_RGB32F_ARB,
00189 
00190     TEXTURE_FMT_COMPRESSED_RGB_S3TC_DXT1_EXT   = GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
00191     TEXTURE_FMT_COMPRESSED_RGBA_S3TC_DXT1_EXT  = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
00192     TEXTURE_FMT_COMPRESSED_RGBA_S3TC_DXT3_EXT  = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
00193     TEXTURE_FMT_COMPRESSED_RGBA_S3TC_DXT5_EXT  = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
00194     TEXTURE_FMT_FORCE_DWORD                    = 0x7fffffff /* force 32-bit size enum */
00195   };
00196 
00197   struct PixelFormatReadInfo
00198   {
00199     const TCHAR *Name;
00200     GLenum          Format;     // format use for glReadPixels
00201     GLenum          type;       // type use for glReadPixels
00202     // Format specific internal flags, e.g. whether SRGB is supported with this format
00203     DWORD                       Flags;
00204     bool                        Supported;
00205   };
00206 
00207   enum eCUBEMAP_FACES
00208   {
00209     CUBEMAP_FACE_POSITIVE_X     = GL_TEXTURE_CUBE_MAP_POSITIVE_X,
00210     CUBEMAP_FACE_NEGATIVE_X     = GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
00211     CUBEMAP_FACE_POSITIVE_Y     = GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
00212     CUBEMAP_FACE_NEGATIVE_Y     = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
00213     CUBEMAP_FACE_POSITIVE_Z     = GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
00214     CUBEMAP_FACE_NEGATIVE_Z     = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
00215 
00216     CUBEMAP_FACE_FORCE_DWORD    = 0x7fffffff
00217   };
00218 
00219   enum VBO_USAGE
00220   {
00221     VBO_USAGE_UNKNOWN   = 0,
00222     VBO_USAGE_STATIC    = GL_STATIC_DRAW,
00223     VBO_USAGE_DYNAMIC   = GL_DYNAMIC_DRAW,
00224     VBO_USAGE_STREAM    = GL_STREAM_DRAW,
00225     VBO_USAGE_FORCE_DWORD    = 0x7fffffff /* force 32-bit size enum */
00226   };
00227 
00228   enum INDEX_FORMAT
00229   {
00230     INDEX_FORMAT_UNKNOWN   = 0,
00231     INDEX_FORMAT_USHORT    = GL_UNSIGNED_SHORT,
00232     INDEX_FORMAT_UINT      = GL_UNSIGNED_INT,
00233     INDEX_FORMAT_FORCE_DWORD    = 0x7fffffff /* force 32-bit size enum */
00234   };
00235 
00236 // Primitives supported by draw-primitive API
00237   typedef enum
00238   {
00239     PRIMITIVE_TYPE_POINTLIST             = GL_POINTS,
00240     PRIMITIVE_TYPE_LINELIST              = GL_LINES,
00241     PRIMITIVE_TYPE_LINESTRIP             = GL_LINE_STRIP,
00242     PRIMITIVE_TYPE_TRIANGLELIST          = GL_TRIANGLES,
00243     PRIMITIVE_TYPE_TRIANGLESTRIP         = GL_TRIANGLE_STRIP,
00244     PRIMITIVE_TYPE_TRIANGLEFAN           = GL_TRIANGLE_FAN,
00245     PRIMITIVE_TYPE_QUADLIST              = GL_QUADS,
00246     PRIMITIVE_TYPE_QUADSTRIP             = GL_QUAD_STRIP,
00247     PRIMITIVE_TYPE_FORCE_DWORD           = 0x7fffffff /* force 32-bit size enum */
00248   } PRIMITIVE_TYPE;
00249 
00250   enum OpenGLResourceType
00251   {
00252     RTINDEXBUFFER,
00253     RTVERTEXBUFFER,
00254     RTSURFACE,
00255     RTVOLUME,
00256     RTBASETEXTURE,
00257     RTTEXTURE,
00258     RTTEXTURERECTANGLE,
00259     RTCUBETEXTURE,
00260     RTVOLUMETEXTURE,
00261     RTANIMATEDTEXTURE,
00262     RTVERTEXDECLARATION,
00263     RTQUERY,
00264     RTFRAMEBUFFEROBJECT,
00265     RT_GLSL_VERTEXSHADER,
00266     RT_GLSL_PIXELSHADER,
00267     RT_GLSL_GEOMETRYSHADER,
00268     RT_GLSL_SHADERPROGRAM,
00269     RT_CG_VERTEXSHADER,
00270     RT_CG_PIXELSHADER,
00271     RT_FORCE_DWORD           = 0x7fffffff /* force 32-bit size enum */
00272   };
00273 
00274   /* Multi-Sample buffer types */
00275   typedef enum
00276   {
00277     MULTISAMPLE_TYPE_NONE            =  0,
00278     MULTISAMPLE_TYPE_NONMASKABLE     =  1,
00279     MULTISAMPLE_TYPE_2_SAMPLES       =  2,
00280     MULTISAMPLE_TYPE_3_SAMPLES       =  3,
00281     MULTISAMPLE_TYPE_4_SAMPLES       =  4,
00282     MULTISAMPLE_TYPE_5_SAMPLES       =  5,
00283     MULTISAMPLE_TYPE_6_SAMPLES       =  6,
00284     MULTISAMPLE_TYPE_7_SAMPLES       =  7,
00285     MULTISAMPLE_TYPE_8_SAMPLES       =  8,
00286     MULTISAMPLE_TYPE_9_SAMPLES       =  9,
00287     MULTISAMPLE_TYPE_10_SAMPLES      = 10,
00288     MULTISAMPLE_TYPE_11_SAMPLES      = 11,
00289     MULTISAMPLE_TYPE_12_SAMPLES      = 12,
00290     MULTISAMPLE_TYPE_13_SAMPLES      = 13,
00291     MULTISAMPLE_TYPE_14_SAMPLES      = 14,
00292     MULTISAMPLE_TYPE_15_SAMPLES      = 15,
00293     MULTISAMPLE_TYPE_16_SAMPLES      = 16,
00294     MULTISAMPLE_TYPE_FORCE_DWORD     = 0x7fffffff /* force 32-bit size enum */
00295   } MULTISAMPLE_TYPE;
00296 
00297   typedef enum
00298   {
00299     MEM_POOL_DEFAULT = 0,
00300     MEM_POOL_MANAGED = 1,
00301     MEM_POOL_SYSTEMMEM = 2,
00302     MEM_POOL_SCRATCH = 3,
00303     MEM_POOL_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */
00304   } MEM_POOL;
00305 
00306 
00307   typedef struct
00308   {
00309     OpenGLResourceType ResourceType;
00310     unsigned int Width;
00311     unsigned int Height;
00312     unsigned int Depth;
00313     BitmapFormat PixelFormat;
00314     unsigned int RowPitch;
00315     unsigned int SlicePitch;
00316     unsigned int BitsPerPixel;
00317     unsigned int WidthInBlocks;
00318     unsigned int HeightInBlocks;
00319     unsigned int DepthInBlocks;
00320     unsigned int BytesPerBlock;
00321     int ExpBias;
00322     DWORD Flags;
00323     MULTISAMPLE_TYPE MultiSampleType;
00324   } TEXTURE_DESC;
00325 
00326   typedef struct _SURFACE_DESC
00327   {
00328     BitmapFormat    PixelFormat;
00329     OpenGLResourceType     Type;
00330     DWORD               Usage;
00331     MEM_POOL             Pool;
00332 
00333     MULTISAMPLE_TYPE MultiSampleType;
00334     DWORD               MultiSampleQuality;
00335     unsigned int                Width;
00336     unsigned int                Height;
00337   } SURFACE_DESC;
00338 
00339   typedef struct _VOLUME_DESC
00340   {
00341     BitmapFormat PixelFormat;
00342     OpenGLResourceType Type;
00343     DWORD Usage;
00344     MEM_POOL Pool;
00345     unsigned int Width;
00346     unsigned int Height;
00347     unsigned int Depth;
00348   } VOLUME_DESC;
00349 
00350   typedef struct _ANIMATEDTEXTURE_DESC
00351   {
00352     BitmapFormat PixelFormat;
00353     OpenGLResourceType Type;
00354     DWORD Usage;
00355     MEM_POOL Pool;
00356     unsigned int Width;
00357     unsigned int Height;
00358     unsigned int Depth;
00359   } ANIMATEDTEXTURE_DESC;
00360 
00361   typedef struct _VERTEXBUFFER_DESC
00362   {
00363     VBO_USAGE Usage;
00364     unsigned int Size;
00365   } VERTEXBUFFER_DESC;
00366 
00367   typedef struct _INDEXBUFFER_DESC
00368   {
00369     INDEX_FORMAT Format;
00370     VBO_USAGE Usage;
00371     unsigned int Size;
00372   } INDEXBUFFER_DESC;
00373 
00374   typedef struct _LOCKED_RECT
00375   {
00376     int Pitch;
00377     void *pBits;
00378   } SURFACE_LOCKED_RECT;
00379 
00380   typedef struct _SURFACE_RECT
00381   {
00382     long left;      //Specifies the x-coordinate of the lower-left corner of the rectangle.
00383     long top;       //Specifies the y-coordinate of the lower-left corner of the rectangle.
00384     long right;     //Specifies the x-coordinate of the upper-right corner of the rectangle.
00385     long bottom;    //Specifies the y-coordinate of the upper-right corner of the rectangle.
00386   } SURFACE_RECT;
00387 
00388 
00389   /* Structures for LockBox */
00390   typedef struct _VOLUME_BOX
00391   {
00392     int                Left;
00393     int                Top;
00394     int                Right;
00395     int                Bottom;
00396     int                Front;
00397     int                Back;
00398   } VOLUME_BOX;
00399 
00400   typedef struct _VOLUME_LOCKED_BOX
00401   {
00402     int                 RowPitch;
00403     int                 SlicePitch;
00404     void               *pBits;
00405   } VOLUME_LOCKED_BOX;
00406 
00407   typedef enum _ATTRIB_DECL_TYPE
00408   {
00409     ATTRIB_DECLTYPE_UNKNOWN = 0,
00410     ATTRIB_DECLTYPE_FLOAT1,
00411     ATTRIB_DECLTYPE_FLOAT2,
00412     ATTRIB_DECLTYPE_FLOAT3,
00413     ATTRIB_DECLTYPE_FLOAT4,
00414     ATTRIB_DECLTYPE_COLOR,
00415     ATTRIB_DECLTYPE_UBYTE4,
00416     ATTRIB_DECLTYPE_SHORT2,
00417     ATTRIB_DECLTYPE_SHORT4,
00418     ATTRIB_DECLTYPE_UBYTE4N,
00419     ATTRIB_DECLTYPE_SHORT2N,
00420     ATTRIB_DECLTYPE_SHORT4N,
00421     ATTRIB_DECLTYPE_USHORT2N,
00422     ATTRIB_DECLTYPE_USHORT4N,
00423     ATTRIB_DECLTYPE_UDEC3,
00424     ATTRIB_DECLTYPE_DEC3N,
00425     ATTRIB_DECLTYPE_FLOAT16_2,
00426     ATTRIB_DECLTYPE_FLOAT16_4,
00427     ATTRIB_DECLTYPE_UNUSED,
00428     ATTRIB_DECLTYPE_FORCE_DWORD           = 0x7fffffff /* force 32-bit size enum */
00429   } ATTRIB_DECL_TYPE;
00430 
00431   typedef enum _ATTRIB_COMPONENT_TYPE
00432   {
00433     ATTRIB_CT_UNKNOWN           =   0,
00434     ATTRIB_CT_BYTE              =   GL_BYTE,
00435     ATTRIB_CT_UNSIGNED_BYTE     =   GL_UNSIGNED_BYTE,
00436     ATTRIB_CT_SHORT             =   GL_SHORT,
00437     ATTRIB_CT_UNSIGNED_SHORT    =   GL_UNSIGNED_SHORT,
00438     ATTRIB_CT_INT               =   GL_INT,
00439     ATTRIB_CT_UNSIGNED_INT      =   GL_UNSIGNED_INT,
00440     ATTRIB_CT_FLOAT             =   GL_FLOAT,
00441     ATTRIB_CT_HALF_FLOAT        =   GL_HALF_FLOAT_ARB,
00442 //    ATTRIB_CT_2_BYTES           =   GL_2_BYTES,
00443 //    ATTRIB_CT_3_BYTES           =   GL_3_BYTES,
00444 //    ATTRIB_CT_4_BYTES           =   GL_4_BYTES,
00445     ATTRIB_CT_DOUBLE            =   GL_DOUBLE,
00446 // Type can be GL_UNSIGNED_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE
00447     ATTRIB_CT_FORCE_DWORD           = 0x7fffffff /* force 32-bit size enum */
00448   } ATTRIB_COMPONENT_TYPE;
00449 
00450 // Binding Semantics
00451   typedef enum
00452   {
00453     ATTRIB_USAGE_DECL_POSITION       = 0,
00454     ATTRIB_USAGE_DECL_BLENDWEIGHT    = 1,
00455     ATTRIB_USAGE_DECL_NORMAL         = 2,
00456     ATTRIB_USAGE_DECL_COLOR          = 3,
00457     ATTRIB_USAGE_DECL_COLOR1         = 4,
00458     ATTRIB_USAGE_DECL_FOGCOORD       = 5,
00459     ATTRIB_USAGE_DECL_PSIZE          = 6,
00460     ATTRIB_USAGE_DECL_BLENDINDICES   = 7,
00461     ATTRIB_USAGE_DECL_TEXCOORD       = 8,
00462     ATTRIB_USAGE_DECL_TEXCOORD0      = 8,
00463     ATTRIB_USAGE_DECL_TEXCOORD1      = 9,
00464     ATTRIB_USAGE_DECL_TEXCOORD2      = 10,
00465     ATTRIB_USAGE_DECL_TEXCOORD3      = 11,
00466     ATTRIB_USAGE_DECL_TEXCOORD4      = 12,
00467     ATTRIB_USAGE_DECL_TEXCOORD5      = 13,
00468     ATTRIB_USAGE_DECL_TEXCOORD6      = 14,
00469     ATTRIB_USAGE_DECL_TEXCOORD7      = 15,
00470     ATTRIB_USAGE_DECL_TANGENT        = 14,
00471     ATTRIB_USAGE_DECL_BINORMAL       = 15,
00472     ATTRIB_USAGE_DECL_FORCE_DWORD    = 0x7fffffff /* force 32-bit size enum */
00473   } ATTRIB_USAGE_DECL;
00474 
00475   typedef enum
00476   {
00477     QUERY_TYPE_VCACHE                 = 4,
00478     QUERY_TYPE_RESOURCEMANAGER        = 5,
00479     QUERY_TYPE_VERTEXSTATS            = 6,
00480     QUERY_TYPE_EVENT                  = 8,
00481     QUERY_TYPE_OCCLUSION              = 9,
00482     QUERY_TYPE_SCREENEXTENT           = 10,
00483     QUERY_TYPE_FORCE_DWORD            = 0x7fffffff /* force 32-bit size enum */
00484   } QUERY_TYPE;
00485 
00486 // Flags field for Issue
00487 #define ISSUE_END (1 << 0) // Tells the runtime to issue the end of a query, changing it's state to "non-signaled".
00488 #define ISSUE_BEGIN (1 << 1) // Tells the runtime to issue the begining of a query.
00489 
00490   struct VERTEXELEMENT
00491   {
00492     VERTEXELEMENT()
00493     {
00494       Stream = 0;
00495       Offset = 0;
00496       Type = ATTRIB_CT_UNKNOWN;
00497       NumComponent = 0;
00498       stride_ = 0;
00499     }
00500 
00501     VERTEXELEMENT(
00502       int stream,
00503       int offset,
00504       ATTRIB_COMPONENT_TYPE type,
00505       BYTE numcomponents,
00506       int stride)
00507     {
00508       Stream = stream;
00509       Offset = offset;
00510       Type = type;
00511       NumComponent = numcomponents;
00512       stride_ = stride;
00513     }
00514 
00515     int Stream;
00516     int Offset;
00517     // Type can be GL_UNSIGNED_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE ...
00518     ATTRIB_COMPONENT_TYPE Type;
00519     // This can be 1, 2, 3 or 4; For a position (xyzw), it will be 4. For a texture coordinate (uv) it will be 2.
00520     int NumComponent;
00521     int stride_;
00522   };
00523 
00524 #define DECL_END VERTEXELEMENT( \
00525   0xFF,                       \
00526   0,                          \
00527   ATTRIB_CT_UNKNOWN,          \
00528   0, 0)
00529 
00530   unsigned int GetVertexElementSize (VERTEXELEMENT vtxelement);
00531 
00532 #define MAXDECLLENGTH    64
00533 #define MAX_NUM_STREAM  8
00534 
00535   void DecomposeTypeDeclaraction (ATTRIB_DECL_TYPE Type, BYTE &NumComponent, ATTRIB_COMPONENT_TYPE &ComponentType);
00536 
00537 //   void AddVertexElement (std::vector<VERTEXELEMENT>& Elements,
00538 //                          WORD Stream,
00539 //                          WORD Offset,
00540 //                          //ubiS16 Stride,
00541 //                          ATTRIB_DECL_TYPE Type,
00542 //                          ATTRIB_USAGE_DECL Usage,
00543 //                          BYTE UsageIndex);
00544 
00545   GLenum GetGLPrimitiveType(PRIMITIVE_TYPE InPrimitiveType);
00546   unsigned int GetGLElementCount(PRIMITIVE_TYPE InPrimitiveType, unsigned int InPrimitiveCount);
00547 }
00548 
00549 #endif // GLRESOURCE_H
00550 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends