# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/OpenGL.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.com                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #ifndef OpenGL_INCLUDE_ONCE
    00033 #define OpenGL_INCLUDE_ONCE
    00034
    00035 #include <vlCore/OpenGLDefs.hpp>
    00036 #include <vlGraphics/link_config.hpp>
    00037
    00038 #define GLEW_Has_Geometry_Shader (GLEW_NV_geometry_shader4||GLEW_EXT_geometry_shader4||GLEW_ARB_geometry_shader4||GLEW_VERSION_3_2||GLEW_VERSION_4_0)
    00039 #define GLEW_Has_Shading_Language_20 (GLEW_ARB_shading_language_100||GLEW_VERSION_2_0||GLEW_VERSION_3_0||GLEW_VERSION_4_0)
    00040 #define GLEW_Has_Shading_Language_21 (GLEW_VERSION_2_1||GLEW_VERSION_3_0||GLEW_VERSION_4_0)
    00041 #define GLEW_Has_Framebuffer_Object (GLEW_EXT_framebuffer_object||GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0||GLEW_VERSION_4_0)
    00042 #define GLEW_Has_Framebuffer_Object_Multisample (GLEW_VERSION_4_0||GLEW_VERSION_3_0||GLEW_ARB_framebuffer_object||GLEW_EXT_framebuffer_multisample)
    00043
    00044 namespace vl
    00045 {
    00046
    00047   //-----------------------------------------------------------------------------
    00048   // VL_CHECK_OGL
    00049   //-----------------------------------------------------------------------------
    00050
    00051   VLGRAPHICS_EXPORT int glcheck( const char* file, int line );
    00052
    00053   #if defined( _DEBUG ) || !defined( NDEBUG ) || VL_FORCE_CHECKS == 1
    00054     #define VL_CHECK_OGL( ) { if ( ::vl::glcheck( __FILE__, __LINE__ ) ) { VL_TRAP( ) } }
    00055   #else
    00056     #define VL_CHECK_OGL( );
    00057   #endif
    00058
    00059   //-----------------------------------------------------------------------------
    00060   // OpenGL functions wrappers
    00061   //-----------------------------------------------------------------------------
    00062
    00063   inline void VL_glBindBuffer( GLenum target, GLuint buffer )
    00064   {
    00065     if (GLEW_VERSION_1_5)
    00066       glBindBuffer(target,buffer);
    00067     else
    00068     if (GLEW_ARB_vertex_buffer_object)
    00069       glBindBufferARB(target,buffer);
    00070     else
    00071     {
    00072       VL_CHECK( buffer == 0 );
    00073     }
    00074   }
    00075
    00076   inline void VL_glGenBuffers( GLsizei n, GLuint * buffers)
    00077   {
    00078     if (GLEW_VERSION_1_5)
    00079       glGenBuffers( n, buffers);
    00080     else
    00081     if (GLEW_ARB_vertex_buffer_object)
    00082       glGenBuffersARB( n, buffers);
    00083     else
    00084       VL_TRAP();
    00085   }
    00086
    00087   inline void VL_glDeleteBuffers( GLsizei n, const GLuint * buffers)
    00088   {
    00089     if (GLEW_VERSION_1_5)
    00090       glDeleteBuffers( n, buffers);
    00091     else
    00092     if (GLEW_ARB_vertex_buffer_object)
    00093       glDeleteBuffersARB( n, buffers);
    00094     else
    00095       VL_TRAP();
    00096   }
    00097
    00098   inline void VL_glBufferData( GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
    00099   {
    00100     if (GLEW_VERSION_1_5)
    00101       glBufferData( target, size, data, usage);
    00102     else
    00103     if (GLEW_ARB_vertex_buffer_object)
    00104       glBufferDataARB( target, size, data, usage);
    00105     else
    00106       VL_TRAP();
    00107   }
    00108
    00109   inline void VL_glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data)
    00110   {
    00111     if (GLEW_VERSION_1_5)
    00112       glBufferSubData( target, offset, size, data );
    00113     else
    00114     if (GLEW_ARB_vertex_buffer_object)
    00115       glBufferSubDataARB( target, offset, size, data);
    00116     else
    00117       VL_TRAP();
    00118   }
    00119
    00120   inline void* VL_glMapBuffer( GLenum target, GLenum access)
    00121   {
    00122     if (GLEW_VERSION_1_5)
    00123       return glMapBuffer( target, access);
    00124     else
    00125     if (GLEW_ARB_vertex_buffer_object)
    00126       return glMapBufferARB( target, access);
    00127     else
    00128       VL_TRAP();
    00129     return NULL;
    00130   }
    00131
    00132   inline GLboolean VL_glUnmapBuffer(GLenum target)
    00133   {
    00134     if (GLEW_VERSION_1_5)
    00135       return glUnmapBuffer( target );
    00136     else
    00137     if (GLEW_ARB_vertex_buffer_object)
    00138       return glUnmapBufferARB( target );
    00139     else
    00140       VL_TRAP();
    00141     return GL_FALSE;
    00142   }
    00143
    00144   //-----------------------------------------------------------------------------
    00145
    00146   inline void VL_glSecondaryColor3f(float r, float g, float b)
    00147   {
    00148     if(GLEW_VERSION_1_4)
    00149       glSecondaryColor3f(r,g,b);
    00150     else
    00151     if(GLEW_EXT_secondary_color)
    00152       glSecondaryColor3fEXT(r,g,b);
    00153     else
    00154       VL_TRAP();
    00155   }
    00156
    00157   inline void VL_glSecondaryColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
    00158   {
    00159     if(GLEW_VERSION_1_4)
    00160       glSecondaryColorPointer(size, type, stride, (GLvoid*)pointer);
    00161     else
    00162     if(GLEW_EXT_secondary_color)
    00163       glSecondaryColorPointerEXT(size, type, stride, (GLvoid*)pointer);
    00164     else
    00165       VL_TRAP();
    00166   }
    00167
    00168   //-----------------------------------------------------------------------------
    00169
    00170   inline void VL_glFogCoordPointer( GLenum type, GLsizei stride, GLvoid* pointer )
    00171   {
    00172     if (GLEW_VERSION_1_4)
    00173       glFogCoordPointer(type,stride,pointer);
    00174     else
    00175     if (GLEW_EXT_fog_coord)
    00176       glFogCoordPointerEXT(type,stride,pointer);
    00177     else
    00178       VL_TRAP();
    00179   }
    00180
    00181   //-----------------------------------------------------------------------------
    00182
    00183   inline void VL_glEnableVertexAttribArray( GLuint index )
    00184   {
    00185     if (GLEW_VERSION_2_0)
    00186       glEnableVertexAttribArray(index);
    00187     else
    00188     if (GLEW_ARB_vertex_program)
    00189       glEnableVertexAttribArrayARB(index);
    00190     else
    00191       VL_TRAP();
    00192   }
    00193
    00194   inline void VL_glDisableVertexAttribArray( GLuint index )
    00195   {
    00196     if (GLEW_VERSION_2_0)
    00197       glDisableVertexAttribArray(index);
    00198     else
    00199     if (GLEW_ARB_vertex_program)
    00200       glDisableVertexAttribArrayARB(index);
    00201     else
    00202       VL_TRAP();
    00203   }
    00204
    00205   //-----------------------------------------------------------------------------
    00206
    00207   inline void VL_glVertexAttribPointer( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer)
    00208   {
    00209     if (GLEW_VERSION_2_0)
    00210       glVertexAttribPointer(index, size, type, normalized, stride, pointer);
    00211     else
    00212     if (GLEW_ARB_vertex_program)
    00213       glVertexAttribPointerARB(index, size, type, normalized, stride, pointer);
    00214     else
    00215       VL_TRAP();
    00216   }
    00217
    00218   inline void VL_glVertexAttribIPointer(GLuint name, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
    00219   {
    00220     if(GLEW_VERSION_3_0)
    00221       glVertexAttribIPointer(name, size, type, stride, pointer);
    00222     else
    00223     if (GLEW_EXT_gpu_shader4)
    00224       glVertexAttribIPointerEXT(name, size, type, stride, pointer);
    00225     else
    00226       VL_TRAP();
    00227   }
    00228
    00229   inline void VL_glVertexAttribLPointer(GLuint name, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
    00230   {
    00231     if(GLEW_ARB_vertex_attrib_64bit)
    00232       glVertexAttribLPointer(name, size, type, stride, pointer);
    00233     else
    00234     if(GLEW_EXT_vertex_attrib_64bit)
    00235       glVertexAttribLPointerEXT(name, size, type, stride, pointer);
    00236     else
    00237       VL_TRAP();
    00238   }
    00239
    00240   //-----------------------------------------------------------------------------
    00241
    00242   inline void VL_glClientActiveTexture(GLenum texture)
    00243   {
    00244     if(GLEW_VERSION_1_3)
    00245       glClientActiveTexture(texture);
    00246     else
    00247     if (GLEW_ARB_multitexture)
    00248       glClientActiveTextureARB(texture);
    00249     else
    00250     {
    00251       VL_CHECK(texture == GL_TEXTURE0);
    00252     }
    00253   }
    00254
    00255   inline void VL_glActiveTexture(GLenum texture)
    00256   {
    00257     if(GLEW_VERSION_1_3)
    00258       glActiveTexture(texture);
    00259     else
    00260     if (GLEW_ARB_multitexture)
    00261       glActiveTextureARB(texture);
    00262     else
    00263     {
    00264       VL_CHECK(texture == GL_TEXTURE0);
    00265     }
    00266   }
    00267
    00268   //-----------------------------------------------------------------------------
    00269
    00270   inline void VL_glBlendFuncSeparate( GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
    00271   {
    00272     if (GLEW_VERSION_1_4)
    00273       glBlendFuncSeparate( srcRGB, dstRGB, srcAlpha, dstAlpha);
    00274     else
    00275     if (GLEW_EXT_blend_func_separate)
    00276       glBlendFuncSeparateEXT( srcRGB, dstRGB, srcAlpha, dstAlpha);
    00277     else
    00278       VL_TRAP();
    00279   }
    00280
    00281   inline void VL_glBlendEquationSeparate( GLenum modeRGB, GLenum modeAlpha)
    00282   {
    00283     if (GLEW_VERSION_2_0)
    00284       glBlendEquationSeparate(modeRGB, modeAlpha);
    00285     else
    00286     if(GLEW_EXT_blend_equation_separate)
    00287       glBlendEquationSeparateEXT(modeRGB, modeAlpha);
    00288     else
    00289       VL_TRAP();
    00290   }
    00291
    00292   inline void VL_glBlendEquation(GLenum mode)
    00293   {
    00294     if (GLEW_VERSION_1_4)
    00295       glBlendEquation(mode);
    00296     else
    00297     if (GLEW_EXT_blend_minmax)
    00298       glBlendEquationEXT(mode);
    00299     else
    00300       VL_TRAP();
    00301   }
    00302
    00303   inline void VL_glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
    00304   {
    00305     if(GLEW_VERSION_1_4)
    00306       glBlendColor(red,green,blue,alpha);
    00307     else
    00308     if (GLEW_EXT_blend_color)
    00309       glBlendColorEXT(red,green,blue,alpha);
    00310     else
    00311       VL_TRAP();
    00312   }
    00313
    00314   //-----------------------------------------------------------------------------
    00315
    00316   inline void VL_glPointParameterfv( GLenum pname, const GLfloat* params)
    00317   {
    00318     if (GLEW_VERSION_1_4||GLEW_VERSION_3_0)
    00319       glPointParameterfv(pname,(GLfloat*)params);
    00320     else
    00321     if (GLEW_ARB_point_parameters)
    00322       glPointParameterfvARB(pname,(GLfloat*)params);
    00323     else
    00324     if (GLEW_EXT_point_parameters)
    00325       glPointParameterfvEXT(pname,(GLfloat*)params);
    00326     else
    00327       VL_TRAP();
    00328   }
    00329
    00330   inline void VL_glPointParameterf( GLenum pname, GLfloat param)
    00331   {
    00332     if (GLEW_VERSION_1_4||GLEW_VERSION_3_0)
    00333       glPointParameterf(pname,param);
    00334     else
    00335     if (GLEW_ARB_point_parameters)
    00336       glPointParameterfARB(pname,param);
    00337     else
    00338     if (GLEW_EXT_point_parameters)
    00339       glPointParameterfEXT(pname,param);
    00340     else
    00341       VL_TRAP();
    00342   }
    00343
    00344   inline void VL_glPointParameteri( GLenum pname, GLenum param)
    00345   {
    00346     if (GLEW_VERSION_1_4||GLEW_VERSION_3_0)
    00347       glPointParameteri(pname,param);
    00348     else
    00349     if (GLEW_NV_point_sprite)
    00350       glPointParameteriNV(pname,param);
    00351     else
    00352       VL_TRAP();
    00353   }
    00354
    00355   //-----------------------------------------------------------------------------
    00356
    00357   inline void VL_glStencilFuncSeparate( GLenum face, GLenum func, GLint ref, GLuint mask)
    00358   {
    00359     if ( GLEW_VERSION_2_0 )
    00360       glStencilFuncSeparate( face, func, ref, mask );
    00361     else
    00362       VL_TRAP();
    00363     // NOT SUPPORTED
    00364     // see also http://www.opengl.org/registry/specs/ATI/separate_stencil.txt
    00365     /*else
    00366     if ( GLEW_ATI_separate_stencil )
    00367       glStencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) */
    00368   }
    00369
    00370   inline void VL_glStencilOpSeparate( GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
    00371   {
    00372     if ( GLEW_VERSION_2_0 )
    00373       glStencilOpSeparate( face, sfail, dpfail, dppass );
    00374     else
    00375       VL_TRAP();
    00376     // NOT SUPPORTED
    00377     // see also http://www.opengl.org/registry/specs/ATI/separate_stencil.txt
    00378     /*else
    00379     if ( GLEW_ATI_separate_stencil )
    00380       glStencilOpSeparateATI( GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass )*/
    00381   }
    00382
    00383   //-----------------------------------------------------------------------------
    00384
    00385   inline void VL_glSampleCoverage( GLclampf value, GLboolean invert)
    00386   {
    00387     if (GLEW_VERSION_1_3)
    00388       glSampleCoverage(value,invert);
    00389     else
    00390     if (GLEW_ARB_multisample)
    00391       glSampleCoverageARB(value,invert);
    00392     else
    00393       VL_TRAP();
    00394   }
    00395
    00396   //-----------------------------------------------------------------------------
    00397
    00398   inline void VL_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
    00399   {
    00400     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00401       glBindRenderbuffer(target, renderbuffer);
    00402     else
    00403     if (GLEW_EXT_framebuffer_object)
    00404       glBindRenderbufferEXT(target, renderbuffer);
    00405     else
    00406       VL_TRAP();
    00407   }
    00408
    00409   inline void VL_glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
    00410   {
    00411     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00412       glDeleteRenderbuffers(n, renderbuffers);
    00413     else
    00414     if (GLEW_EXT_framebuffer_object)
    00415       glDeleteRenderbuffersEXT(n, renderbuffers);
    00416     else
    00417       VL_TRAP();
    00418   }
    00419
    00420   inline void VL_glGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
    00421   {
    00422     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00423       glGenRenderbuffers(n, renderbuffers);
    00424     else
    00425     if (GLEW_EXT_framebuffer_object)
    00426       glGenRenderbuffersEXT(n, renderbuffers);
    00427     else
    00428       VL_TRAP();
    00429   }
    00430
    00431   inline void VL_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
    00432   {
    00433     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00434       glRenderbufferStorage(target, internalformat, width, height);
    00435     else
    00436     if (GLEW_EXT_framebuffer_object)
    00437       glRenderbufferStorageEXT(target, internalformat, width, height);
    00438     else
    00439       VL_TRAP();
    00440   }
    00441
    00442   inline void VL_glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
    00443   {
    00444     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00445       glGetRenderbufferParameteriv(target, pname, params);
    00446     else
    00447     if (GLEW_EXT_framebuffer_object)
    00448       glGetRenderbufferParameterivEXT(target, pname, params);
    00449     else
    00450       VL_TRAP();
    00451   }
    00452
    00453   inline GLboolean VL_glIsFramebuffer(GLuint framebuffer)
    00454   {
    00455     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00456       return glIsFramebuffer(framebuffer);
    00457     else
    00458     if (GLEW_EXT_framebuffer_object)
    00459       return glIsFramebufferEXT(framebuffer);
    00460     else
    00461       VL_TRAP();
    00462     return GL_FALSE;
    00463   }
    00464
    00465   inline void VL_glBindFramebuffer(GLenum target, GLuint framebuffer)
    00466   {
    00467     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00468       glBindFramebuffer(target, framebuffer);
    00469     else
    00470     if (GLEW_EXT_framebuffer_object)
    00471       glBindFramebufferEXT(target, framebuffer);
    00472     else
    00473     {
    00474       VL_CHECK(framebuffer == 0);
    00475     }
    00476   }
    00477
    00478   inline void VL_glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
    00479   {
    00480     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00481       glDeleteFramebuffers(n, framebuffers);
    00482     else
    00483     if (GLEW_EXT_framebuffer_object)
    00484       glDeleteFramebuffersEXT(n, framebuffers);
    00485     else
    00486       VL_TRAP();
    00487   }
    00488
    00489   inline void VL_glGenFramebuffers(GLsizei n, GLuint *framebuffers)
    00490   {
    00491     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00492       glGenFramebuffers(n, framebuffers);
    00493     else
    00494     if (GLEW_EXT_framebuffer_object)
    00495       glGenFramebuffersEXT(n, framebuffers);
    00496     else
    00497       VL_TRAP();
    00498   }
    00499
    00500   inline GLenum VL_glCheckFramebufferStatus(GLenum target)
    00501   {
    00502     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00503       return glCheckFramebufferStatus(target);
    00504     else
    00505     if (GLEW_EXT_framebuffer_object)
    00506       return glCheckFramebufferStatusEXT(target);
    00507     else
    00508       VL_TRAP();
    00509
    00510     return GL_FRAMEBUFFER_UNSUPPORTED;
    00511   }
    00512
    00513   inline void VL_glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
    00514   {
    00515     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00516       glFramebufferTexture1D(target, attachment, textarget, texture, level);
    00517     else
    00518     if (GLEW_EXT_framebuffer_object)
    00519       glFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
    00520     else
    00521       VL_TRAP();
    00522   }
    00523
    00524   inline void VL_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
    00525   {
    00526     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00527       glFramebufferTexture2D(target, attachment, textarget, texture, level);
    00528     else
    00529     if (GLEW_EXT_framebuffer_object)
    00530       glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
    00531     else
    00532       VL_TRAP();
    00533   }
    00534
    00535   inline void VL_glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
    00536   {
    00537     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00538       glFramebufferTexture3D(target, attachment, textarget, texture, level, zoffset);
    00539     else
    00540     if (GLEW_EXT_framebuffer_object)
    00541       glFramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset);
    00542     else
    00543       VL_TRAP();
    00544   }
    00545
    00546   inline void VL_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
    00547   {
    00548     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00549       glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
    00550     else
    00551     if (GLEW_EXT_framebuffer_object)
    00552       glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
    00553     else
    00554       VL_TRAP();
    00555   }
    00556
    00557   inline void VL_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params)
    00558   {
    00559     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00560       glGetFramebufferAttachmentParameteriv(target,attachment,pname,params);
    00561     else
    00562     if (GLEW_EXT_framebuffer_object)
    00563       glGetFramebufferAttachmentParameterivEXT(target,attachment,pname,params);
    00564     else
    00565       VL_TRAP();
    00566   }
    00567
    00568   inline void VL_glGenerateMipmap(GLenum target)
    00569   {
    00570     if (GLEW_ARB_framebuffer_object||GLEW_VERSION_3_0)
    00571       glGenerateMipmap(target);
    00572     else
    00573     if (GLEW_EXT_framebuffer_object)
    00574       glGenerateMipmapEXT(target);
    00575     else
    00576       VL_TRAP();
    00577   }
    00578
    00579   inline void VL_glFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level)
    00580   {
    00581     // even if this extension is signed ad ARB it does not appear in the GL 3.0 specs
    00582     if (GLEW_ARB_geometry_shader4)
    00583       glFramebufferTextureARB(target,attachment,texture,level);
    00584     else
    00585     if (GLEW_EXT_geometry_shader4)
    00586       glFramebufferTextureEXT(target,attachment,texture,level);
    00587     else
    00588       VL_TRAP();
    00589   }
    00590
    00591   inline void VL_glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
    00592   {
    00593     // mix fixme: missing function -> GLEW bug?
    00594     //if (GLEW_VERSION_3_0)
    00595     //  glFramebufferTextureLayer(target, attachment, texture, level, layer);
    00596     //else
    00597     if (GLEW_ARB_geometry_shader4)
    00598       glFramebufferTextureLayerARB(target, attachment, texture, level, layer);
    00599     else
    00600     if (GLEW_EXT_geometry_shader4||GLEW_EXT_texture_array)
    00601       glFramebufferTextureLayerEXT(target, attachment, texture, level, layer);
    00602     else
    00603       VL_TRAP();
    00604   }
    00605
    00606   inline void VL_glRenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height )
    00607   {
    00608     if (GLEW_VERSION_3_0||GLEW_ARB_framebuffer_object)
    00609       glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
    00610     else
    00611     if (GLEW_EXT_framebuffer_multisample)
    00612       glRenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height);
    00613     else
    00614       VL_TRAP();
    00615   }
    00616
    00617   inline void VL_glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
    00618   {
    00619     if (GLEW_ARB_framebuffer_object)
    00620       glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
    00621     else
    00622     if (GLEW_EXT_framebuffer_blit)
    00623       glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
    00624     else
    00625       VL_TRAP();
    00626   }
    00627
    00628   //-----------------------------------------------------------------------------
    00629
    00630   inline void VL_glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
    00631   {
    00632     if (GLEW_VERSION_3_1)
    00633       glDrawElementsInstanced(mode, count, type, indices, primcount);
    00634     else
    00635     if (GLEW_ARB_draw_instanced)
    00636       glDrawElementsInstancedARB(mode, count, type, indices, primcount);
    00637     else
    00638     if (GLEW_EXT_draw_instanced)
    00639       glDrawElementsInstancedEXT(mode, count, type, indices, primcount);
    00640     else
    00641       VL_TRAP();
    00642   }
    00643
    00644   inline void VL_glDrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, int basevertex)
    00645   {
    00646     if (GLEW_VERSION_3_2)
    00647       glDrawElementsInstancedBaseVertex(mode, count, type, indices, primcount, basevertex);
    00648     else
    00649       VL_TRAP();
    00650   }
    00651
    00652   inline void VL_glDrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, int basevertex)
    00653   {
    00654     if (GLEW_VERSION_3_2 || GLEW_ARB_draw_elements_base_vertex)
    00655       glDrawElementsBaseVertex(mode, count, type, (void*)indices, basevertex);
    00656     else
    00657       VL_TRAP();
    00658   }
    00659
    00660   inline void VL_glDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, int basevertex)
    00661   {
    00662     if (GLEW_VERSION_3_2 || GLEW_ARB_draw_elements_base_vertex)
    00663       glDrawRangeElementsBaseVertex(mode, start, end, count, type, (void*)indices, basevertex);
    00664     else
    00665       VL_TRAP();
    00666   }
    00667
    00668   inline void VL_glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
    00669   {
    00670     if (GLEW_VERSION_3_1)
    00671       glDrawArraysInstanced(mode, first, count, primcount);
    00672     else
    00673     if (GLEW_ARB_draw_instanced)
    00674       glDrawArraysInstancedARB(mode, first, count, primcount);
    00675     else
    00676     if (GLEW_EXT_draw_instanced)
    00677       glDrawArraysInstancedEXT(mode, first, count, primcount);
    00678     else
    00679       VL_TRAP();
    00680   }
    00681
    00682   //-----------------------------------------------------------------------------
    00683
    00684   inline void VL_glProgramParameteri(GLuint program, GLenum pname, GLint value)
    00685   {
    00686     if (GLEW_ARB_geometry_shader4)
    00687       glProgramParameteriARB(program, pname, value);
    00688     else
    00689     if (GLEW_EXT_geometry_shader4)
    00690       glProgramParameteriEXT(program, pname, value);
    00691     else
    00692       VL_TRAP();
    00693   }
    00694
    00695   inline void VL_glBindFragDataLocation(GLuint program, GLuint colorNumber, const GLchar *name)
    00696   {
    00697     if (GLEW_VERSION_3_0)
    00698       glBindFragDataLocation(program, colorNumber, name);
    00699     else
    00700     if (GLEW_EXT_gpu_shader4)
    00701       glBindFragDataLocationEXT(program, colorNumber, name);
    00702     else
    00703       VL_TRAP();
    00704   }
    00705
    00706   inline void VL_glUniform1uiv(GLint location, GLsizei count, const GLuint *value)
    00707   {
    00708     if (GLEW_VERSION_3_0)
    00709       glUniform1uiv(location, count, value);
    00710     else
    00711     if (GLEW_EXT_gpu_shader4)
    00712       glUniform1uivEXT(location, count, value);
    00713     else
    00714       VL_TRAP();
    00715   }
    00716
    00717   inline void VL_glUniform2uiv(GLint location, GLsizei count, const GLuint *value)
    00718   {
    00719     if (GLEW_VERSION_3_0)
    00720       glUniform2uiv(location, count, value);
    00721     else
    00722     if (GLEW_EXT_gpu_shader4)
    00723       glUniform2uivEXT(location, count, value);
    00724     else
    00725       VL_TRAP();
    00726   }
    00727
    00728   inline void VL_glUniform3uiv(GLint location, GLsizei count, const GLuint *value)
    00729   {
    00730     if (GLEW_VERSION_3_0)
    00731       glUniform3uiv(location, count, value);
    00732     else
    00733     if (GLEW_EXT_gpu_shader4)
    00734       glUniform3uivEXT(location, count, value);
    00735     else
    00736       VL_TRAP();
    00737   }
    00738
    00739   inline void VL_glUniform4uiv(GLint location, GLsizei count, const GLuint *value)
    00740   {
    00741     if (GLEW_VERSION_3_0)
    00742       glUniform4uiv(location, count, value);
    00743     else
    00744     if (GLEW_EXT_gpu_shader4)
    00745       glUniform4uivEXT(location, count, value);
    00746     else
    00747       VL_TRAP();
    00748   }
    00749
    00750   //------------------------------------------------------------------------------
    00751
    00752 }
    00753
    00754 #endif

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:24.
Permission is granted to use this page to write and publish articles regarding Visualization Library.