Introduced osg namespace to new local GLU functions
This commit is contained in:
parent
12e6a23451
commit
d23ce985a1
@ -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 = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
osg::notify(osg::WARN) << "Error scaleImage() did not succeed : errorString = "<<osg::gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
|
||||
// now set up the photo header.
|
||||
@ -282,11 +282,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(),
|
||||
@ -300,7 +300,7 @@ void PhotoArchive::buildArchive(const std::string& filename, const FileNameList&
|
||||
{
|
||||
delete [] newData;
|
||||
|
||||
osg::notify(osg::WARN) << "Error scaleImage() did not succeed : errorString = "<<gluErrorString((GLenum)status)<<std::endl;
|
||||
osg::notify(osg::WARN) << "Error scaleImage() did not succeed : errorString = "<<osg::gluErrorString((GLenum)status)<<std::endl;
|
||||
}
|
||||
|
||||
ImageHeader imageHeader;
|
||||
|
@ -38,52 +38,8 @@
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::Image> > ImageList;
|
||||
|
||||
|
||||
class MyGraphicsContext {
|
||||
public:
|
||||
MyGraphicsContext()
|
||||
{
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = 1;
|
||||
traits->height = 1;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = false;
|
||||
traits->sharedContext = 0;
|
||||
traits->pbuffer = true;
|
||||
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
if (!_gc)
|
||||
{
|
||||
traits->pbuffer = false;
|
||||
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
}
|
||||
|
||||
if (_gc.valid())
|
||||
{
|
||||
_gc->realize();
|
||||
_gc->makeCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
bool valid() const { return _gc.valid() && _gc->isRealized(); }
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::GraphicsContext> _gc;
|
||||
};
|
||||
|
||||
|
||||
osg::StateSet* createState()
|
||||
{
|
||||
MyGraphicsContext gc;
|
||||
if (!gc.valid())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Unable to create the graphics context required to build 3d image."<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read 4 2d images
|
||||
osg::ref_ptr<osg::Image> image_0 = osgDB::readImageFile("Images/lz.rgb");
|
||||
osg::ref_ptr<osg::Image> 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);
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
#include <osg/GL>
|
||||
|
||||
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
|
||||
|
@ -210,7 +210,7 @@ class OSGUTIL_EXPORT Tessellator : public osg::Referenced
|
||||
typedef std::vector<NewVertex> NewVertexList;
|
||||
typedef std::vector<Vec3d*> Vec3dList;
|
||||
|
||||
GLUtesselator* _tobj;
|
||||
osg::GLUtesselator* _tobj;
|
||||
|
||||
PrimList _primList;
|
||||
Vec3dList _coordData;
|
||||
|
@ -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,
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -50,6 +50,9 @@
|
||||
#include <math.h>
|
||||
#include <osg/Notify>
|
||||
|
||||
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
|
@ -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;
|
||||
|
@ -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: "<<msg<<std::endl; }
|
||||
else { OSG_WARN<<"before Glyph::subload(): detected OpenGL error number: "<<errorNo<<std::endl; }
|
||||
}
|
||||
@ -459,7 +459,7 @@ void Glyph::subload() const
|
||||
{
|
||||
|
||||
|
||||
const GLubyte* msg = gluErrorString(errorNo);
|
||||
const GLubyte* msg = osg::gluErrorString(errorNo);
|
||||
if (msg) { OSG_WARN<<"after Glyph::subload() : detected OpenGL error: "<<msg<<std::endl; }
|
||||
else { OSG_WARN<<"after Glyph::subload() : detected OpenGL error number: "<<errorNo<<std::endl; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user