Introduced optional build against the GLU library, using optional compile paths to enable/disable GLU related function.
To toggle the use of the GLU library adjust the OSG_GLU_AVAILABLE variable via ccmake . or CMakeSetup.
This commit is contained in:
parent
6992e8eedf
commit
2d26cbe7ab
@ -280,6 +280,9 @@ MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
|
||||
|
||||
OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
|
||||
|
||||
OPTION(OSG_GLU_AVAILABLE "Set to OFF to disable use of OpenGL GLU library." ${OPENGL_GLU_FOUND})
|
||||
MARK_AS_ADVANCED(OSG_GLU_AVAILABLE)
|
||||
|
||||
################################################################################
|
||||
# Set Config file
|
||||
|
||||
|
@ -71,7 +71,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgparametric)
|
||||
ADD_SUBDIRECTORY(osgparticle)
|
||||
ADD_SUBDIRECTORY(osgparticleeffects)
|
||||
ADD_SUBDIRECTORY(osgphotoalbum)
|
||||
ADD_SUBDIRECTORY(osgpick)
|
||||
ADD_SUBDIRECTORY(osgplanets)
|
||||
ADD_SUBDIRECTORY(osgpoints)
|
||||
@ -103,7 +102,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgstereomatch)
|
||||
ADD_SUBDIRECTORY(osgteapot)
|
||||
ADD_SUBDIRECTORY(osgterrain)
|
||||
ADD_SUBDIRECTORY(osgtessellate)
|
||||
ADD_SUBDIRECTORY(osgtext)
|
||||
ADD_SUBDIRECTORY(osgtext3D)
|
||||
ADD_SUBDIRECTORY(osgtexture1D)
|
||||
@ -140,6 +138,11 @@ IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_SUBDIRECTORY(osgwidgettable)
|
||||
ADD_SUBDIRECTORY(osgwidgetwindow)
|
||||
|
||||
IF(OSG_GLU_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(osgphotoalbum)
|
||||
ADD_SUBDIRECTORY(osgtessellate)
|
||||
ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(osgpdf)
|
||||
|
||||
IF (BUILD_OSG_WRAPPERS)
|
||||
|
@ -14,19 +14,25 @@
|
||||
#ifndef OSG_GLU
|
||||
#define OSG_GLU 1
|
||||
|
||||
#include <osg/GL>
|
||||
#include <osg/Config>
|
||||
|
||||
#if defined(__APPLE__) || \
|
||||
(defined (_AIX) && !defined (_AIX51))
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
|
||||
#include <osg/GL>
|
||||
|
||||
#if defined(__APPLE__) || \
|
||||
(defined (_AIX) && !defined (_AIX51))
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#if defined(GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
typedef void (APIENTRY *GLU_TESS_CALLBACK)(...);
|
||||
#else
|
||||
typedef void (APIENTRY *GLU_TESS_CALLBACK)();
|
||||
#endif
|
||||
|
||||
#if defined(GLU_TESS_CALLBACK_TRIPLEDOT)
|
||||
typedef void (APIENTRY *GLU_TESS_CALLBACK)(...);
|
||||
#else
|
||||
typedef void (APIENTRY *GLU_TESS_CALLBACK)();
|
||||
#endif
|
||||
|
||||
#endif // __osgGLU_h
|
||||
|
@ -23,6 +23,19 @@
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
#ifndef OSG_GLU_AVAILABLE
|
||||
// as we have no GLU we'll just define the required enum values
|
||||
#define GLU_FALSE 0
|
||||
#define GLU_FILL 100012
|
||||
#define GLU_SMOOTH 100000
|
||||
#define GLU_OUTSIDE 100020
|
||||
#define GLU_NONE 100002
|
||||
#define GLU_POINT 100010
|
||||
#define GLU_LINE 100011
|
||||
#define GLU_FILL 100012
|
||||
#define GLU_SILHOUETTE 100013
|
||||
#endif
|
||||
|
||||
/** A class for assisting the building ascene graphs that is equivilant to OpenGL 1.0 style calls.
|
||||
*/
|
||||
class OSGUTIL_EXPORT SceneGraphBuilder
|
||||
|
@ -42,6 +42,7 @@ class OSGUTIL_EXPORT Tessellator : public osg::Referenced
|
||||
~Tessellator();
|
||||
|
||||
/** The winding rule, see red book ch 11. */
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
enum WindingType{
|
||||
TESS_WINDING_ODD = GLU_TESS_WINDING_ODD,
|
||||
TESS_WINDING_NONZERO = GLU_TESS_WINDING_NONZERO ,
|
||||
@ -49,7 +50,15 @@ class OSGUTIL_EXPORT Tessellator : public osg::Referenced
|
||||
TESS_WINDING_NEGATIVE = GLU_TESS_WINDING_NEGATIVE ,
|
||||
TESS_WINDING_ABS_GEQ_TWO = GLU_TESS_WINDING_ABS_GEQ_TWO
|
||||
} ;
|
||||
|
||||
#else
|
||||
enum WindingType{
|
||||
TESS_WINDING_ODD,
|
||||
TESS_WINDING_NONZERO,
|
||||
TESS_WINDING_POSITIVE,
|
||||
TESS_WINDING_NEGATIVE,
|
||||
TESS_WINDING_ABS_GEQ_TWO
|
||||
} ;
|
||||
#endif
|
||||
/** we interpret all contours in the geometry as a single set to be tessellated or
|
||||
* each separate drawable's contours needs to be tessellated. */
|
||||
enum TessellationType {
|
||||
@ -211,7 +220,11 @@ class OSGUTIL_EXPORT Tessellator : public osg::Referenced
|
||||
typedef std::vector<NewVertex> NewVertexList;
|
||||
typedef std::vector<Vec3d*> Vec3dList;
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
GLUtesselator* _tobj;
|
||||
#else
|
||||
void* _tobj;
|
||||
#endif
|
||||
PrimList _primList;
|
||||
Vec3dList _coordData;
|
||||
NewVertexList _newVertexList;
|
||||
|
@ -30,6 +30,6 @@
|
||||
#cmakedefine OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION
|
||||
#cmakedefine OSG_USE_UTF8_FILENAME
|
||||
#cmakedefine OSG_DISABLE_MSVC_WARNINGS
|
||||
|
||||
#cmakedefine OSG_GLU_AVAILABLE
|
||||
|
||||
#endif
|
||||
|
@ -235,53 +235,61 @@ std::string& osg::getGLExtensionDisableString()
|
||||
return s_GLExtensionDisableString;
|
||||
}
|
||||
|
||||
|
||||
bool osg::isGLUExtensionSupported(unsigned int contextID, const char *extension)
|
||||
{
|
||||
ExtensionSet& extensionSet = s_gluExtensionSetList[contextID];
|
||||
std::string& rendererString = s_gluRendererList[contextID];
|
||||
|
||||
// if not already set up, initialize all the per graphic context values.
|
||||
if (!s_gluInitializedList[contextID])
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
bool osg::isGLUExtensionSupported(unsigned int contextID, const char *extension)
|
||||
{
|
||||
s_gluInitializedList[contextID] = 1;
|
||||
|
||||
// set up the renderer
|
||||
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||
rendererString = renderer ? (const char*)renderer : "";
|
||||
ExtensionSet& extensionSet = s_gluExtensionSetList[contextID];
|
||||
std::string& rendererString = s_gluRendererList[contextID];
|
||||
|
||||
// get the extension list from OpenGL.
|
||||
const char* extensions = (const char*)gluGetString(GLU_EXTENSIONS);
|
||||
if (extensions==NULL) return false;
|
||||
// if not already set up, initialize all the per graphic context values.
|
||||
if (!s_gluInitializedList[contextID])
|
||||
{
|
||||
s_gluInitializedList[contextID] = 1;
|
||||
|
||||
// set up the renderer
|
||||
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||
rendererString = renderer ? (const char*)renderer : "";
|
||||
|
||||
// get the extension list from OpenGL.
|
||||
const char* extensions = (const char*)gluGetString(GLU_EXTENSIONS);
|
||||
if (extensions==NULL) return false;
|
||||
|
||||
// insert the ' ' delimiated extensions words into the extensionSet.
|
||||
const char *startOfWord = extensions;
|
||||
const char *endOfWord;
|
||||
while ((endOfWord = strchr(startOfWord,' '))!=NULL)
|
||||
{
|
||||
extensionSet.insert(std::string(startOfWord,endOfWord));
|
||||
startOfWord = endOfWord+1;
|
||||
}
|
||||
if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord));
|
||||
|
||||
osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"<<std::endl;
|
||||
for(ExtensionSet::iterator itr=extensionSet.begin();
|
||||
itr!=extensionSet.end();
|
||||
++itr)
|
||||
{
|
||||
osg::notify(INFO)<<" "<<*itr<<std::endl;
|
||||
}
|
||||
|
||||
// insert the ' ' delimiated extensions words into the extensionSet.
|
||||
const char *startOfWord = extensions;
|
||||
const char *endOfWord;
|
||||
while ((endOfWord = strchr(startOfWord,' '))!=NULL)
|
||||
{
|
||||
extensionSet.insert(std::string(startOfWord,endOfWord));
|
||||
startOfWord = endOfWord+1;
|
||||
}
|
||||
if (*startOfWord!=0) extensionSet.insert(std::string(startOfWord));
|
||||
|
||||
osg::notify(INFO)<<"OpenGL extensions supported by installed OpenGL drivers are:"<<std::endl;
|
||||
for(ExtensionSet::iterator itr=extensionSet.begin();
|
||||
itr!=extensionSet.end();
|
||||
++itr)
|
||||
{
|
||||
osg::notify(INFO)<<" "<<*itr<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
// true if extension found in extensionSet.
|
||||
bool result = extensionSet.find(extension)!=extensionSet.end();
|
||||
|
||||
if (result) osg::notify(INFO)<<"OpenGL utility library extension '"<<extension<<"' is supported."<<std::endl;
|
||||
else osg::notify(INFO)<<"OpenGL utility library extension '"<<extension<<"' is not supported."<<std::endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
bool osg::isGLUExtensionSupported(unsigned int, const char *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// true if extension found in extensionSet.
|
||||
bool result = extensionSet.find(extension)!=extensionSet.end();
|
||||
|
||||
if (result) osg::notify(INFO)<<"OpenGL utility library extension '"<<extension<<"' is supported."<<std::endl;
|
||||
else osg::notify(INFO)<<"OpenGL utility library extension '"<<extension<<"' is not supported."<<std::endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
@ -875,124 +875,135 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Image::scaleImage(int s,int t,int r, GLenum newDataType)
|
||||
{
|
||||
if (_s==s && _t==t && _r==r) return;
|
||||
|
||||
if (_data==NULL)
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
void Image::scaleImage(int s,int t,int r, GLenum newDataType)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : cannot scale NULL image."<<std::endl;
|
||||
return;
|
||||
}
|
||||
if (_s==s && _t==t && _r==r) return;
|
||||
|
||||
if (_r!=1 || r!=1)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,_packing);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,_packing);
|
||||
|
||||
GLint status = gluScaleImage(_pixelFormat,
|
||||
_s,
|
||||
_t,
|
||||
_dataType,
|
||||
_data,
|
||||
s,
|
||||
t,
|
||||
newDataType,
|
||||
newData);
|
||||
|
||||
if (status==0)
|
||||
{
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
dirty();
|
||||
}
|
||||
#else
|
||||
void Image::scaleImage(int,int,int, GLenum)
|
||||
{
|
||||
notify(WARN) << "Error Image::scaleImage() do not succeed : scaling of volumes not implemented."<<std::endl;
|
||||
return;
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::scaleImage(int s,int t,int r, GLenum newDataType) not supported."<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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)
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
void Image::copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image* source)
|
||||
{
|
||||
// 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT,_packing);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,_packing);
|
||||
|
||||
GLint status = gluScaleImage(_pixelFormat,
|
||||
_s,
|
||||
_t,
|
||||
_dataType,
|
||||
_data,
|
||||
s,
|
||||
t,
|
||||
newDataType,
|
||||
newData);
|
||||
|
||||
if (status==0)
|
||||
#else
|
||||
void Image::copySubImage(int, int, int, const osg::Image*)
|
||||
{
|
||||
|
||||
// free old image.
|
||||
_s = s;
|
||||
_t = t;
|
||||
_dataType = newDataType;
|
||||
setData(newData,USE_NEW_DELETE);
|
||||
osg::notify(osg::NOTICE)<<"Warning: Image::copySubImage(int, int, int, const osg::Image*)) not supported."<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete [] newData;
|
||||
|
||||
notify(WARN) << "Error Image::scaleImage() did not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
|
||||
dirty();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Image::flipHorizontal()
|
||||
{
|
||||
|
@ -982,10 +982,13 @@ bool State::checkGLErrors(const char* str) const
|
||||
GLenum errorNo = glGetError();
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
const char* error = (char*)gluErrorString(errorNo);
|
||||
if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '" << error<<"'";
|
||||
else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x" << std::hex << errorNo << std::dec;
|
||||
|
||||
#else
|
||||
osg::notify(WARN)<<"Warning: detected OpenGL error number 0x" << std::hex << errorNo << std::dec;
|
||||
#endif
|
||||
if (str) osg::notify(WARN)<<" at "<<str<< std::endl;
|
||||
else osg::notify(WARN)<<" in osg::State."<< std::endl;
|
||||
|
||||
@ -999,10 +1002,13 @@ bool State::checkGLErrors(StateAttribute::GLMode mode) const
|
||||
GLenum errorNo = glGetError();
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
const char* error = (char*)gluErrorString(errorNo);
|
||||
if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '"<< error <<"' after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
|
||||
else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
|
||||
|
||||
#else
|
||||
osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1013,9 +1019,13 @@ bool State::checkGLErrors(const StateAttribute* attribute) const
|
||||
GLenum errorNo = glGetError();
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
const char* error = (char*)gluErrorString(errorNo);
|
||||
if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '"<< error <<"' after applying attribute "<<attribute->className()<<" "<<attribute<< std::endl;
|
||||
else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
|
||||
#else
|
||||
osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1747,7 +1747,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
bool needImageRescale = inwidth!=image->s() || inheight!=image->t();
|
||||
if (needImageRescale)
|
||||
{
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
// resize the image to power of two.
|
||||
|
||||
if (image->isMipmap())
|
||||
@ -1778,8 +1778,11 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
gluScaleImage(image->getPixelFormat(),
|
||||
image->s(),image->t(),image->getDataType(),image->data(),
|
||||
inwidth,inheight,image->getDataType(),dataPtr);
|
||||
|
||||
}
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: gluScaleImage(..) not supported, cannot subload image."<<std::endl;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool mipmappingRequired = _min_filter != LINEAR && _min_filter != NEAREST;
|
||||
bool useHardwareMipMapGeneration = mipmappingRequired && (!image->isMipmap() && isHardwareMipmapGenerationEnabled(state));
|
||||
@ -1891,7 +1894,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
if ( !compressed_image)
|
||||
{
|
||||
numMipmapLevels = 0;
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
gluBuild2DMipmaps( target, _internalFormat,
|
||||
inwidth,inheight,
|
||||
(GLenum)image->getPixelFormat(), (GLenum)image->getDataType(),
|
||||
@ -1904,6 +1907,9 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
width >>= 1;
|
||||
height >>= 1;
|
||||
}
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning:: gluBuild2DMipMaps(..) not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1989,9 +1995,8 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
bool needImageRescale = inwidth!=image->s() || inheight!=image->t();
|
||||
if (needImageRescale)
|
||||
{
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
// resize the image to power of two.
|
||||
|
||||
if (image->isMipmap())
|
||||
{
|
||||
notify(WARN)<<"Warning:: Mipmapped osg::Image not a power of two, cannot apply to texture."<<std::endl;
|
||||
@ -2002,10 +2007,10 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
notify(WARN)<<"Warning:: Compressed osg::Image not a power of two, cannot apply to texture."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
unsigned int newTotalSize = osg::Image::computeRowWidthInBytes(inwidth,image->getPixelFormat(),image->getDataType(),image->getPacking())*inheight;
|
||||
data = new unsigned char [newTotalSize];
|
||||
|
||||
|
||||
if (!data)
|
||||
{
|
||||
notify(WARN)<<"Warning:: Not enough memory to resize image, cannot apply to texture."<<std::endl;
|
||||
@ -2020,6 +2025,10 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
gluScaleImage(image->getPixelFormat(),
|
||||
image->s(),image->t(),image->getDataType(),image->data(),
|
||||
inwidth,inheight,image->getDataType(),data);
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: gluScaleImage(..) not supported, cannot subload image."<<std::endl;
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,10 +299,14 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
|
||||
numMipmapLevels = 1;
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
gluBuild1DMipmaps( target, _internalFormat,
|
||||
image->s(),
|
||||
(GLenum)image->getPixelFormat(), (GLenum)image->getDataType(),
|
||||
image->data() );
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: gluBuild1DMipmaps(..) not supported."<<std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -157,10 +157,13 @@ IF(COLLADA_FOUND)
|
||||
ADD_SUBDIRECTORY(dae)
|
||||
ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(lwo)
|
||||
IF(OSG_GLU_AVAILABLE)
|
||||
ADD_SUBDIRECTORY(lwo)
|
||||
ADD_SUBDIRECTORY(dw)
|
||||
ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(bvh)
|
||||
ADD_SUBDIRECTORY(x)
|
||||
ADD_SUBDIRECTORY(dw)
|
||||
ADD_SUBDIRECTORY(ply)
|
||||
ADD_SUBDIRECTORY(dxf)
|
||||
ADD_SUBDIRECTORY(OpenFlight)
|
||||
|
@ -860,7 +860,13 @@ void Font::Glyph::subload() const
|
||||
GLenum errorNo = glGetError();
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
osg::notify(osg::WARN)<<"before Font::Glyph::subload(): detected OpenGL error '"<<gluErrorString(errorNo)<<std::endl;
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
const GLubyte* msg = gluErrorString(errorNo);
|
||||
if (msg) osg::notify(osg::WARN)<<"before Font::Glyph::subload(): detected OpenGL error: "<<msg<<std::endl;
|
||||
else osg::notify(osg::WARN)<<"before Font::Glyph::subload(): detected OpenGL error number: "<<errorNo<<std::endl;
|
||||
#else
|
||||
osg::notify(osg::WARN)<<"before Font::Glyph::subload(): detected OpenGL error number: "<<errorNo<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(s() <= 0 || t() <= 0)
|
||||
@ -882,7 +888,15 @@ void Font::Glyph::subload() const
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
|
||||
osg::notify(osg::WARN)<<"after Font::Glyph::subload() : detected OpenGL error '"<<gluErrorString(errorNo)<<"'"<<std::endl;
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
const GLubyte* msg = gluErrorString(errorNo);
|
||||
if (msg) osg::notify(osg::WARN)<<"after Font::Glyph::subload() : detected OpenGL error: "<<msg<<std::endl;
|
||||
else osg::notify(osg::WARN)<<"after Font::Glyph::subload() : detected OpenGL error number: "<<errorNo<<std::endl;
|
||||
#else
|
||||
osg::notify(osg::WARN)<<"after Font::Glyph::subload() : detected OpenGL error number: "<<errorNo<<std::endl;
|
||||
#endif
|
||||
|
||||
osg::notify(osg::WARN)<< "\tglTexSubImage2D(0x"<<hex<<GL_TEXTURE_2D<<dec<<" ,"<<0<<"\t"<<std::endl<<
|
||||
"\t "<<_texturePosX<<" ,"<<_texturePosY<<std::endl<<
|
||||
"\t "<<s()<<" ,"<<t()<<std::endl<<hex<<
|
||||
|
@ -881,10 +881,13 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
GLenum errorNo = glGetError();
|
||||
if (errorNo!=GL_NO_ERROR)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
const char* error = (char*)gluErrorString(errorNo);
|
||||
if (error) osg::notify(osg::NOTICE)<<"Warning: detected OpenGL error '"<<error<<"' after RenderBin::draw(,)"<<std::endl;
|
||||
else osg::notify(osg::NOTICE)<<"Warning: detected OpenGL errorNo= 0x"<<std::hex<<errorNo<<" after RenderBin::draw(,)"<<std::dec<<std::endl;
|
||||
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: detected OpenGL errorNo= 0x"<<std::hex<<errorNo<<" after RenderBin::draw(,)"<<std::dec<<std::endl;
|
||||
#endif
|
||||
if ( fbo_ext )
|
||||
{
|
||||
GLenum fbstatus = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
|
@ -28,6 +28,10 @@ Tessellator::Tessellator() :
|
||||
_tobj = 0;
|
||||
_errorCode = 0;
|
||||
_index=0;
|
||||
|
||||
#ifndef OSG_GLU_AVAILABLE
|
||||
osg::notify(osg::NOTICE)<<"Warning: gluTesselation not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
Tessellator::~Tessellator()
|
||||
@ -39,6 +43,7 @@ void Tessellator::beginTessellation()
|
||||
{
|
||||
reset();
|
||||
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (!_tobj) _tobj = gluNewTess();
|
||||
|
||||
gluTessCallback(_tobj, GLU_TESS_VERTEX_DATA, (GLU_TESS_CALLBACK) vertexCallback);
|
||||
@ -49,18 +54,24 @@ void Tessellator::beginTessellation()
|
||||
if (tessNormal.length()>0.0) gluTessNormal(_tobj, tessNormal.x(), tessNormal.y(), tessNormal.z());
|
||||
|
||||
gluTessBeginPolygon(_tobj,this);
|
||||
#else
|
||||
osg::notify(osg::NOTICE)<<"Warning: gluTesselation not supported."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tessellator::beginContour()
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (_tobj)
|
||||
{
|
||||
gluTessBeginContour(_tobj);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tessellator::addVertex(osg::Vec3* vertex)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (_tobj)
|
||||
{
|
||||
Vec3d* data = new Vec3d;
|
||||
@ -70,18 +81,22 @@ void Tessellator::addVertex(osg::Vec3* vertex)
|
||||
(*data)._v[2]=(*vertex)[2];
|
||||
gluTessVertex(_tobj,data->_v,vertex);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tessellator::endContour()
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (_tobj)
|
||||
{
|
||||
gluTessEndContour(_tobj);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tessellator::endTessellation()
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (_tobj)
|
||||
{
|
||||
gluTessEndPolygon(_tobj);
|
||||
@ -94,15 +109,18 @@ void Tessellator::endTessellation()
|
||||
osg::notify(osg::WARN)<<"Tessellation Error: "<<estring<< std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tessellator::reset()
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
if (_tobj)
|
||||
{
|
||||
gluDeleteTess(_tobj);
|
||||
_tobj = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (Vec3dList::iterator i = _coordData.begin(); i != _coordData.end(); ++i)
|
||||
{
|
||||
@ -166,6 +184,7 @@ class InsertNewVertices : public osg::ArrayVisitor
|
||||
|
||||
void Tessellator::retessellatePolygons(osg::Geometry &geom)
|
||||
{
|
||||
#ifdef OSG_GLU_AVAILABLE
|
||||
// turn the contour list into primitives, a little like Tessellator does but more generally
|
||||
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geom.getVertexArray());
|
||||
|
||||
@ -284,6 +303,7 @@ void Tessellator::retessellatePolygons(osg::Geometry &geom)
|
||||
|
||||
collectTessellation(geom, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tessellator::addContour(GLenum mode, unsigned int first, unsigned int last, osg::Vec3Array* vertices)
|
||||
|
Loading…
Reference in New Issue
Block a user