Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OpenGLExtensions.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: OpenGLExtensions.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.58 $       $Date: 2020/02/26 06:00:57 $
00015  *
00016  ***************************************************************************/
00023 #ifndef OPENGLEXTENSIONS_H
00024 #define OPENGLEXTENSIONS_H
00025 
00026 #if defined(_MSC_VER)
00027 #include <windows.h>
00028 #endif
00029 
00030 // The Linux OpenGL ABI 1.0 spec requires that we define
00031 // GL_GLEXT_PROTOTYPES before including gl.h or glx.h for extensions
00032 // in order to get prototypes:
00033 //   http://oss.sgi.com/projects/ogl-sample/ABI/index.html
00034 #define GL_GLEXT_PROTOTYPES   1
00035 #define GLX_GLXEXT_PROTOTYPES 1
00036 
00037 #if defined(__APPLE__) && !defined (VMDMESA) 
00038 #include <OpenGL/gl.h>
00039 #else
00040 #include <GL/gl.h>
00041 #endif
00042 
00043 #if defined(VMDUSELIBGLU)
00044 #if defined(__APPLE__) && !defined (VMDMESA) 
00045 #include <OpenGL/glu.h>
00046 #else
00047 #include <GL/glu.h>
00048 #endif
00049 #endif
00050 
00051 // NOTE: you may have to get copies of the latest OpenGL extension headers
00052 // from the OpenGL web site if your Linux machine lacks them:
00053 //   http://oss.sgi.com/projects/ogl-sample/registry/
00054 #if (defined(__linux) || defined(_MSC_VER)) && !defined(VMDMESA)
00055 #include <GL/glext.h>
00056 #endif
00057 #if defined(__APPLE__) && !defined(VMDMESA) 
00058 #include <OpenGL/glext.h>
00059 #endif
00060 
00061 // Add support for EGL contexts, eglGetProcAddress() 
00062 #if defined(VMDEGLPBUFFER)
00063 #include <EGL/egl.h>
00064 #endif
00065 
00066 // required for Win32 calling conventions to work correctly
00067 #ifndef APIENTRY
00068 #define APIENTRY
00069 #endif
00070 #ifndef GLAPI
00071 #define GLAPI extern
00072 #endif
00073 
00074 // XXX enable OpenGL Shading Language support if it is available in the headers
00075 #if 1 && defined(GL_ARB_shader_objects)
00076 #define VMDUSEOPENGLSHADER 1
00077 #endif
00078 
00079 // prevent vendor-specific header file clashes
00080 typedef void (APIENTRY *VMDGLXextFuncPtr)(void);
00081 
00082 // XXX Newer OpenGL extensions cause problems on Linux/Windows/Mac because
00083 //     they don't gaurantee runtime linkage, even for ARB extensions.
00084 //     To use them, we must look them up at runtime with vmdProcAddress()
00085 //      which wraps display- and system-dependent methods for doing so.
00086 #if defined(_MSC_VER) || defined(__APPLE__) || defined(__irix) || (!defined(ARCH_SOLARIS2) && !defined(ARCH_SOLARIS2_64))
00087 
00088 #define VMDUSEGETPROCADDRESS 1
00089 #define GLLOCKARRAYSEXT           ext->p_glLockArraysEXT
00090 #define GLUNLOCKARRAYSEXT         ext->p_glUnlockArraysEXT
00091 #define GLMULTIDRAWELEMENTSEXT    ext->p_glMultiDrawElementsEXT
00092 #define GLPOINTPARAMETERFARB      ext->p_glPointParameterfARB
00093 #define GLPOINTPARAMETERFVARB     ext->p_glPointParameterfvARB
00094 
00095 // OpenGL Shader Functions
00096 #define GLCREATESHADEROBJECTARB   ext->p_glCreateShaderObjectARB
00097 #define GLCREATEPROGRAMOBJECTARB  ext->p_glCreateProgramObjectARB
00098 #define GLUSEPROGRAMOBJECTARB     ext->p_glUseProgramObjectARB
00099 #define GLDETACHOBJECTARB         ext->p_glDetachObjectARB
00100 #define GLGETINFOLOGARB           ext->p_glGetInfoLogARB
00101 #define GLGETOBJECTPARAMETERIVARB ext->p_glGetObjectParameterivARB
00102 #define GLLINKPROGRAMARB          ext->p_glLinkProgramARB
00103 #define GLDELETEOBJECTARB         ext->p_glDeleteObjectARB
00104 #define GLATTACHOBJECTARB         ext->p_glAttachObjectARB
00105 #define GLCOMPILESHADERARB        ext->p_glCompileShaderARB
00106 #define GLSHADERSOURCEARB         ext->p_glShaderSourceARB
00107 #define GLGETUNIFORMLOCATIONARB   ext->p_glGetUniformLocationARB
00108 #define GLUNIFORM1IARB            ext->p_glUniform1iARB
00109 #define GLUNIFORM1FVARB           ext->p_glUniform1fvARB
00110 #define GLUNIFORM2FVARB           ext->p_glUniform2fvARB
00111 #define GLUNIFORM3FVARB           ext->p_glUniform3fvARB
00112 #define GLUNIFORM4FVARB           ext->p_glUniform4fvARB
00113 
00114 #else
00115 
00116 #define GLLOCKARRAYSEXT           glLockArraysEXT
00117 #define GLUNLOCKARRAYSEXT         glUnlockArraysEXT
00118 #define GLMULTIDRAWELEMENTSEXT    glMultiDrawElementsEXT
00119 #define GLPOINTPARAMETERFARB      glPointParameterfARB
00120 #define GLPOINTPARAMETERFVARB     glPointParameterfvARB
00121 
00122 // OpenGL Shader Functions
00123 #define GLCREATESHADEROBJECTARB   glCreateShaderObjectARB
00124 #define GLCREATEPROGRAMOBJECTARB  glCreateProgramObjectARB
00125 #define GLUSEPROGRAMOBJECTARB     glUseProgramObjectARB
00126 #define GLDETACHOBJECTARB         glDetachObjectARB
00127 #define GLGETINFOLOGARB           glGetInfoLogARB
00128 #define GLGETOBJECTPARAMETERIVARB glGetObjectParameterivARB
00129 #define GLLINKPROGRAMARB          glLinkProgramARB
00130 #define GLDELETEOBJECTARB         glDeleteObjectARB
00131 #define GLATTACHOBJECTARB         glAttachObjectARB
00132 #define GLCOMPILESHADERARB        glCompileShaderARB
00133 #define GLSHADERSOURCEARB         glShaderSourceARB
00134 #define GLGETUNIFORMLOCATIONARB   glGetUniformLocationARB
00135 #define GLUNIFORM1IARB            glUniform1iARB
00136 #define GLUNIFORM1FVARB           glUniform1fvARB
00137 #define GLUNIFORM2FVARB           glUniform2fvARB
00138 #define GLUNIFORM3FVARB           glUniform3fvARB
00139 #define GLUNIFORM4FVARB           glUniform4fvARB
00140 
00141 #endif
00142 
00143 
00144 // special case Linux and MacOS X as platforms that fail to use glProcAddress()
00145 // on core functions like glTexImage3D().
00146 #if defined(VMDUSEGETPROCADDRESS) && !defined(__linux) && !defined(__APPLE__)
00147 #define GLTEXIMAGE3D              ext->p_glTexImage3D
00148 #else
00149 #define GLTEXIMAGE3D              glTexImage3D
00150 #endif
00151 
00152 
00155 class OpenGLExtensions {
00156 private:
00157   void *gllibraryhandle;
00158 
00159 public: 
00160   // OpenGL buffers, extensions, and bonus features found on this display 
00161   int hasstereo;                 
00162   int stereodrawforced;          
00163   int hasmultisample;            
00164   int nummultisamples;           
00165   int hasstencilbuffer;          
00166   int hastex2d;                  
00167   int hastex3d;                  
00168   int hasmultidrawext;           
00169   int hascompiledvertexarrayext; 
00170   int hasrescalenormalext;       
00171   GLint multitextureunits;       
00172   int hasglarbtexnonpoweroftwo;  
00173   int hasglpointparametersext;   
00174   int hasglpointspritearb;       
00175   int hasglshadinglangarb;       
00176   int hasglshaderobjectsarb;     
00177   int hasglvertexshaderarb;      
00178   int hasglfragmentshaderarb;    
00179   int hasglgeometryshader4arb;   
00180   int hasglsampleshadingarb;     
00181  
00182   // OpenGL function pointers
00183   void (APIENTRY *p_glLockArraysEXT)(GLint, GLsizei);
00184   void (APIENTRY *p_glUnlockArraysEXT)(void);
00185   void (APIENTRY *p_glMultiDrawElementsEXT)(GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); 
00186   void (APIENTRY *p_glGlobalAlphaFactorfSUN)(GLfloat);
00187   void (APIENTRY *p_glPointParameterfARB)(GLenum, GLfloat);
00188   void (APIENTRY *p_glPointParameterfvARB)(GLenum, const GLfloat *);
00189   void (APIENTRY *p_glTexImage3D)(GLenum, GLint, GLint, 
00190                                   GLsizei, GLsizei, GLsizei, GLint, 
00191                                   GLenum, GLenum, const GLvoid *);
00192 
00193 
00194 //
00195 // Only enable OpenGL Shader code when we find exensions in the headers
00196 //
00197 #if defined(GL_ARB_shader_objects)
00198   // OpenGL Shader Function Pointers
00199   GLhandleARB (APIENTRY *p_glCreateShaderObjectARB)(GLenum shaderType);
00200   GLhandleARB (APIENTRY *p_glCreateProgramObjectARB)(void);
00201   void (APIENTRY *p_glUseProgramObjectARB)(GLhandleARB programObj);
00202   void (APIENTRY *p_glDetachObjectARB)(GLhandleARB containerObj, GLhandleARB attachedObj);
00203   void (APIENTRY *p_glGetInfoLogARB)(GLhandleARB obj,GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
00204   void (APIENTRY *p_glGetObjectParameterivARB)(GLhandleARB obj, GLenum pname, GLint *params);
00205   void (APIENTRY *p_glLinkProgramARB)(GLhandleARB programObj);
00206   void (APIENTRY *p_glDeleteObjectARB)(GLhandleARB obj);
00207   void (APIENTRY *p_glAttachObjectARB)(GLhandleARB containerObj, GLhandleARB obj);
00208   void (APIENTRY *p_glCompileShaderARB)(GLhandleARB shaderObj);
00209   void (APIENTRY *p_glShaderSourceARB)(GLhandleARB shaderObj, GLsizei count, const GLcharARB **strings, const GLint *length);
00210   GLint (APIENTRY *p_glGetUniformLocationARB)(GLhandleARB programObject, const GLcharARB *name);
00211   void (APIENTRY *p_glUniform1iARB)(GLint location, GLint v0);
00212   void (APIENTRY *p_glUniform1fvARB)(GLint location, GLsizei count, GLfloat *value);
00213   void (APIENTRY *p_glUniform2fvARB)(GLint location, GLsizei count, GLfloat *value);
00214   void (APIENTRY *p_glUniform3fvARB)(GLint location, GLsizei count, GLfloat *value);
00215   void (APIENTRY *p_glUniform4fvARB)(GLint location, GLsizei count, GLfloat *value);
00216 #endif
00217 
00218   enum rendenum { ATI, NVIDIA, MSOFTGDI, MESAGL, WIREGL, INTELSWR, GENERIC };
00219 
00220   // OpenGL Renderer version information
00221   int oglmajor;         
00222   int oglminor;         
00223   int oglrelease;       
00224   rendenum oglrenderer; 
00225 
00226 public:
00227   OpenGLExtensions(void);
00228   virtual ~OpenGLExtensions(void);
00229   void find_renderer(void);         
00230   void find_extensions(void);       
00231   int vmdQueryExtension(const char *extname);  
00232   void vmdQueryGLVersion(int *major, int *minor, int *release); 
00233   VMDGLXextFuncPtr vmdGetProcAddress(const char *); 
00234   void PrintExtensions(void);       
00235 };
00236 
00237 #endif
00238 

Generated on Tue Oct 15 02:44:35 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002