From d23ce985a11b6a95b81ad76af158040d338163f3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 7 Oct 2010 11:53:28 +0000 Subject: [PATCH] Introduced osg namespace to new local GLU functions --- examples/osgphotoalbum/PhotoArchive.cpp | 12 ++--- examples/osgtexture3D/osgtexture3D.cpp | 49 +------------------ include/osg/GLU | 9 +++- include/osgUtil/Tessellator | 2 +- src/osg/Image.cpp | 2 +- src/osg/glu/libtess/tess.cpp | 63 +++++-------------------- src/osg/glu/libtess/tess.h | 8 +++- src/osg/glu/libutil/error.cpp | 4 ++ src/osg/glu/libutil/mipmap.cpp | 4 ++ src/osgPlugins/lwo/Tessellator.cpp | 20 ++++---- src/osgText/Glyph.cpp | 4 +- 11 files changed, 54 insertions(+), 123 deletions(-) diff --git a/examples/osgphotoalbum/PhotoArchive.cpp b/examples/osgphotoalbum/PhotoArchive.cpp index a7f94b69e..59eac5d3e 100644 --- a/examples/osgphotoalbum/PhotoArchive.cpp +++ b/examples/osgphotoalbum/PhotoArchive.cpp @@ -215,11 +215,11 @@ void PhotoArchive::buildArchive(const std::string& filename, const FileNameList& return; } - PixelStorageModes psm; + osg::PixelStorageModes psm; psm.pack_alignment = image->getPacking(); psm.unpack_alignment = image->getPacking(); - GLint status = gluScaleImage(&psm, image->getPixelFormat(), + GLint status = osg::gluScaleImage(&psm, image->getPixelFormat(), image->s(), image->t(), image->getDataType(), @@ -233,7 +233,7 @@ void PhotoArchive::buildArchive(const std::string& filename, const FileNameList& { delete [] newData; - osg::notify(osg::WARN) << "Error scaleImage() did not succeed : errorString = "< image_0 = osgDB::readImageFile("Images/lz.rgb"); osg::ref_ptr image_1 = osgDB::readImageFile("Images/reflect.rgb"); @@ -102,10 +58,7 @@ osg::StateSet* createState() return new osg::StateSet; } - // get max 3D texture size - GLint textureSize = osg::Texture3D::getExtensions(0,true)->maxTexture3DSize(); - if (textureSize > 256) - textureSize = 256; + GLint textureSize = 256; // scale them all to the same size. image_0->scaleImage(textureSize,textureSize,1); diff --git a/include/osg/GLU b/include/osg/GLU index 8432c963b..6a98f7f2b 100644 --- a/include/osg/GLU +++ b/include/osg/GLU @@ -16,6 +16,9 @@ #include +namespace osg +{ + /* Pixel storage modes, used by gluScaleImage */ struct OSG_EXPORT PixelStorageModes { @@ -163,13 +166,15 @@ extern OSG_EXPORT GLUtesselator* gluNewTess (void); extern OSG_EXPORT void gluDeleteTess (GLUtesselator* tess); extern OSG_EXPORT void gluTessBeginContour (GLUtesselator* tess); -extern OSG_EXPORT void gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data); extern OSG_EXPORT void gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); extern OSG_EXPORT void gluTessEndContour (GLUtesselator* tess); -extern OSG_EXPORT void gluTessEndPolygon (GLUtesselator* tess); extern OSG_EXPORT void gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); extern OSG_EXPORT void gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data); extern OSG_EXPORT void gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data); +extern OSG_EXPORT void gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data); +extern OSG_EXPORT void gluTessEndPolygon (GLUtesselator* tess); +extern OSG_EXPORT void gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value ); +} #endif // __osgGLU_h diff --git a/include/osgUtil/Tessellator b/include/osgUtil/Tessellator index e679b15f9..4225340ec 100644 --- a/include/osgUtil/Tessellator +++ b/include/osgUtil/Tessellator @@ -210,7 +210,7 @@ class OSGUTIL_EXPORT Tessellator : public osg::Referenced typedef std::vector NewVertexList; typedef std::vector Vec3dList; - GLUtesselator* _tobj; + osg::GLUtesselator* _tobj; PrimList _primList; Vec3dList _coordData; diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 796be4126..a6cb2dfc2 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1003,7 +1003,7 @@ void Image::copySubImage(int s_offset, int t_offset, int r_offset, const osg::Im PixelStorageModes psm; psm.pack_alignment = _packing; - psm.pack_row_length = _packing; + psm.pack_row_length = _s; psm.unpack_alignment = _packing; GLint status = gluScaleImage(&psm, _pixelFormat, diff --git a/src/osg/glu/libtess/tess.cpp b/src/osg/glu/libtess/tess.cpp index c7a68aacb..1c7d91a08 100644 --- a/src/osg/glu/libtess/tess.cpp +++ b/src/osg/glu/libtess/tess.cpp @@ -54,6 +54,7 @@ #define FALSE 0 #endif + /*ARGSUSED*/ static void GLAPIENTRY noBegin( GLenum type ) {} /*ARGSUSED*/ static void GLAPIENTRY noEdgeFlag( GLboolean boundaryEdge ) {} /*ARGSUSED*/ static void GLAPIENTRY noVertex( void *data ) {} @@ -89,7 +90,7 @@ typedef struct { GLUhalfEdge e, eSym; } EdgePair; GLUtesselator * GLAPIENTRY -gluNewTess( void ) +osg::gluNewTess( void ) { GLUtesselator *tess; @@ -190,7 +191,7 @@ static void GotoState( GLUtesselator *tess, enum TessState newState ) void GLAPIENTRY -gluDeleteTess( GLUtesselator *tess ) +osg::gluDeleteTess( GLUtesselator *tess ) { RequireState( tess, T_DORMANT ); memFree( tess ); @@ -198,7 +199,7 @@ gluDeleteTess( GLUtesselator *tess ) void GLAPIENTRY -gluTessProperty( GLUtesselator *tess, GLenum which, GLdouble value ) +osg::gluTessProperty( GLUtesselator *tess, GLenum which, GLdouble value ) { GLenum windingRule; @@ -237,7 +238,7 @@ gluTessProperty( GLUtesselator *tess, GLenum which, GLdouble value ) /* Returns tessellator property */ void GLAPIENTRY -gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value ) +osg::gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value ) { switch (which) { case GLU_TESS_TOLERANCE: @@ -265,7 +266,7 @@ gluGetTessProperty( GLUtesselator *tess, GLenum which, GLdouble *value ) } /* gluGetTessProperty() */ void GLAPIENTRY -gluTessNormal( GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z ) +osg::gluTessNormal( GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z ) { tess->normal[0] = x; tess->normal[1] = y; @@ -273,7 +274,7 @@ gluTessNormal( GLUtesselator *tess, GLdouble x, GLdouble y, GLdouble z ) } void GLAPIENTRY -gluTessCallback( GLUtesselator *tess, GLenum which, _GLUfuncptr fn) +osg::gluTessCallback( GLUtesselator *tess, GLenum which, _GLUfuncptr fn) { switch( which ) { case GLU_TESS_BEGIN: @@ -412,7 +413,7 @@ static int EmptyCache( GLUtesselator *tess ) void GLAPIENTRY -gluTessVertex( GLUtesselator *tess, GLdouble coords[3], void *data ) +osg::gluTessVertex( GLUtesselator *tess, GLdouble coords[3], void *data ) { int i, tooLarge = FALSE; GLdouble x, clamped[3]; @@ -459,7 +460,7 @@ gluTessVertex( GLUtesselator *tess, GLdouble coords[3], void *data ) void GLAPIENTRY -gluTessBeginPolygon( GLUtesselator *tess, void *data ) +osg::gluTessBeginPolygon( GLUtesselator *tess, void *data ) { RequireState( tess, T_DORMANT ); @@ -473,7 +474,7 @@ gluTessBeginPolygon( GLUtesselator *tess, void *data ) void GLAPIENTRY -gluTessBeginContour( GLUtesselator *tess ) +osg::gluTessBeginContour( GLUtesselator *tess ) { RequireState( tess, T_IN_POLYGON ); @@ -490,14 +491,14 @@ gluTessBeginContour( GLUtesselator *tess ) void GLAPIENTRY -gluTessEndContour( GLUtesselator *tess ) +osg::gluTessEndContour( GLUtesselator *tess ) { RequireState( tess, T_IN_CONTOUR ); tess->state = T_IN_POLYGON; } void GLAPIENTRY -gluTessEndPolygon( GLUtesselator *tess ) +osg::gluTessEndPolygon( GLUtesselator *tess ) { GLUmesh *mesh; @@ -590,43 +591,3 @@ gluTessEndPolygon( GLUtesselator *tess ) tess->polygonData= NULL; tess->mesh = NULL; } - - -/*XXXblythe unused function*/ -#if 0 -void GLAPIENTRY -gluDeleteMesh( GLUmesh *mesh ) -{ - __gl_meshDeleteMesh( mesh ); -} -#endif - - - -/*******************************************************/ - -/* Obsolete calls -- for backward compatibility */ - -void GLAPIENTRY -gluBeginPolygon( GLUtesselator *tess ) -{ - gluTessBeginPolygon( tess, NULL ); - gluTessBeginContour( tess ); -} - - -/*ARGSUSED*/ -void GLAPIENTRY -gluNextContour( GLUtesselator *tess, GLenum type ) -{ - gluTessEndContour( tess ); - gluTessBeginContour( tess ); -} - - -void GLAPIENTRY -gluEndPolygon( GLUtesselator *tess ) -{ - gluTessEndContour( tess ); - gluTessEndPolygon( tess ); -} diff --git a/src/osg/glu/libtess/tess.h b/src/osg/glu/libtess/tess.h index 912cc5b9d..d9594f363 100644 --- a/src/osg/glu/libtess/tess.h +++ b/src/osg/glu/libtess/tess.h @@ -46,7 +46,6 @@ #include "dict.h" #include "priorityq.h" - /* The begin/end calls must be properly nested. We keep track of * the current state to enforce the ordering. */ @@ -62,7 +61,7 @@ typedef struct CachedVertex { void *data; } CachedVertex; -struct GLUtesselator { +struct osg::GLUtesselator { /*** state needed for collecting the input data ***/ @@ -168,4 +167,9 @@ void GLAPIENTRY __gl_noCombineData( GLdouble coords[3], void *data[4], (*tess->callErrorData)((a),tess->polygonData); \ else (*tess->callError)((a)); +// make it easy to introduce the namespace osg for the public functions and typedefs +using osg::GLUtesselator; +using osg::_GLUfuncptr; + + #endif diff --git a/src/osg/glu/libutil/error.cpp b/src/osg/glu/libutil/error.cpp index 1a65fc05c..0d601cf26 100644 --- a/src/osg/glu/libutil/error.cpp +++ b/src/osg/glu/libutil/error.cpp @@ -36,6 +36,9 @@ #define GL_TABLE_TOO_LARGE 0x8031 #endif +namespace osg +{ + static unsigned char *__gluNurbsErrors[] = { (unsigned char*) " ", (unsigned char*) "spline order un-supported", @@ -140,3 +143,4 @@ const GLubyte* gluErrorString(GLenum errorCode) return (const GLubyte *) 0; } +} // end of namespace osg \ No newline at end of file diff --git a/src/osg/glu/libutil/mipmap.cpp b/src/osg/glu/libutil/mipmap.cpp index 8632c63b9..9b155cdf1 100644 --- a/src/osg/glu/libutil/mipmap.cpp +++ b/src/osg/glu/libutil/mipmap.cpp @@ -50,6 +50,9 @@ #include #include +namespace osg +{ + typedef union { unsigned char ub[4]; unsigned short us[2]; @@ -8970,3 +8973,4 @@ static void halveImage3D(int components, /*** mipmap.c ***/ +} // end of namespace osg \ No newline at end of file diff --git a/src/osgPlugins/lwo/Tessellator.cpp b/src/osgPlugins/lwo/Tessellator.cpp index bbfae77e8..51e6d2e82 100644 --- a/src/osgPlugins/lwo/Tessellator.cpp +++ b/src/osgPlugins/lwo/Tessellator.cpp @@ -44,15 +44,15 @@ bool Tessellator::tessellate(const Polygon &poly, const osg::Vec3Array *points, out_ = out; last_error_ = 0; - GLUtesselator *tess = gluNewTess(); + osg::GLUtesselator *tess = osg::gluNewTess(); - gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (GLU_TESS_CALLBACK) (cb_begin_data)); - gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (GLU_TESS_CALLBACK) (cb_vertex_data)); - gluTessCallback(tess, GLU_TESS_END_DATA, (GLU_TESS_CALLBACK) (cb_end_data)); - gluTessCallback(tess, GLU_TESS_ERROR_DATA, (GLU_TESS_CALLBACK) (cb_error_data)); + osg::gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (osg::GLU_TESS_CALLBACK) (cb_begin_data)); + osg::gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (osg::GLU_TESS_CALLBACK) (cb_vertex_data)); + osg::gluTessCallback(tess, GLU_TESS_END_DATA, (osg::GLU_TESS_CALLBACK) (cb_end_data)); + osg::gluTessCallback(tess, GLU_TESS_ERROR_DATA, (osg::GLU_TESS_CALLBACK) (cb_error_data)); - gluTessBeginPolygon(tess, this); - gluTessBeginContour(tess); + osg::gluTessBeginPolygon(tess, this); + osg::gluTessBeginContour(tess); double *vertices = new double[poly.indices().size() * 3]; int *indices = new int[poly.indices().size()]; @@ -72,9 +72,9 @@ bool Tessellator::tessellate(const Polygon &poly, const osg::Vec3Array *points, gluTessVertex(tess, v, x); } - gluTessEndContour(tess); - gluTessEndPolygon(tess); - gluDeleteTess(tess); + osg::gluTessEndContour(tess); + osg::gluTessEndPolygon(tess); + osg::gluDeleteTess(tess); delete[] vertices; delete[] indices; diff --git a/src/osgText/Glyph.cpp b/src/osgText/Glyph.cpp index a4d613364..54120f3aa 100644 --- a/src/osgText/Glyph.cpp +++ b/src/osgText/Glyph.cpp @@ -434,7 +434,7 @@ void Glyph::subload() const GLenum errorNo = glGetError(); if (errorNo!=GL_NO_ERROR) { - const GLubyte* msg = gluErrorString(errorNo); + const GLubyte* msg = osg::gluErrorString(errorNo); if (msg) { OSG_WARN<<"before Glyph::subload(): detected OpenGL error: "<