2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-10-04 23:12:57 +08:00
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
#ifndef OSG_GL
|
|
|
|
#define OSG_GL 1
|
|
|
|
|
2009-10-24 00:51:45 +08:00
|
|
|
#include <osg/Config>
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2009-10-24 00:51:45 +08:00
|
|
|
#ifndef WIN32
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
// Required for compatibility with glext.h sytle function definitions of
|
2001-09-20 05:08:56 +08:00
|
|
|
// OpenGL extensions, such as in src/osg/Point.cpp.
|
|
|
|
#ifndef APIENTRY
|
|
|
|
#define APIENTRY
|
|
|
|
#endif
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2002-08-25 03:35:00 +08:00
|
|
|
#else // WIN32
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2002-08-25 03:35:00 +08:00
|
|
|
#if defined(__CYGWIN__) || defined(__MINGW32__)
|
2002-01-04 05:34:57 +08:00
|
|
|
|
2002-08-25 03:35:00 +08:00
|
|
|
#ifndef APIENTRY
|
|
|
|
#define GLUT_APIENTRY_DEFINED
|
|
|
|
#define APIENTRY __stdcall
|
|
|
|
#endif
|
2007-04-04 03:42:43 +08:00
|
|
|
// XXX This is from Win32's <windef.h>
|
2002-08-25 03:35:00 +08:00
|
|
|
#ifndef CALLBACK
|
|
|
|
#define CALLBACK __stdcall
|
|
|
|
#endif
|
2002-01-04 05:34:57 +08:00
|
|
|
|
2002-08-25 03:35:00 +08:00
|
|
|
#else // ! __CYGWIN__
|
2002-01-04 05:34:57 +08:00
|
|
|
|
2004-09-13 23:14:11 +08:00
|
|
|
// Under Windows avoid including <windows.h>
|
2002-08-25 03:35:00 +08:00
|
|
|
// to avoid name space pollution, but Win32's <GL/gl.h>
|
|
|
|
// needs APIENTRY and WINGDIAPI defined properly.
|
|
|
|
// XXX This is from Win32's <windef.h>
|
|
|
|
#ifndef APIENTRY
|
|
|
|
#define GLUT_APIENTRY_DEFINED
|
|
|
|
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
|
2002-08-27 22:00:04 +08:00
|
|
|
#define WINAPI __stdcall
|
|
|
|
#define APIENTRY WINAPI
|
2002-08-25 03:35:00 +08:00
|
|
|
#else
|
|
|
|
#define APIENTRY
|
|
|
|
#endif
|
|
|
|
#endif
|
2002-01-04 05:34:57 +08:00
|
|
|
|
2007-04-04 03:42:43 +08:00
|
|
|
// XXX This is from Win32's <windef.h>
|
2002-08-25 03:35:00 +08:00
|
|
|
#ifndef CALLBACK
|
2007-04-04 03:42:43 +08:00
|
|
|
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
|
2002-08-25 03:35:00 +08:00
|
|
|
#define CALLBACK __stdcall
|
|
|
|
#else
|
|
|
|
#define CALLBACK
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // __CYGWIN__
|
|
|
|
|
|
|
|
// XXX This is from Win32's <wingdi.h> and <winnt.h>
|
|
|
|
#ifndef WINGDIAPI
|
|
|
|
#define GLUT_WINGDIAPI_DEFINED
|
2002-08-27 22:00:04 +08:00
|
|
|
#define DECLSPEC_IMPORT __declspec(dllimport)
|
|
|
|
#define WINGDIAPI DECLSPEC_IMPORT
|
2002-08-25 03:35:00 +08:00
|
|
|
#endif
|
2002-12-05 01:34:52 +08:00
|
|
|
// XXX This is from Win32's <ctype.h>
|
|
|
|
|
2005-11-22 17:47:18 +08:00
|
|
|
#if !defined(_WCHAR_T_DEFINED) && !(defined(__GNUC__)&&((__GNUC__ == 3)||(__GNUC__ == 4)))
|
2002-08-25 03:35:00 +08:00
|
|
|
typedef unsigned short wchar_t;
|
|
|
|
#define _WCHAR_T_DEFINED
|
|
|
|
#endif
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2009-10-24 00:51:45 +08:00
|
|
|
#endif // WIN32
|
|
|
|
|
|
|
|
#if defined(OSG_GLES1_AVAILABLE)
|
|
|
|
|
|
|
|
#include <GLES/gl.h>
|
|
|
|
|
|
|
|
#elif defined(OSG_GLES2_AVAILABLE)
|
|
|
|
|
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
|
2009-11-04 00:34:54 +08:00
|
|
|
#elif defined(OSG_GL3_AVAILABLE)
|
|
|
|
|
|
|
|
#define GL3_PROTOTYPES 1
|
|
|
|
#include <GL3/gl3.h>
|
|
|
|
|
2009-10-24 00:51:45 +08:00
|
|
|
#else
|
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
#ifndef __gl_h_
|
2009-10-24 00:51:45 +08:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#else
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
2001-01-11 00:32:10 +08:00
|
|
|
#endif
|
|
|
|
|
2009-10-24 00:51:45 +08:00
|
|
|
#endif
|
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
|
2009-10-24 00:51:45 +08:00
|
|
|
#ifdef OSG_GL_MATRICES_AVAILABLE
|
2009-10-25 19:52:01 +08:00
|
|
|
|
2006-12-14 22:44:10 +08:00
|
|
|
inline void glLoadMatrix(const float* mat) { glLoadMatrixf(static_cast<const GLfloat*>(mat)); }
|
|
|
|
inline void glMultMatrix(const float* mat) { glMultMatrixf(static_cast<const GLfloat*>(mat)); }
|
2009-10-25 19:52:01 +08:00
|
|
|
|
|
|
|
#ifdef OSG_GLES1_AVAILABLE
|
|
|
|
inline void glLoadMatrix(const double* mat)
|
|
|
|
{
|
|
|
|
GLfloat flt_mat[16];
|
|
|
|
for(unsigned int i=0;i<16;++i) flt_mat[i] = mat[i];
|
|
|
|
glLoadMatrixf(flt_mat);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void glMultMatrix(const double* mat)
|
|
|
|
{
|
|
|
|
GLfloat flt_mat[16];
|
|
|
|
for(unsigned int i=0;i<16;++i) flt_mat[i] = mat[i];
|
|
|
|
glMultMatrixf(flt_mat);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
inline void glLoadMatrix(const double* mat) { glLoadMatrixd(static_cast<const GLdouble*>(mat)); }
|
|
|
|
inline void glMultMatrix(const double* mat) { glMultMatrixd(static_cast<const GLdouble*>(mat)); }
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// add defines for OpenGL targets that don't define them, just to ease compatibility across targets
|
|
|
|
#ifndef GL_DOUBLE
|
|
|
|
#define GL_DOUBLE 0x140A
|
|
|
|
typedef double GLdouble;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GL_INT
|
|
|
|
#define GL_INT 0x1404
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GL_UNSIGNED_INT
|
|
|
|
#define GL_UNSIGNED_INT 0x1405
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GL_NONE
|
|
|
|
// OpenGL ES1 doesn't provide GL_NONE
|
|
|
|
#define GL_NONE 0x0
|
|
|
|
#endif
|
|
|
|
|
2009-11-04 00:34:54 +08:00
|
|
|
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
|
2009-10-25 19:52:01 +08:00
|
|
|
#define GL_POLYGON 0x0009
|
|
|
|
#define GL_QUADS 0x0007
|
|
|
|
#define GL_QUAD_STRIP 0x0008
|
|
|
|
#endif
|
|
|
|
|
2009-11-04 00:34:54 +08:00
|
|
|
#if defined(OSG_GL3_AVAILABLE)
|
|
|
|
#define GL_LUMINANCE 0x1909
|
|
|
|
#define GL_LUMINANCE_ALPHA 0x190A
|
|
|
|
#endif
|
|
|
|
|
2009-10-25 19:52:01 +08:00
|
|
|
#ifdef OSG_GLES1_AVAILABLE
|
2009-10-28 02:07:12 +08:00
|
|
|
inline void glColor4ubv(const GLubyte* c) { glColor4ub(c[0], c[1], c[2], c[3]); }
|
|
|
|
inline void glColor3fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
|
|
|
|
inline void glColor4fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], c[3]); }
|
|
|
|
inline void glColor3dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
|
|
|
|
inline void glColor4dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], c[3]); }
|
|
|
|
|
|
|
|
inline void glNormal3bv(const GLbyte* n) { const float div = 1.0f/128.0f; glNormal3f(float(n[0])*div, float(n[1])*div, float(n[3])*div); }
|
|
|
|
inline void glNormal3sv(const GLshort* n) { const float div = 1.0f/32768.0f; glNormal3f(float(n[0])*div, float(n[1])*div, float(n[3])*div); }
|
|
|
|
inline void glNormal3fv(const GLfloat* n) { glNormal3f(n[0], n[1], n[3]); }
|
|
|
|
inline void glNormal3dv(const GLdouble* n) { glNormal3f(n[0], n[1], n[3]); }
|
2009-10-24 00:51:45 +08:00
|
|
|
#endif
|
2003-09-06 04:48:42 +08:00
|
|
|
|
2001-01-11 00:32:10 +08:00
|
|
|
#endif // __osgGL_h
|