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:
@@ -290,11 +290,13 @@ OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions
|
||||
# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||
# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||
# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||
# SET(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||
# SET(OSG_GL_FIXED_FUNCTION_AVAILABLE ${OSG_GL1_AVAILABLE})
|
||||
|
||||
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
|
||||
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -400,15 +400,19 @@ void ArrayDispatchers::init()
|
||||
_secondaryColorDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||
_fogCoordDispatchers = new AttributeDispatchMap(&(_state->getGLBeginEndAdapter()));
|
||||
|
||||
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true);
|
||||
_glBeginEndAdapter = &(_state->getGLBeginEndAdapter());
|
||||
_useGLBeginEndAdapter = false;
|
||||
|
||||
_vertexDispatchers->assign<GLfloat>(Array::Vec2ArrayType, glVertex2fv, 2);
|
||||
_vertexDispatchers->assign<GLfloat>(Array::Vec3ArrayType, glVertex3fv, 3);
|
||||
_vertexDispatchers->assign<GLdouble>(Array::Vec2dArrayType, glVertex2dv, 2);
|
||||
_vertexDispatchers->assign<GLdouble>(Array::Vec3dArrayType, glVertex3dv, 3);
|
||||
_vertexDispatchers->assignGLBeginEnd<GLfloat>(Array::Vec3ArrayType, &GLBeginEndAdapter::Vertex3fv, 3);
|
||||
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true);
|
||||
|
||||
#ifndef OSG_GLES1_AVAILABLE
|
||||
_vertexDispatchers->assign<GLfloat>(Array::Vec2ArrayType, glVertex2fv, 2);
|
||||
_vertexDispatchers->assign<GLfloat>(Array::Vec3ArrayType, glVertex3fv, 3);
|
||||
_vertexDispatchers->assign<GLdouble>(Array::Vec2dArrayType, glVertex2dv, 2);
|
||||
_vertexDispatchers->assign<GLdouble>(Array::Vec3dArrayType, glVertex3dv, 3);
|
||||
_vertexDispatchers->assignGLBeginEnd<GLfloat>(Array::Vec3ArrayType, &GLBeginEndAdapter::Vertex3fv, 3);
|
||||
#endif
|
||||
|
||||
_normalDispatchers->assign<GLbyte>(Array::Vec3bArrayType, glNormal3bv, 3);
|
||||
_normalDispatchers->assign<GLshort>(Array::Vec3sArrayType, glNormal3sv, 3);
|
||||
@@ -427,6 +431,7 @@ void ArrayDispatchers::init()
|
||||
_secondaryColorDispatchers->assign<GLfloat>(Array::Vec3ArrayType, extensions->_glSecondaryColor3fv, 3);
|
||||
|
||||
_fogCoordDispatchers->assign<GLfloat>(Array::FloatArrayType, extensions->_glFogCoordfv, 1);
|
||||
#endif
|
||||
|
||||
// pre allocate.
|
||||
_activeDispatchList.resize(5);
|
||||
@@ -483,8 +488,8 @@ AttributeDispatch* ArrayDispatchers::vertexAttribDispatcher(unsigned int unit, A
|
||||
|
||||
void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
|
||||
{
|
||||
#if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
|
||||
Drawable::Extensions* extensions = Drawable::getExtensions(_state->getContextID(),true);
|
||||
|
||||
for(unsigned int i=_texCoordDispatchers.size(); i<=unit; ++i)
|
||||
{
|
||||
_texCoordDispatchers.push_back(new AttributeDispatchMap(_glBeginEndAdapter));
|
||||
@@ -512,6 +517,7 @@ void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
|
||||
texCoordDispatcher.targetGLBeginEndAssign<GLenum, GLfloat>((GLenum)(GL_TEXTURE0+i), Array::Vec4ArrayType, &GLBeginEndAdapter::MultiTexCoord4fv, 4);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit)
|
||||
|
||||
@@ -75,7 +75,7 @@ unsigned int ClipPlane::getClipPlaneNum() const
|
||||
|
||||
void ClipPlane::apply(State&) const
|
||||
{
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
|
||||
glClipPlane((GLenum)(GL_CLIP_PLANE0+_clipPlaneNum),_clipPlane.ptr());
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: ClipPlane::apply(State&) - not supported."<<std::endl;
|
||||
|
||||
@@ -28,7 +28,7 @@ ColorMatrix::~ColorMatrix()
|
||||
|
||||
void ColorMatrix::apply(State& state) const
|
||||
{
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#if defined(OSG_GL_FIXED_FUNCTION_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
|
||||
unsigned int contextID = state.getContextID();
|
||||
|
||||
static bool s_ARB_imaging = isGLExtensionSupported(contextID,"GL_ARB_imaging");
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#cmakedefine OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
#cmakedefine OSG_GL_MATRICES_AVAILABLE
|
||||
#cmakedefine OSG_GL_VERTEX_FUNCS_AVAILABLE
|
||||
#cmakedefine OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
#cmakedefine OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,13 @@ Fog::~Fog()
|
||||
void Fog::apply(State& state) const
|
||||
{
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
|
||||
#ifdef OSG_GLES1_AVAILABLE
|
||||
#define glFogi glFogx
|
||||
#endif
|
||||
|
||||
glFogi( GL_FOG_MODE, _mode );
|
||||
|
||||
glFogf( GL_FOG_DENSITY, _density );
|
||||
glFogf( GL_FOG_START, _start );
|
||||
glFogf( GL_FOG_END, _end );
|
||||
|
||||
@@ -19,12 +19,12 @@ using namespace osg;
|
||||
void Hint::apply(State& /*state*/) const
|
||||
{
|
||||
if (_target==GL_NONE || _mode==GL_NONE) return;
|
||||
|
||||
|
||||
glHint(_target, _mode);
|
||||
}
|
||||
|
||||
void Hint::setTarget(GLenum target)
|
||||
{
|
||||
{
|
||||
if (_target==target) return;
|
||||
|
||||
if (_parents.empty())
|
||||
|
||||
@@ -20,15 +20,42 @@
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/Texture1D>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Texture3D>
|
||||
#include <osg/Texture2DArray>
|
||||
#include <osg/Light>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dxtctool.h"
|
||||
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
#define GL_BITMAP 0x1A00
|
||||
#define GL_RED 0x1903
|
||||
#define GL_GREEN 0x1904
|
||||
#define GL_BLUE 0x1905
|
||||
#define GL_COLOR_INDEX 0x1900
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
#define GL_INTENSITY12 0x804C
|
||||
#define GL_INTENSITY16 0x804D
|
||||
#define GL_INTENSITY4 0x804A
|
||||
#define GL_INTENSITY8 0x804B
|
||||
#define GL_LUMINANCE12 0x8041
|
||||
#define GL_LUMINANCE12_ALPHA4 0x8046
|
||||
#define GL_LUMINANCE12_ALPHA12 0x8047
|
||||
#define GL_LUMINANCE16 0x8042
|
||||
#define GL_LUMINANCE16_ALPHA16 0x8048
|
||||
#define GL_LUMINANCE4 0x803F
|
||||
#define GL_LUMINANCE4_ALPHA4 0x8043
|
||||
#define GL_LUMINANCE6_ALPHA2 0x8044
|
||||
#define GL_LUMINANCE8 0x8040
|
||||
#define GL_LUMINANCE8_ALPHA8 0x8045
|
||||
#define GL_STENCIL_INDEX 0x1901
|
||||
#define GL_RGBA8 0x8058
|
||||
#endif
|
||||
|
||||
using namespace osg;
|
||||
using namespace std;
|
||||
|
||||
@@ -682,6 +709,7 @@ void Image::readPixels(int x,int y,int width,int height,
|
||||
|
||||
void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type)
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
// osg::notify(osg::NOTICE)<<"Image::readImageFromCurrentTexture()"<<std::endl;
|
||||
|
||||
const osg::Texture::Extensions* extensions = osg::Texture::getExtensions(contextID,true);
|
||||
@@ -689,20 +717,16 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
|
||||
const osg::Texture2DArray::Extensions* extensions2DArray = osg::Texture2DArray::getExtensions(contextID,true);
|
||||
|
||||
|
||||
GLboolean binding1D, binding2D, binding3D, binding2DArray;
|
||||
GLboolean binding1D = GL_FALSE, binding2D = GL_FALSE, binding3D = GL_FALSE, binding2DArray = GL_FALSE;
|
||||
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_1D, &binding1D);
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_2D, &binding2D);
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_3D, &binding3D);
|
||||
|
||||
|
||||
|
||||
if (extensions2DArray->isTexture2DArraySupported())
|
||||
{
|
||||
glGetBooleanv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &binding2DArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
binding2DArray = GL_FALSE;
|
||||
}
|
||||
|
||||
GLenum textureMode = binding1D ? GL_TEXTURE_1D : binding2D ? GL_TEXTURE_2D : binding3D ? GL_TEXTURE_3D : binding2DArray ? GL_TEXTURE_2D_ARRAY_EXT : 0;
|
||||
|
||||
@@ -873,137 +897,134 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
|
||||
|
||||
dirty();
|
||||
}
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::readImageFromCurrentTexture() not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Image::scaleImage(int s,int t,int r, GLenum newDataType)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
void Image::scaleImage(int s,int t,int r, GLenum newDataType)
|
||||
if (_s==s && _t==t && _r==r) return;
|
||||
|
||||
if (_data==NULL)
|
||||
{
|
||||
if (_s==s && _t==t && _r==r) return;
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : cannot scale NULL image."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_data==NULL)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : cannot scale NULL image."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_r!=1 || r!=1)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : scaling of volumes not implemented."<<std::endl;
|
||||
return;
|
||||
}
|
||||
if (_r!=1 || r!=1)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : scaling of volumes not implemented."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,newDataType,_packing)*t;
|
||||
unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,newDataType,_packing)*t;
|
||||
|
||||
// need to sort out what size to really use...
|
||||
unsigned char* newData = new unsigned char [newTotalSize];
|
||||
if (!newData)
|
||||
{
|
||||
// should we throw an exception??? Just return for time being.
|
||||
notify(FATAL) << "Error Image::scaleImage() do not succeed : out of memory."<<newTotalSize<<std::endl;
|
||||
return;
|
||||
}
|
||||
// need to sort out what size to really use...
|
||||
unsigned char* newData = new unsigned char [newTotalSize];
|
||||
if (!newData)
|
||||
{
|
||||
// should we throw an exception??? Just return for time being.
|
||||
notify(FATAL) << "Error Image::scaleImage() do not succeed : out of memory."<<newTotalSize<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,_packing);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,_packing);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,_packing);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,_packing);
|
||||
|
||||
GLint status = gluScaleImage(_pixelFormat,
|
||||
_s,
|
||||
_t,
|
||||
_dataType,
|
||||
_data,
|
||||
s,
|
||||
t,
|
||||
newDataType,
|
||||
newData);
|
||||
GLint status = gluScaleImage(_pixelFormat,
|
||||
_s,
|
||||
_t,
|
||||
_dataType,
|
||||
_data,
|
||||
s,
|
||||
t,
|
||||
newDataType,
|
||||
newData);
|
||||
|
||||
if (status==0)
|
||||
{
|
||||
if (status==0)
|
||||
{
|
||||
|
||||
// free old image.
|
||||
_s = s;
|
||||
_t = t;
|
||||
_dataType = newDataType;
|
||||
setData(newData,USE_NEW_DELETE);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete [] newData;
|
||||
// free old image.
|
||||
_s = s;
|
||||
_t = t;
|
||||
_dataType = newDataType;
|
||||
setData(newData,USE_NEW_DELETE);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete [] newData;
|
||||
|
||||
notify(WARN) << "Error Image::scaleImage() did not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
notify(WARN) << "Error Image::scaleImage() did not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
|
||||
dirty();
|
||||
dirty();
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::scaleImage(int s,int t,int r, GLenum newDataType) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Image::copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image* source)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (!source) return;
|
||||
if (s_offset<0 || t_offset<0 || r_offset<0)
|
||||
{
|
||||
notify(WARN)<<"Warning: negative offsets passed to Image::copySubImage(..) not supported, operation ignored."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_data)
|
||||
{
|
||||
notify(INFO)<<"allocating image"<<endl;
|
||||
allocateImage(s_offset+source->s(),t_offset+source->t(),r_offset+source->r(),
|
||||
source->getPixelFormat(),source->getDataType(),
|
||||
source->getPacking());
|
||||
}
|
||||
|
||||
if (s_offset>=_s || t_offset>=_t || r_offset>=_r)
|
||||
{
|
||||
notify(WARN)<<"Warning: offsets passed to Image::copySubImage(..) outside destination image, operation ignored."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_pixelFormat != source->getPixelFormat())
|
||||
{
|
||||
notify(WARN)<<"Warning: image with an incompatible pixel formats passed to Image::copySubImage(..), operation ignored."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
void* data_destination = data(s_offset,t_offset,r_offset);
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,source->getPacking());
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH,_s);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,_packing);
|
||||
|
||||
GLint status = gluScaleImage(_pixelFormat,
|
||||
source->s(),
|
||||
source->t(),
|
||||
source->getDataType(),
|
||||
source->data(),
|
||||
source->s(),
|
||||
source->t(),
|
||||
_dataType,
|
||||
data_destination);
|
||||
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH,0);
|
||||
|
||||
if (status!=0)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
#else
|
||||
void Image::scaleImage(int,int,int, GLenum)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::scaleImage(int s,int t,int r, GLenum newDataType) not supported."<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
void Image::copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image* source)
|
||||
{
|
||||
if (!source) return;
|
||||
if (s_offset<0 || t_offset<0 || r_offset<0)
|
||||
{
|
||||
notify(WARN)<<"Warning: negative offsets passed to Image::copySubImage(..) not supported, operation ignored."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_data)
|
||||
{
|
||||
notify(INFO)<<"allocating image"<<endl;
|
||||
allocateImage(s_offset+source->s(),t_offset+source->t(),r_offset+source->r(),
|
||||
source->getPixelFormat(),source->getDataType(),
|
||||
source->getPacking());
|
||||
}
|
||||
|
||||
if (s_offset>=_s || t_offset>=_t || r_offset>=_r)
|
||||
{
|
||||
notify(WARN)<<"Warning: offsets passed to Image::copySubImage(..) outside destination image, operation ignored."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_pixelFormat != source->getPixelFormat())
|
||||
{
|
||||
notify(WARN)<<"Warning: image with an incompatible pixel formats passed to Image::copySubImage(..), operation ignored."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
void* data_destination = data(s_offset,t_offset,r_offset);
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,source->getPacking());
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH,_s);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,_packing);
|
||||
|
||||
GLint status = gluScaleImage(_pixelFormat,
|
||||
source->s(),
|
||||
source->t(),
|
||||
source->getDataType(),
|
||||
source->data(),
|
||||
source->s(),
|
||||
source->t(),
|
||||
_dataType,
|
||||
data_destination);
|
||||
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH,0);
|
||||
|
||||
if (status!=0)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void Image::copySubImage(int, int, int, const osg::Image*)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::copySubImage(int, int, int, const osg::Image*)) not supported."<<std::endl;
|
||||
}
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::copySubImage(int, int, int, const osg::Image*)) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Image::flipHorizontal()
|
||||
{
|
||||
|
||||
@@ -51,6 +51,11 @@ LightModel::~LightModel()
|
||||
void LightModel::apply(State&) const
|
||||
{
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
|
||||
#ifdef OSG_GLES1_AVAILABLE
|
||||
#define glLightModeli glLightModelx
|
||||
#endif
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient.ptr());
|
||||
|
||||
static bool s_separateSpecularSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0;
|
||||
@@ -66,7 +71,10 @@ void LightModel::apply(State&) const
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OSG_GLES1_AVAILABLE
|
||||
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,_localViewer);
|
||||
#endif
|
||||
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSided);
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: LightModel::apply(State&) - not supported."<<std::endl;
|
||||
|
||||
@@ -353,9 +353,12 @@ void Material::setAlpha(Face face,float alpha)
|
||||
void Material::apply(State&) const
|
||||
{
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
|
||||
#ifdef OSG_GL1_AVAILABLE
|
||||
if (_colorMode==OFF)
|
||||
{
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
|
||||
glColor4fv(_diffuseFront.ptr());
|
||||
}
|
||||
else
|
||||
@@ -372,6 +375,7 @@ void Material::apply(State&) const
|
||||
case(OFF): break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_colorMode!=AMBIENT && _colorMode!=AMBIENT_AND_DIFFUSE)
|
||||
{
|
||||
|
||||
@@ -739,7 +739,6 @@ void State::disableAllVertexArrays()
|
||||
disableVertexAttribPointersAboveAndIncluding(0);
|
||||
disableColorPointer();
|
||||
disableFogCoordPointer();
|
||||
disableIndexPointer();
|
||||
disableNormalPointer();
|
||||
disableSecondaryColorPointer();
|
||||
}
|
||||
@@ -751,7 +750,6 @@ void State::dirtyAllVertexArrays()
|
||||
dirtyVertexAttribPointersAboveAndIncluding(0);
|
||||
dirtyColorPointer();
|
||||
dirtyFogCoordPointer();
|
||||
dirtyIndexPointer();
|
||||
dirtyNormalPointer();
|
||||
dirtySecondaryColorPointer();
|
||||
}
|
||||
@@ -760,8 +758,12 @@ void State::setInterleavedArrays( GLenum format, GLsizei stride, const GLvoid* p
|
||||
{
|
||||
disableAllVertexArrays();
|
||||
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
|
||||
glInterleavedArrays( format, stride, pointer);
|
||||
|
||||
#endif
|
||||
|
||||
// the crude way, assume that all arrays have been effected so dirty them and
|
||||
// disable them...
|
||||
dirtyAllVertexArrays();
|
||||
@@ -848,6 +850,7 @@ bool State::setActiveTextureUnit( unsigned int unit )
|
||||
|
||||
void State::setFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
setVertexAttribPointer(_fogCoordAlias._location, 1, type, GL_FALSE, stride, ptr);
|
||||
@@ -871,11 +874,15 @@ void State::setFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
|
||||
_fogArray._dirty = false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
setVertexAttribPointer(_fogCoordAlias._location, 1, type, GL_FALSE, stride, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void State::setSecondaryColorPointer( GLint size, GLenum type,
|
||||
GLsizei stride, const GLvoid *ptr )
|
||||
{
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (_useVertexAttributeAliasing)
|
||||
{
|
||||
setVertexAttribPointer(_secondaryColorAlias._location, size, type, GL_FALSE, stride, ptr);
|
||||
@@ -898,6 +905,9 @@ void State::setSecondaryColorPointer( GLint size, GLenum type,
|
||||
_secondaryColorArray._dirty = false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
setVertexAttribPointer(_secondaryColorAlias._location, size, type, GL_FALSE, stride, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** wrapper around glEnableVertexAttribArrayARB(index);glVertexAttribPointerARB(..);
|
||||
@@ -978,7 +988,6 @@ void State::lazyDisablingOfVertexAttributes()
|
||||
_normalArray._lazy_disable = true;
|
||||
_colorArray._lazy_disable = true;
|
||||
_secondaryColorArray._lazy_disable = true;
|
||||
_indexArray._lazy_disable = true;
|
||||
_fogArray._lazy_disable = true;
|
||||
for(EnabledTexCoordArrayList::iterator itr = _texCoordArrayList.begin();
|
||||
itr != _texCoordArrayList.end();
|
||||
@@ -1005,7 +1014,6 @@ void State::applyDisablingOfVertexAttributes()
|
||||
if (_normalArray._lazy_disable) disableNormalPointer();
|
||||
if (_colorArray._lazy_disable) disableColorPointer();
|
||||
if (_secondaryColorArray._lazy_disable) disableSecondaryColorPointer();
|
||||
if (_indexArray._lazy_disable) disableIndexPointer();
|
||||
if (_fogArray._lazy_disable) disableFogCoordPointer();
|
||||
for(unsigned int i=0; i<_texCoordArrayList.size(); ++i)
|
||||
{
|
||||
@@ -1202,10 +1210,11 @@ void State::applyProjectionMatrix(const osg::RefMatrix* matrix)
|
||||
if (_projectionMatrixUniform.valid()) _projectionMatrixUniform->set(*_projection);
|
||||
updateModelViewAndProjectionMatrixUniforms();
|
||||
}
|
||||
|
||||
#ifdef OSG_GL_MATRICES_AVAILABLE
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadMatrix(_projection->ptr());
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,7 +1237,9 @@ void State::applyModelViewMatrix(const osg::RefMatrix* matrix)
|
||||
updateModelViewAndProjectionMatrixUniforms();
|
||||
}
|
||||
|
||||
#ifdef OSG_GL_MATRICES_AVAILABLE
|
||||
glLoadMatrix(_modelView->ptr());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,14 @@
|
||||
#include <osg/CullFace>
|
||||
#include <osg/FrontFace>
|
||||
#include <osg/PolygonMode>
|
||||
#include <osg/Material>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/Depth>
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Node>
|
||||
|
||||
#include <osg/TexGen>
|
||||
#include <osg/Texture1D>
|
||||
#include <osg/TextureCubeMap>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/Texture2DArray>
|
||||
@@ -789,7 +792,7 @@ void StateSet::setMode(StateAttribute::GLMode mode, StateAttribute::GLModeValue
|
||||
{
|
||||
notify(NOTICE)<<"Error: Setting mode 'GL_COLOR_MATERIAL' via osg::StateSet::setMode(mode,value) ignored.\n";
|
||||
notify(NOTICE)<<" The mode 'GL_COLOR_MATERIAL' is set by the osg::Material StateAttribute.\n";
|
||||
notify(NOTICE)<<" Setting this as a mode fools osg's State tracking."<<std::endl;
|
||||
notify(NOTICE)<<" Setting this mode would confuse osg's State tracking."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -811,7 +814,7 @@ void StateSet::removeMode(StateAttribute::GLMode mode)
|
||||
{
|
||||
notify(NOTICE)<<"Error: Setting mode 'GL_COLOR_MATERIAL' via osg::StateSet::removeMode(mode) ignored.\n";
|
||||
notify(NOTICE)<<" The mode 'GL_COLOR_MATERIAL' is set by the osg::Material StateAttribute.\n";
|
||||
notify(NOTICE)<<" Setting this as a mode fools osg's State tracking."<<std::endl;
|
||||
notify(NOTICE)<<" Setting this mode would confuse osg's State tracking."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <osg/ApplicationUsage>
|
||||
#include <osg/FrameBufferObject>
|
||||
#include <osg/TextureRectangle>
|
||||
#include <osg/Texture1D>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Mutex>
|
||||
@@ -1589,6 +1590,12 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
|
||||
if (extensions->isTextureBorderClampSupported())
|
||||
{
|
||||
|
||||
#ifndef GL_TEXTURE_BORDER_COLOR
|
||||
#define GL_TEXTURE_BORDER_COLOR 0x1004
|
||||
#endif
|
||||
|
||||
|
||||
if (_internalFormatType == SIGNED_INTEGER)
|
||||
{
|
||||
GLint color[4] = {(GLint)_borderColor.r(), (GLint)_borderColor.g(), (GLint)_borderColor.b(), (GLint)_borderColor.a()};
|
||||
@@ -1726,22 +1733,25 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
case GL_COMPRESSED_INTENSITY: _internalFormat = GL_INTENSITY; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
|
||||
|
||||
|
||||
bool useClientStorage = extensions->isClientStorageSupported() && getClientStorageHint();
|
||||
if (useClientStorage)
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE);
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY,0.0f);
|
||||
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY,0.0f);
|
||||
#endif
|
||||
|
||||
#ifdef GL_TEXTURE_STORAGE_HINT_APPLE
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
unsigned char* dataPtr = (unsigned char*)image->data();
|
||||
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"inwidth="<<inwidth<<" inheight="<<inheight<<" image->getFileName()"<<image->getFileName()<<std::endl;
|
||||
|
||||
bool needImageRescale = inwidth!=image->s() || inheight!=image->t();
|
||||
|
||||
@@ -119,7 +119,7 @@ void Texture1D::setImage(Image* image)
|
||||
|
||||
void Texture1D::apply(State& state) const
|
||||
{
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
@@ -229,6 +229,9 @@ void Texture1D::apply(State& state) const
|
||||
{
|
||||
generateMipmap(state);
|
||||
}
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Texture1D::apply(State& state) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture1D::computeInternalFormat() const
|
||||
@@ -239,6 +242,7 @@ void Texture1D::computeInternalFormat() const
|
||||
|
||||
void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& numMipmapLevels) const
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
// if we don't have a valid image we can't create a texture!
|
||||
if (!image || !image->data())
|
||||
return;
|
||||
@@ -348,10 +352,14 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
}
|
||||
|
||||
inwidth = image->s();
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Texture1D::applyTexImage1D(State& state) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture1D::copyTexImage1D(State& state, int x, int y, int width)
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
// get the texture object for the current contextID.
|
||||
@@ -401,10 +409,14 @@ void Texture1D::copyTexImage1D(State& state, int x, int y, int width)
|
||||
|
||||
// inform state that this texture is the current one bound.
|
||||
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Texture1D::copyTexImage1D(..) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int width)
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
// get the texture object for the current contextID.
|
||||
@@ -429,10 +441,14 @@ void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int w
|
||||
// create it upfront - simply call copyTexImage1D.
|
||||
copyTexImage1D(state,x,y,width);
|
||||
}
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Texture1D::copyTexSubImage1D(..) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture1D::allocateMipmap(State& state) const
|
||||
{
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
const unsigned int contextID = state.getContextID();
|
||||
|
||||
// get the texture object for the current contextID.
|
||||
@@ -466,4 +482,7 @@ void Texture1D::allocateMipmap(State& state) const
|
||||
// inform state that this texture is the current one bound.
|
||||
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
||||
}
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: Texture1D::allocateMipmap(..) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -296,9 +296,12 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
|
||||
if (useClientStorage)
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE);
|
||||
glTexParameterf(target,GL_TEXTURE_PRIORITY,0.0f);
|
||||
|
||||
#ifdef GL_TEXTURE_STORAGE_HINT_APPLE
|
||||
|
||||
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
|
||||
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY,0.0f);
|
||||
#endif
|
||||
|
||||
#ifdef GL_TEXTURE_STORAGE_HINT_APPLE
|
||||
glTexParameteri(target, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user