Introduced usage of OSG_GLES*_AVAILABLE macros to headers and .cpp's to enable building against OpenGL ES 1.x and 2.x headers
This commit is contained in:
@@ -101,10 +101,69 @@
|
||||
|
||||
|
||||
#ifdef OSG_GL_MATRICES_AVAILABLE
|
||||
|
||||
inline void glLoadMatrix(const float* mat) { glLoadMatrixf(static_cast<const GLfloat*>(mat)); }
|
||||
inline void glLoadMatrix(const double* mat) { glLoadMatrixd(static_cast<const GLdouble*>(mat)); }
|
||||
inline void glMultMatrix(const float* mat) { glMultMatrixf(static_cast<const GLfloat*>(mat)); }
|
||||
inline void glMultMatrix(const double* mat) { glMultMatrixd(static_cast<const GLdouble*>(mat)); }
|
||||
|
||||
#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
|
||||
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
#define GL_POLYGON 0x0009
|
||||
#define GL_QUADS 0x0007
|
||||
#define GL_QUAD_STRIP 0x0008
|
||||
|
||||
void glDepthRange(double near_val, double far_val) { glDepthRangef(near_val, far_val); }
|
||||
#endif
|
||||
|
||||
#ifdef OSG_GLES1_AVAILABLE
|
||||
void glColor4ubv(const GLubyte* c) { glColor4ub(c[0], c[1], c[2], c[3]); }
|
||||
void glColor3fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
|
||||
void glColor4fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], c[3]); }
|
||||
void glColor3dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
|
||||
void glColor4dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], c[3]); }
|
||||
|
||||
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); }
|
||||
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); }
|
||||
void glNormal3fv(const GLfloat* n) { glNormal3f(n[0], n[1], n[3]); }
|
||||
void glNormal3dv(const GLdouble* n) { glNormal3f(n[0], n[1], n[3]); }
|
||||
#endif
|
||||
|
||||
#endif // __osgGL_h
|
||||
|
||||
Reference in New Issue
Block a user