1 #ifndef COIN_GLUWRAPPER_H 2 #define COIN_GLUWRAPPER_H 3 4 /**************************************************************************\ 5 * Copyright (c) Kongsberg Oil & Gas Technologies AS 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * Neither the name of the copyright holder nor the names of its 20 * contributors may be used to endorse or promote products derived from 21 * this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 \**************************************************************************/ 35 36 #ifndef COIN_INTERNAL 37 #error this is a private header file 38 #endif 39 40 #ifdef HAVE_CONFIG_H 41 #include <config.h> 42 #endif /* HAVE_CONFIG_H */ 43 44 #ifdef HAVE_WINDOWS_H 45 #include <windows.h> /* to pick up the APIENTRY define */ 46 #endif /* HAVE_WINDOWS_H */ 47 48 #include <Inventor/system/gl.h> 49 50 /* Under Win32, we need to make sure we use the correct calling method 51 by using the APIENTRY define for the function signature types (or 52 else we'll get weird stack errors). On other platforms, just define 53 APIENTRY empty. */ 54 #ifndef APIENTRY 55 #define APIENTRY 56 #endif /* !APIENTRY */ 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif /* __cplusplus */ 61 62 /* Callback func type. */ 63 typedef void (APIENTRY * gluNurbsCallback_cb_t)(void *, ...); 64 65 /* Typedefinitions of function signatures for GLU calls we use. We 66 need these for casting from the void-pointer return of dlsym().*/ 67 typedef const GLubyte * (APIENTRY *gluGetString_t)(GLenum); 68 typedef const GLubyte * (APIENTRY *gluErrorString_t)(GLenum); 69 typedef GLint (APIENTRY *gluScaleImage_t)(GLenum, GLsizei, GLsizei, GLenum, const void *, GLsizei, GLsizei, GLenum, GLvoid *); 70 71 /* The first argument for these methods is actually either GLUnurbs or 72 GLUnurbsObj, depending on the GLU version (yes, they managed to 73 change the API over version 1.x to 1.y, for some value of [0, 3] 74 for x and y, where x < y). */ 75 typedef void * (APIENTRY *gluNewNurbsRenderer_t)(void); 76 typedef void (APIENTRY *gluDeleteNurbsRenderer_t)(void *); 77 typedef void (APIENTRY *gluNurbsProperty_t)(void *, GLenum, GLfloat); 78 typedef void (APIENTRY *gluLoadSamplingMatrices_t)(void *, const GLfloat *, const GLfloat *, const GLint *); 79 typedef void (APIENTRY *gluBeginSurface_t)(void *); 80 typedef void (APIENTRY *gluEndSurface_t)(void *); 81 typedef void (APIENTRY *gluNurbsSurface_t)(void *, GLint, GLfloat *, GLint, GLfloat *, GLint, GLint, GLfloat *, GLint, GLint, GLenum); 82 typedef void (APIENTRY *gluBeginTrim_t)(void *); 83 typedef void (APIENTRY *gluEndTrim_t)(void *); 84 typedef void (APIENTRY *gluBeginCurve_t)(void *); 85 typedef void (APIENTRY *gluEndCurve_t)(void *); 86 typedef void (APIENTRY *gluNurbsCurve_t)(void *, GLint, GLfloat *, GLint, GLfloat *, GLint, GLenum); 87 typedef void (APIENTRY *gluPwlCurve_t)(void *, GLint, GLfloat *, GLint, GLenum); 88 typedef void (APIENTRY *gluNurbsCallback_t)(void *, GLenum, gluNurbsCallback_cb_t); 89 typedef void (APIENTRY *gluNurbsCallbackData_t)(void *, GLvoid *); 90 91 /* gluTessellator routines */ 92 typedef struct coin_GLUtessellator coin_GLUtessellator; 93 typedef coin_GLUtessellator * (APIENTRY *gluNewTess_t)(void); 94 typedef void (APIENTRY *gluTessCallback_cb_t)(void); 95 96 typedef void (APIENTRY *gluTessCallback_t)(coin_GLUtessellator *, GLenum, gluTessCallback_cb_t); 97 typedef void (APIENTRY *gluTessProperty_t)(coin_GLUtessellator * tessobj, GLenum property, GLdouble value); 98 typedef void (APIENTRY *gluTessBeginPolygon_t)(coin_GLUtessellator * tessobj, void * user_data); 99 typedef void (APIENTRY *gluTessEndPolygon_t)(coin_GLUtessellator * tessobj); 100 typedef void (APIENTRY *gluTessBeginContour_t)(coin_GLUtessellator * tessobj); 101 typedef void (APIENTRY *gluTessEndContour_t)(coin_GLUtessellator * tessobj); 102 typedef void (APIENTRY *gluTessVertex_t)(coin_GLUtessellator * tessobj, GLdouble coords[3], void * vertex_data); 103 typedef void (APIENTRY *gluDeleteTess_t)(coin_GLUtessellator * tessobj); 104 typedef void (APIENTRY *gluTessNormal_t)(coin_GLUtessellator * tessobj, GLdouble x, GLdouble y, GLdouble z); 105 106 typedef struct { 107 /* Is the GLU library at all available? */ 108 int available; 109 110 /* GLU versioning. */ 111 struct { 112 unsigned int major, minor, release; 113 } version; 114 int (*versionMatchesAtLeast)(unsigned int major, 115 unsigned int minor, 116 unsigned int release); 117 118 /* 119 GLU calls which might be used. Note that any of these can be NULL 120 pointers if the function is not available, unless marked as being 121 always available. (That is, as long as GLU itself is available.) 122 */ 123 124 gluGetString_t gluGetString; 125 gluErrorString_t gluErrorString; 126 gluScaleImage_t gluScaleImage; /* always present */ 127 gluNewNurbsRenderer_t gluNewNurbsRenderer; 128 gluDeleteNurbsRenderer_t gluDeleteNurbsRenderer; 129 gluNurbsProperty_t gluNurbsProperty; 130 gluLoadSamplingMatrices_t gluLoadSamplingMatrices; 131 gluBeginSurface_t gluBeginSurface; 132 gluEndSurface_t gluEndSurface; 133 gluNurbsSurface_t gluNurbsSurface; 134 gluBeginTrim_t gluBeginTrim; 135 gluEndTrim_t gluEndTrim; 136 gluBeginCurve_t gluBeginCurve; 137 gluEndCurve_t gluEndCurve; 138 gluNurbsCurve_t gluNurbsCurve; 139 gluPwlCurve_t gluPwlCurve; 140 gluNurbsCallback_t gluNurbsCallback; 141 gluNurbsCallbackData_t gluNurbsCallbackData; 142 143 gluNewTess_t gluNewTess; 144 gluTessCallback_t gluTessCallback; 145 gluTessProperty_t gluTessProperty; 146 gluTessBeginPolygon_t gluTessBeginPolygon; 147 gluTessEndPolygon_t gluTessEndPolygon; 148 gluTessBeginContour_t gluTessBeginContour; 149 gluTessEndContour_t gluTessEndContour; 150 gluTessVertex_t gluTessVertex; 151 gluDeleteTess_t gluDeleteTess; 152 gluTessNormal_t gluTessNormal; 153 154 gluNurbsSurface_t gluNurbsSurface_in_GLU; 155 156 } GLUWrapper_t; 157 158 159 const GLUWrapper_t * GLUWrapper(void); 160 161 162 #ifdef __cplusplus 163 } 164 #endif /* __cplusplus */ 165 166 #endif /* COIN_GLUWRAPPER_H */ 167