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:
@@ -16,6 +16,10 @@
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef GL_ALPHA_TEST
|
||||
#define GL_ALPHA_TEST 0x0BC0
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Encapsulates OpenGL glAlphaFunc.
|
||||
|
||||
@@ -85,14 +85,22 @@ class OSG_EXPORT ArrayDispatchers : public osg::Referenced
|
||||
|
||||
void Begin(GLenum mode)
|
||||
{
|
||||
#ifdef OSG_GL1_AVAILABLE
|
||||
if (_useGLBeginEndAdapter) _glBeginEndAdapter->Begin(mode);
|
||||
else ::glBegin(mode);
|
||||
#else
|
||||
_glBeginEndAdapter->Begin(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
void End()
|
||||
{
|
||||
#ifdef OSG_GL1_AVAILABLE
|
||||
if (_useGLBeginEndAdapter) _glBeginEndAdapter->End();
|
||||
else ::glEnd();
|
||||
#else
|
||||
_glBeginEndAdapter->End();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
#include <osg/Plane>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef GL_CLIP_PLANE0
|
||||
#define GL_CLIP_PLANE0 0x3000
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Encapsulates OpenGL glClipPlane().
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
#define GL_FRAGMENT_DEPTH 0x8452
|
||||
#endif
|
||||
|
||||
#ifndef GL_FOG
|
||||
#define GL_FOG 0x0B60
|
||||
#define GL_EXP 0x0800
|
||||
#define GL_EXP2 0x0801
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -32,9 +32,12 @@
|
||||
#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_2_0
|
||||
#define GL_VERSION_2_0 1
|
||||
#if !defined(GL_VERSION_2_0)
|
||||
typedef char GLchar;
|
||||
#endif
|
||||
|
||||
#if !defined(GL_VERSION_2_0) && !defined(GL_ES_VERSION_2_0)
|
||||
#define GL_VERSION_2_0 1
|
||||
#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
|
||||
|
||||
@@ -18,6 +18,14 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
|
||||
#ifndef GL_LIGHT0
|
||||
#define GL_LIGHT0 0x4000
|
||||
#endif
|
||||
|
||||
#ifndef GL_LIGHTING
|
||||
#define GL_LIGHTING 0x0B50
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Light state class which encapsulates OpenGL glLight() functionality. */
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef GL_LINE_STIPPLE
|
||||
#define GL_LINE_STIPPLE 0x0B24
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
class OSG_EXPORT LineStipple : public StateAttribute
|
||||
|
||||
@@ -16,6 +16,25 @@
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#define GL_CLEAR 0x1500
|
||||
#define GL_SET 0x150F
|
||||
#define GL_COPY 0x1503
|
||||
#define GL_COPY_INVERTED 0x150C
|
||||
#define GL_NOOP 0x1505
|
||||
#define GL_AND 0x1501
|
||||
#define GL_NAND 0x150E
|
||||
#define GL_OR 0x1507
|
||||
#define GL_NOR 0x1508
|
||||
#define GL_XOR 0x1506
|
||||
#define GL_EQUIV 0x1509
|
||||
#define GL_AND_REVERSE 0x1502
|
||||
#define GL_AND_INVERTED 0x1504
|
||||
#define GL_OR_REVERSE 0x150B
|
||||
#define GL_OR_INVERTED 0x150D
|
||||
#define GL_COLOR_LOGIC_OP 0x0BF2
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Encapsulates OpenGL LogicOp state. */
|
||||
|
||||
@@ -17,6 +17,15 @@
|
||||
#include <osg/Vec4>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#define GL_AMBIENT 0x1200
|
||||
#define GL_DIFFUSE 0x1201
|
||||
#define GL_SPECULAR 0x1202
|
||||
#define GL_EMISSION 0x1600
|
||||
#define GL_AMBIENT_AND_DIFFUSE 0x1602
|
||||
#define GL_COLOR_MATERIAL 0x0B57
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
/** Material - encapsulates OpenGL glMaterial state.*/
|
||||
class OSG_EXPORT Material : public StateAttribute
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
#include <osg/Vec3>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef GL_POINT_SMOOTH
|
||||
#define GL_POINT_SMOOTH 0x0B10
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Point - encapsulates the OpenGL point smoothing and size state.*/
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
#include <osg/StateAttribute>
|
||||
#include <osg/GL>
|
||||
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
#define GL_POINT 0x1B00
|
||||
#define GL_LINE 0x1B01
|
||||
#define GL_FILL 0x1B02
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** State Class for setting OpenGL's polygon culling mode.
|
||||
|
||||
@@ -52,8 +52,10 @@ class OSG_EXPORT PolygonOffset : public StateAttribute
|
||||
virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
|
||||
{
|
||||
usage.usesMode(GL_POLYGON_OFFSET_FILL);
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
usage.usesMode(GL_POLYGON_OFFSET_LINE);
|
||||
usage.usesMode(GL_POLYGON_OFFSET_POINT);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#ifndef GL_POLYGON_STIPPLE
|
||||
#define GL_POLYGON_STIPPLE 0x0B42
|
||||
#endif
|
||||
|
||||
namespace osg
|
||||
{
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
#ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#define GL_FLAT 0x1D00
|
||||
#define GL_SMOOTH 0x1D01
|
||||
#endif
|
||||
|
||||
/** Class which encapsulates glShadeModel(..).
|
||||
*/
|
||||
class OSG_EXPORT ShadeModel : public StateAttribute
|
||||
|
||||
@@ -33,10 +33,6 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#ifndef GL_TEXTURE0
|
||||
#define GL_TEXTURE0 0x84C0
|
||||
#endif
|
||||
|
||||
#ifndef GL_FOG_COORDINATE_ARRAY
|
||||
#ifdef GL_FOG_COORDINATE_ARRAY_EXT
|
||||
#define GL_FOG_COORDINATE_ARRAY GL_FOG_COORDINATE_ARRAY_EXT
|
||||
@@ -497,32 +493,56 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
inline void Vertex(float x, float y, float z, float w=1.0f)
|
||||
{
|
||||
#if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _vertexAlias._location, x,y,z,w);
|
||||
else glVertex4f(x,y,z,w);
|
||||
#else
|
||||
_glVertexAttrib4f( _vertexAlias._location, x,y,z,w);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void Color(float r, float g, float b, float a=1.0f)
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _colorAlias._location, r,g,b,a);
|
||||
else glColor4f(r,g,b,a);
|
||||
#else
|
||||
_glVertexAttrib4f( _colorAlias._location, r,g,b,a);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Normal(float x, float y, float z)
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _normalAlias._location, x,y,z,0.0);
|
||||
else glNormal3f(x,y,z);
|
||||
#else
|
||||
_glVertexAttrib4f( _normalAlias._location, x,y,z,0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TexCoord(float x, float y=0.0f, float z=0.0f, float w=1.0f)
|
||||
{
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _texCoordAliasList[0]._location, x,y,z,w);
|
||||
else glTexCoord4f(x,y,z,w);
|
||||
#if !defined(OSG_GLES1_AVAILABLE)
|
||||
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _texCoordAliasList[0]._location, x,y,z,w);
|
||||
else glTexCoord4f(x,y,z,w);
|
||||
#else
|
||||
_glVertexAttrib4f( _texCoordAliasList[0]._location, x,y,z,w);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void MultiTexCoord(unsigned int unit, float x, float y=0.0f, float z=0.0f, float w=1.0f)
|
||||
{
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _texCoordAliasList[unit]._location, x,y,z,w);
|
||||
else _glMultiTexCoord4f(GL_TEXTURE0+unit,x,y,z,w);
|
||||
#if !defined(OSG_GLES1_AVAILABLE)
|
||||
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing) _glVertexAttrib4f( _texCoordAliasList[unit]._location, x,y,z,w);
|
||||
else _glMultiTexCoord4f(GL_TEXTURE0+unit,x,y,z,w);
|
||||
#else
|
||||
_glVertexAttrib4f( _texCoordAliasList[unit]._location, x,y,z,w);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void VerteAttrib(unsigned int location, float x, float y=0.0f, float z=0.0f, float w=0.0f)
|
||||
@@ -531,19 +551,16 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Wrapper around glInterleavedArrays(..).
|
||||
* also resets the internal array points and modes within osg::State to keep the other
|
||||
* vertex array operations consistent. */
|
||||
void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer);
|
||||
|
||||
|
||||
/** Mark all the vertex attributes as being disabled but leave the disabling till a later call to applyDisablingOfVertexAttributes.*/
|
||||
void lazyDisablingOfVertexAttributes();
|
||||
|
||||
/** Disable all the vertex attributes that have been marked as to be disabled.*/
|
||||
void applyDisablingOfVertexAttributes();
|
||||
|
||||
/** Wrapper around glInterleavedArrays(..).
|
||||
* also resets the internal array points and modes within osg::State to keep the other
|
||||
* vertex array operations consistent. */
|
||||
void setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* pointer);
|
||||
|
||||
/** Set the vertex pointer using an osg::Array, and manage any VBO that are required.*/
|
||||
inline void setVertexPointer(const Array* array)
|
||||
@@ -569,6 +586,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
inline void setVertexPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
setVertexAttribPointer(_vertexAlias._location, size, type, GL_FALSE, stride, ptr);
|
||||
@@ -588,12 +606,16 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_vertexArray._lazy_disable = false;
|
||||
_vertexArray._dirty = false;
|
||||
}
|
||||
#else
|
||||
setVertexAttribPointer(_vertexAlias._location, size, type, GL_FALSE, stride, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_VERTEX_ARRAY).
|
||||
* note, only updates values that change.*/
|
||||
inline void disableVertexPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointer(_vertexAlias._location);
|
||||
@@ -608,10 +630,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointer(_vertexAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtyVertexPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointer(_vertexAlias._location);
|
||||
@@ -621,6 +647,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_vertexArray._pointer = 0;
|
||||
_vertexArray._dirty = true;
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointer(_vertexAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -648,6 +677,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
inline void setNormalPointer( GLenum type, GLsizei stride,
|
||||
const GLvoid *ptr )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
setVertexAttribPointer(_normalAlias._location, 3, type, GL_FALSE, stride, ptr);
|
||||
@@ -667,12 +697,16 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_normalArray._lazy_disable = false;
|
||||
_normalArray._dirty = false;
|
||||
}
|
||||
#else
|
||||
setVertexAttribPointer(_normalAlias._location, 3, type, GL_FALSE, stride, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_NORMAL_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableNormalPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointer(_normalAlias._location);
|
||||
@@ -687,10 +721,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointer(_normalAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtyNormalPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointer(_normalAlias._location);
|
||||
@@ -700,6 +738,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_normalArray._pointer = 0;
|
||||
_normalArray._dirty = true;
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointer(_normalAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Set the color pointer using an osg::Array, and manage any VBO that are required.*/
|
||||
@@ -727,6 +768,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
inline void setColorPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
setVertexAttribPointer(_colorAlias._location, size, type, GL_FALSE, stride, ptr);
|
||||
@@ -746,12 +788,16 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_colorArray._lazy_disable = false;
|
||||
_colorArray._dirty = false;
|
||||
}
|
||||
#else
|
||||
setVertexAttribPointer(_colorAlias._location, size, type, GL_FALSE, stride, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_COLOR_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableColorPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointer(_colorAlias._location);
|
||||
@@ -766,10 +812,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointer(_colorAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtyColorPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointer(_colorAlias._location);
|
||||
@@ -779,6 +829,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_colorArray._pointer = 0;
|
||||
_colorArray._dirty = true;
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointer(_colorAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -812,6 +865,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
* note, only updates values that change.*/
|
||||
inline void disableSecondaryColorPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointer(_secondaryColorAlias._location);
|
||||
@@ -826,10 +880,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
if (isSecondaryColorSupported()) glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointer(_secondaryColorAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtySecondaryColorPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointer(_secondaryColorAlias._location);
|
||||
@@ -839,45 +897,11 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_secondaryColorArray._pointer = 0;
|
||||
_secondaryColorArray._dirty = true;
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointer(_secondaryColorAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** wrapper around glEnableClientState(GL_INDEX_ARRAY);glIndexPointer(..);
|
||||
* note, only updates values that change.*/
|
||||
inline void setIndexPointer( GLenum type, GLsizei stride,
|
||||
const GLvoid *ptr )
|
||||
{
|
||||
if (!_indexArray._enabled || _indexArray._dirty)
|
||||
{
|
||||
_indexArray._enabled = true;
|
||||
glEnableClientState(GL_INDEX_ARRAY);
|
||||
}
|
||||
//if (_indexArray._pointer!=ptr || _indexArray._dirty)
|
||||
{
|
||||
_indexArray._pointer=ptr;
|
||||
glIndexPointer( type, stride, ptr );
|
||||
}
|
||||
_indexArray._dirty = false;
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_INDEX_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableIndexPointer()
|
||||
{
|
||||
if (_indexArray._enabled || _indexArray._dirty)
|
||||
{
|
||||
_indexArray._enabled = false;
|
||||
_indexArray._dirty = false;
|
||||
glDisableClientState(GL_INDEX_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
inline void dirtyIndexPointer()
|
||||
{
|
||||
_indexArray._pointer = 0;
|
||||
_indexArray._dirty = true;
|
||||
}
|
||||
|
||||
|
||||
inline bool isFogCoordSupported() const { return _isFogCoordSupportResolved?_isFogCoordSupported:computeFogCoordSupported(); }
|
||||
|
||||
|
||||
@@ -909,6 +933,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
* note, only updates values that change.*/
|
||||
inline void disableFogCoordPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointer(_fogCoordAlias._location);
|
||||
@@ -923,10 +948,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
if (isFogCoordSupported()) glDisableClientState(GL_FOG_COORDINATE_ARRAY);
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointer(_fogCoordAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtyFogCoordPointer()
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointer(_fogCoordAlias._location);
|
||||
@@ -936,6 +965,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
_fogArray._pointer = 0;
|
||||
_fogArray._dirty = true;
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointer(_fogCoordAlias._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -965,6 +997,7 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
setVertexAttribPointer(_texCoordAliasList[unit]._location, size, type, GL_FALSE, stride, ptr);
|
||||
@@ -990,12 +1023,16 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
eap._dirty = false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
setVertexAttribPointer(_texCoordAliasList[unit]._location, size, type, GL_FALSE, stride, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** wrapper around glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
* note, only updates values that change.*/
|
||||
inline void disableTexCoordPointer( unsigned int unit )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointer(_texCoordAliasList[unit]._location);
|
||||
@@ -1016,10 +1053,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointer(_texCoordAliasList[unit]._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtyTexCoordPointer( unsigned int unit )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointer(_texCoordAliasList[unit]._location);
|
||||
@@ -1031,11 +1072,15 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
eap._pointer = 0;
|
||||
eap._dirty = true;
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointer(_texCoordAliasList[unit]._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline void disableTexCoordPointersAboveAndIncluding( unsigned int unit )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
disableVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
|
||||
@@ -1058,10 +1103,14 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
++unit;
|
||||
}
|
||||
}
|
||||
#else
|
||||
disableVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void dirtyTexCoordPointersAboveAndIncluding( unsigned int unit )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
dirtyVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
|
||||
@@ -1076,6 +1125,9 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
++unit;
|
||||
}
|
||||
}
|
||||
#else
|
||||
dirtyVertexAttribPointersAboveAndIncluding(_texCoordAliasList[unit]._location);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1483,7 +1535,6 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
EnabledArrayPair _normalArray;
|
||||
EnabledArrayPair _colorArray;
|
||||
EnabledArrayPair _secondaryColorArray;
|
||||
EnabledArrayPair _indexArray;
|
||||
EnabledArrayPair _fogArray;
|
||||
EnabledTexCoordArrayList _texCoordArrayList;
|
||||
EnabledVertexAttribArrayList _vertexAttribArrayList;
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
#include <osg/StateAttribute>
|
||||
#include <osg/Vec4>
|
||||
|
||||
#ifndef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#define GL_MODULATE 0x2100
|
||||
#define GL_ADD 0x0104
|
||||
#define GL_MODULATE 0x2100
|
||||
#define GL_DECAL 0x2101
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** TexEnv encapsulates the OpenGL glTexEnv (texture environment) state.
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
#ifndef OSG_TEXENVCOMBINE
|
||||
#define OSG_TEXENVCOMBINE 1
|
||||
|
||||
#include <osg/GL>
|
||||
#include <osg/StateAttribute>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
|
||||
|
||||
@@ -17,12 +17,22 @@
|
||||
#include <osg/Plane>
|
||||
#include <osg/StateAttribute>
|
||||
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
#define GL_OBJECT_LINEAR 0x2401
|
||||
#define GL_EYE_LINEAR 0x2400
|
||||
#define GL_SPHERE_MAP 0x2402
|
||||
#define GL_TEXTURE_GEN_S 0x0C60
|
||||
#define GL_TEXTURE_GEN_T 0x0C61
|
||||
#define GL_TEXTURE_GEN_R 0x0C62
|
||||
#define GL_TEXTURE_GEN_Q 0x0C63
|
||||
#endif
|
||||
|
||||
#ifndef GL_NORMAL_MAP_ARB
|
||||
#define GL_NORMAL_MAP_ARB 0x8511
|
||||
#define GL_NORMAL_MAP_ARB 0x8511
|
||||
#endif
|
||||
|
||||
#ifndef GL_REFLECTION_MAP_ARB
|
||||
#define GL_REFLECTION_MAP_ARB 0x8512
|
||||
#define GL_REFLECTION_MAP_ARB 0x8512
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -144,10 +144,20 @@
|
||||
#define GL_CLAMP_TO_EDGE 0x812F
|
||||
#endif
|
||||
|
||||
#ifndef GL_CLAMP
|
||||
// OpenGL ES1 and ES2 doesn't provide GL_CLAMP but has GL_CLAMP_TO_EDGE
|
||||
#define GL_CLAMP GL_CLAMP_TO_EDGE
|
||||
#endif
|
||||
|
||||
#ifndef GL_CLAMP_TO_BORDER_ARB
|
||||
#define GL_CLAMP_TO_BORDER_ARB 0x812D
|
||||
#endif
|
||||
|
||||
#ifndef GL_INTENSITY
|
||||
// OpenGL ES1 and ES2 doesn't provide GL_INTENSITY
|
||||
#define GL_INTENSITY 0x8049
|
||||
#endif
|
||||
|
||||
#ifndef GL_GENERATE_MIPMAP_SGIS
|
||||
#define GL_GENERATE_MIPMAP_SGIS 0x8191
|
||||
#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
#include <osg/Texture>
|
||||
|
||||
#ifndef GL_TEXTURE_1D
|
||||
#define GL_TEXTURE_1D 0x0DE0
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** Encapsulates OpenGl 1D texture functionality. Doesn't support cube maps,
|
||||
|
||||
@@ -29,6 +29,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef GL_SAMPLER_1D
|
||||
#define GL_SAMPLER_1D 0x8B5D
|
||||
#define GL_SAMPLER_2D 0x8B5E
|
||||
#define GL_SAMPLER_3D 0x8B5F
|
||||
#define GL_SAMPLER_1D_SHADOW 0x8B61
|
||||
#define GL_SAMPLER_2D_SHADOW 0x8B62
|
||||
#endif
|
||||
|
||||
|
||||
namespace osg {
|
||||
|
||||
// forward declare
|
||||
|
||||
Reference in New Issue
Block a user