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:
@@ -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