| 1 | /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield |
|---|
| 2 | * |
|---|
| 3 | * This library is open source and may be redistributed and/or modified under |
|---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
|---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
|---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
|---|
| 7 | * |
|---|
| 8 | * This library is distributed in the hope that it will be useful, |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | * OpenSceneGraph Public License for more details. |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | #ifndef OSG_GL |
|---|
| 15 | #define OSG_GL 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/Config> |
|---|
| 18 | #include <osg/Export> |
|---|
| 19 | |
|---|
| 20 | #if defined(OSG_GLES1_AVAILABLE) |
|---|
| 21 | |
|---|
| 22 | #ifdef __APPLE__ |
|---|
| 23 | //if its apple include the target defines so we can check for IOS |
|---|
| 24 | #include "TargetConditionals.h" |
|---|
| 25 | #include <OpenGLES/ES1/gl.h> |
|---|
| 26 | #else |
|---|
| 27 | #include <GLES/gl.h> |
|---|
| 28 | #endif |
|---|
| 29 | |
|---|
| 30 | #elif defined(OSG_GLES2_AVAILABLE) |
|---|
| 31 | |
|---|
| 32 | #ifdef __APPLE__ |
|---|
| 33 | //if its apple include the target defines so we can check for IOS |
|---|
| 34 | #include "TargetConditionals.h" |
|---|
| 35 | #include <OpenGLES/ES2/gl.h> |
|---|
| 36 | #else |
|---|
| 37 | #include <GLES2/gl2.h> |
|---|
| 38 | #endif |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | #else |
|---|
| 42 | |
|---|
| 43 | #ifndef WIN32 |
|---|
| 44 | |
|---|
| 45 | // Required for compatibility with glext.h sytle function definitions of |
|---|
| 46 | // OpenGL extensions, such as in src/osg/Point.cpp. |
|---|
| 47 | #ifndef APIENTRY |
|---|
| 48 | #define APIENTRY |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | #else // WIN32 |
|---|
| 52 | |
|---|
| 53 | #if defined(__CYGWIN__) || defined(__MINGW32__) |
|---|
| 54 | |
|---|
| 55 | #ifndef APIENTRY |
|---|
| 56 | #define GLUT_APIENTRY_DEFINED |
|---|
| 57 | #define APIENTRY __stdcall |
|---|
| 58 | #endif |
|---|
| 59 | // XXX This is from Win32's <windef.h> |
|---|
| 60 | #ifndef CALLBACK |
|---|
| 61 | #define CALLBACK __stdcall |
|---|
| 62 | #endif |
|---|
| 63 | |
|---|
| 64 | #else // ! __CYGWIN__ |
|---|
| 65 | |
|---|
| 66 | // Under Windows avoid including <windows.h> |
|---|
| 67 | // to avoid name space pollution, but Win32's <GL/gl.h> |
|---|
| 68 | // needs APIENTRY and WINGDIAPI defined properly. |
|---|
| 69 | // XXX This is from Win32's <windef.h> |
|---|
| 70 | #ifndef APIENTRY |
|---|
| 71 | #define GLUT_APIENTRY_DEFINED |
|---|
| 72 | #if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) |
|---|
| 73 | #define WINAPI __stdcall |
|---|
| 74 | #define APIENTRY WINAPI |
|---|
| 75 | #else |
|---|
| 76 | #define APIENTRY |
|---|
| 77 | #endif |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | // XXX This is from Win32's <windef.h> |
|---|
| 81 | #ifndef CALLBACK |
|---|
| 82 | #if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) |
|---|
| 83 | #define CALLBACK __stdcall |
|---|
| 84 | #else |
|---|
| 85 | #define CALLBACK |
|---|
| 86 | #endif |
|---|
| 87 | #endif |
|---|
| 88 | |
|---|
| 89 | #endif // __CYGWIN__ |
|---|
| 90 | |
|---|
| 91 | // XXX This is from Win32's <wingdi.h> and <winnt.h> |
|---|
| 92 | #ifndef WINGDIAPI |
|---|
| 93 | #define GLUT_WINGDIAPI_DEFINED |
|---|
| 94 | #define DECLSPEC_IMPORT __declspec(dllimport) |
|---|
| 95 | #define WINGDIAPI DECLSPEC_IMPORT |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | // XXX This is from Win32's <ctype.h> |
|---|
| 99 | #if !defined(_WCHAR_T_DEFINED) && !(defined(__GNUC__)&&((__GNUC__ == 3)||(__GNUC__ == 4))) |
|---|
| 100 | typedef unsigned short wchar_t; |
|---|
| 101 | #define _WCHAR_T_DEFINED |
|---|
| 102 | #endif |
|---|
| 103 | |
|---|
| 104 | #endif // WIN32 |
|---|
| 105 | |
|---|
| 106 | #if defined(OSG_GL3_AVAILABLE) |
|---|
| 107 | |
|---|
| 108 | #define GL3_PROTOTYPES 1 |
|---|
| 109 | #include <GL3/gl3.h> |
|---|
| 110 | |
|---|
| 111 | #else |
|---|
| 112 | #ifndef __gl_h_ |
|---|
| 113 | #ifdef __APPLE__ |
|---|
| 114 | #include <OpenGL/gl.h> |
|---|
| 115 | #else |
|---|
| 116 | #include <GL/gl.h> |
|---|
| 117 | #endif |
|---|
| 118 | #endif |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | #ifndef GL_APIENTRY |
|---|
| 122 | #define GL_APIENTRY APIENTRY |
|---|
| 123 | #endif // GL_APIENTRY |
|---|
| 124 | |
|---|
| 125 | #endif |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | #ifdef OSG_GL_MATRICES_AVAILABLE |
|---|
| 129 | |
|---|
| 130 | inline void glLoadMatrix(const float* mat) { glLoadMatrixf(static_cast<const GLfloat*>(mat)); } |
|---|
| 131 | inline void glMultMatrix(const float* mat) { glMultMatrixf(static_cast<const GLfloat*>(mat)); } |
|---|
| 132 | |
|---|
| 133 | #ifdef OSG_GLES1_AVAILABLE |
|---|
| 134 | inline void glLoadMatrix(const double* mat) |
|---|
| 135 | { |
|---|
| 136 | GLfloat flt_mat[16]; |
|---|
| 137 | for(unsigned int i=0;i<16;++i) flt_mat[i] = mat[i]; |
|---|
| 138 | glLoadMatrixf(flt_mat); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | inline void glMultMatrix(const double* mat) |
|---|
| 142 | { |
|---|
| 143 | GLfloat flt_mat[16]; |
|---|
| 144 | for(unsigned int i=0;i<16;++i) flt_mat[i] = mat[i]; |
|---|
| 145 | glMultMatrixf(flt_mat); |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | #else |
|---|
| 149 | inline void glLoadMatrix(const double* mat) { glLoadMatrixd(static_cast<const GLdouble*>(mat)); } |
|---|
| 150 | inline void glMultMatrix(const double* mat) { glMultMatrixd(static_cast<const GLdouble*>(mat)); } |
|---|
| 151 | #endif |
|---|
| 152 | #endif |
|---|
| 153 | |
|---|
| 154 | // add defines for OpenGL targets that don't define them, just to ease compatibility across targets |
|---|
| 155 | #ifndef GL_DOUBLE |
|---|
| 156 | #define GL_DOUBLE 0x140A |
|---|
| 157 | typedef double GLdouble; |
|---|
| 158 | #endif |
|---|
| 159 | |
|---|
| 160 | #ifndef GL_INT |
|---|
| 161 | #define GL_INT 0x1404 |
|---|
| 162 | #endif |
|---|
| 163 | |
|---|
| 164 | #ifndef GL_UNSIGNED_INT |
|---|
| 165 | #define GL_UNSIGNED_INT 0x1405 |
|---|
| 166 | #endif |
|---|
| 167 | |
|---|
| 168 | #ifndef GL_NONE |
|---|
| 169 | // OpenGL ES1 doesn't provide GL_NONE |
|---|
| 170 | #define GL_NONE 0x0 |
|---|
| 171 | #endif |
|---|
| 172 | |
|---|
| 173 | #if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) |
|---|
| 174 | //GLES defines (OES) |
|---|
| 175 | #define GL_RGB8_OES 0x8051 |
|---|
| 176 | #define GL_RGBA8_OES 0x8058 |
|---|
| 177 | #endif |
|---|
| 178 | |
|---|
| 179 | #if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE) |
|---|
| 180 | #define GL_POLYGON 0x0009 |
|---|
| 181 | #define GL_QUADS 0x0007 |
|---|
| 182 | #define GL_QUAD_STRIP 0x0008 |
|---|
| 183 | #endif |
|---|
| 184 | |
|---|
| 185 | #if defined(OSG_GL3_AVAILABLE) |
|---|
| 186 | #define GL_LUMINANCE 0x1909 |
|---|
| 187 | #define GL_LUMINANCE_ALPHA 0x190A |
|---|
| 188 | #endif |
|---|
| 189 | |
|---|
| 190 | #ifdef OSG_GL1_AVAILABLE |
|---|
| 191 | #define OSG_GL1_FEATURES true |
|---|
| 192 | #else |
|---|
| 193 | #define OSG_GL1_FEATURES false |
|---|
| 194 | #endif |
|---|
| 195 | |
|---|
| 196 | #ifdef OSG_GL2_AVAILABLE |
|---|
| 197 | #define OSG_GL2_FEATURES true |
|---|
| 198 | #else |
|---|
| 199 | #define OSG_GL2_FEATURES false |
|---|
| 200 | #endif |
|---|
| 201 | |
|---|
| 202 | #ifdef OSG_GL3_AVAILABLE |
|---|
| 203 | #define OSG_GL3_FEATURES true |
|---|
| 204 | #else |
|---|
| 205 | #define OSG_GL3_FEATURES false |
|---|
| 206 | #endif |
|---|
| 207 | |
|---|
| 208 | #ifdef OSG_GLES1_AVAILABLE |
|---|
| 209 | #define OSG_GLES1_FEATURES true |
|---|
| 210 | #else |
|---|
| 211 | #define OSG_GLES1_FEATURES false |
|---|
| 212 | #endif |
|---|
| 213 | |
|---|
| 214 | #ifdef OSG_GLES2_AVAILABLE |
|---|
| 215 | #define OSG_GLES2_FEATURES true |
|---|
| 216 | #else |
|---|
| 217 | #define OSG_GLES2_FEATURES false |
|---|
| 218 | #endif |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | #endif // __osgGL_h |
|---|