Back to index

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