Futher changes to remove unitialized variables/reordering of initialization to

prevent unitialized warnings.
This commit is contained in:
Robert Osfield 2002-07-21 01:29:11 +00:00
parent 48b3be40e9
commit 389dd8adbb
13 changed files with 71 additions and 78 deletions

View File

@ -37,7 +37,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
/** Set the data which to view. The data will typically be
* an osg::Scene but can be any osg::Node type.
*/
void setSceneData(osg::Node* node) { _sceneData = node; _need_compile = true;}
void setSceneData(osg::Node* node) { _sceneData = node; }
/** Get the scene data which to view. The data will typically be
* an osg::Scene but can be any osg::Node type.
*/
@ -291,12 +291,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphRight;
osg::ref_ptr<osgUtil::RenderStage> _renderStageRight;
osg::ref_ptr<osg::FrameStamp> _frameStamp;
bool _need_compile;
osg::Vec4 _backgroundColor;
CullVisitor::ComputeNearFarMode _computeNearFar;

View File

@ -73,25 +73,25 @@ class MyTransformCallback : public osg::NodeCallback{
osg::Geode* createGeometryCube()
{
osg::Geode* geode = new osg::Geode();
osg::Geode* geode = osgNew osg::Geode();
// -------------------------------------------
// Set up a new Geometry which will be our cube
// -------------------------------------------
osg::Geometry* cube = new osg::Geometry();
osg::Geometry* cube = osgNew osg::Geometry();
// set up the primitives
cube->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,0,4));
cube->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,4,4));
cube->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,8,4));
cube->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,12,4));
cube->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,16,4));
cube->addPrimitive(new osg::DrawArrays(osg::Primitive::POLYGON,20,4));
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,0,4));
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,4,4));
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,8,4));
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,12,4));
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,16,4));
cube->addPrimitive(osgNew osg::DrawArrays(osg::Primitive::POLYGON,20,4));
// set up coords.
osg::Vec3Array* coords = new osg::Vec3Array;
osg::Vec3Array* coords = osgNew osg::Vec3Array;
coords->resize(24);
(*coords)[0].set( -1.0000f, 1.0000f, -1.000f );
@ -129,7 +129,7 @@ osg::Geode* createGeometryCube()
// set up the normals.
osg::Vec3Array* cubeNormals = new osg::Vec3Array;
osg::Vec3Array* cubeNormals = osgNew osg::Vec3Array;
cubeNormals->resize(6);
(*cubeNormals)[0].set(0.0f,0.0f,-1.0f);
@ -145,8 +145,8 @@ osg::Geode* createGeometryCube()
// ---------------------------------------
// Set up a StateSet to make the cube red
// ---------------------------------------
osg::StateSet* cubeState = new osg::StateSet();
osg::Material* redMaterial = new osg::Material();
osg::StateSet* cubeState = osgNew osg::StateSet();
osg::Material* redMaterial = osgNew osg::Material();
osg::Vec4 red( 1.0f, 0.0f, 0.0f, 1.0f );
redMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, red );
cubeState->setAttribute( redMaterial );
@ -168,7 +168,7 @@ int main( int argc, char **argv )
for(int i=1;i<argc;++i) commandLine.push_back(argv[i]);
// create the viewer and the model to it.
osgGLUT::Viewer& viewer = *(osgNew osgGLUT::Viewer);
osgGLUT::Viewer viewer;
viewer.setWindowTitle(argv[0]);
@ -177,17 +177,17 @@ int main( int argc, char **argv )
// parameters that have been matched.
viewer.readCommandLine(commandLine);
osg::MatrixTransform* myTransform = new osg::MatrixTransform();
osg::MatrixTransform* myTransform = osgNew osg::MatrixTransform();
myTransform->addChild( createGeometryCube() );
// move node in a circle at 90 degrees a sec.
myTransform->setAppCallback(new MyTransformCallback(myTransform,osg::inDegrees(90.0f)));
myTransform->setAppCallback(osgNew MyTransformCallback(myTransform,osg::inDegrees(90.0f)));
// add model to viewer.
viewer.addViewport( myTransform );
// register trackball maniupulators.
viewer.registerCameraManipulator(new osgGA::TrackballManipulator);
viewer.registerCameraManipulator(osgNew osgGA::TrackballManipulator);
viewer.open();

View File

@ -9,7 +9,8 @@ CullStack::CullStack()
_LODBias = 1.0f;
_smallFeatureCullingPixelSize = 2.0f;
_frustumVolume=-1.0f;
_bbCornerNear = 0;
_bbCornerFar = 7;
}

View File

@ -42,6 +42,9 @@ GeoSet::GeoSet()
_primLengths = (int *)0;
_numcoords = 0;
_numnormals = 0;
_numcolors = 0;
_numtcoords = 0;
_normal_binding = BIND_OFF;
_color_binding = BIND_OFF;
@ -49,6 +52,9 @@ GeoSet::GeoSet()
_fast_path = 1;
_primlength = 0;
_flat_shaded_skip = 0;
}

View File

@ -133,16 +133,15 @@ void ImpostorSprite::accept(PrimitiveFunctor& functor)
// Helper class for managing the reuse of ImpostorSprite resources.
///////////////////////////////////////////////////////////////////////////
ImpostorSpriteManager::ImpostorSpriteManager()
ImpostorSpriteManager::ImpostorSpriteManager():
_first(NULL),
_last(NULL)
{
_texenv = osgNew TexEnv;
_texenv->setMode(TexEnv::REPLACE);
_alphafunc = osgNew osg::AlphaFunc;
_alphafunc->setFunction( AlphaFunc::GREATER, 0.000f );
_first = NULL;
_last = NULL;
}

View File

@ -2,12 +2,12 @@
using namespace osg;
LightSource::LightSource()
LightSource::LightSource():
_value(StateAttribute::ON)
{
// switch off culling of light source nodes by default.
setCullingActive(false);
_dstate = osgNew StateSet;
_value = StateAttribute::ON;
_light = osgNew Light;
}

View File

@ -2,11 +2,11 @@
using namespace osg;
MatrixTransform::MatrixTransform()
MatrixTransform::MatrixTransform():
_inverseDirty(false)
{
_matrix = osgNew Matrix;
_inverse = osgNew Matrix;
_inverseDirty = false;
}
MatrixTransform::MatrixTransform(const MatrixTransform& transform,const CopyOp& copyop):

View File

@ -505,8 +505,8 @@ sMStats m_getMemoryStatistics()
if (numMatching>0 && !allocUnit->printedOutUnintializedInfo)
{
// possible unitialized data?
std::cout<<"possible uninitilized memory numMatching="<<numMatching<<" numNotMatching="<<numNotMatching<<std::endl;
std::cout<<" allocationNumber="<<allocUnit->allocationNumber<<" sourceFile '"<<allocUnit->sourceFile<<"' sourceLine="<<allocUnit->sourceLine<<std::endl;
printf("Warning: possible uninitilized memory numMatching=%d numNotMatching=%d\n",numMatching,numNotMatching);
printf(" allocationNumber=%d sourceFile '%s' sourceLine=%d\n",allocUnit->allocationNumber,allocUnit->sourceFile,allocUnit->sourceLine);
allocUnit->printedOutUnintializedInfo=true;

View File

@ -18,33 +18,28 @@ using namespace osg;
Texture::DeletedTextureObjectCache Texture::s_deletedTextureObjectCache;
Texture::Texture()
Texture::Texture():
_target(GL_TEXTURE_2D),
_wrap_s(CLAMP),
_wrap_t(CLAMP),
_wrap_r(CLAMP),
_min_filter(LINEAR_MIPMAP_LINEAR), // trilinear
_mag_filter(LINEAR),
_texParamtersDirty(true),
_internalFormatMode(USE_IMAGE_DATA_FORMAT),
_internalFormatValue(0),
_borderColor(0.0, 0.0, 0.0, 0.0),
_textureWidth(0),
_textureHeight(0),
_subloadMode(OFF),
_subloadOffsX(0),
_subloadOffsY(0),
_subloadWidth(0),
_subloadHeight(0)
{
_handleList.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
_modifiedTag.resize(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts(),0);
_target = GL_TEXTURE_2D;
_wrap_s = CLAMP;
_wrap_t = CLAMP;
_wrap_r = CLAMP;
_min_filter = LINEAR_MIPMAP_LINEAR; // trilinear
//_min_filter = LINEAR_MIPMAP_NEAREST; // bilinear
//_min_filter = NEAREST_MIPMAP_LINEAR; // OpenGL default
_mag_filter = LINEAR;
_internalFormatMode = USE_IMAGE_DATA_FORMAT;
_internalFormatValue = 0;
_textureWidth = _textureHeight = 0;
_subloadMode = OFF;
_subloadOffsX = _subloadOffsY = 0;
_subloadWidth = _subloadHeight = 0;
_borderColor.set(0.0, 0.0, 0.0, 0.0);//OpenGL default
_texParamtersDirty = true;
}

View File

@ -79,7 +79,7 @@ static GLenum faceTarget[6] =
#endif
TextureCubeMap::TextureCubeMap()
TextureCubeMap::TextureCubeMap():Texture()
{
_target = GL_TEXTURE_CUBE_MAP; // default to ARB extension
}

View File

@ -3,13 +3,15 @@
using namespace osg;
Transform::Transform()
#ifdef USE_DEPRECATED_API
:_deprecated_inverseDirty(false)
#endif
{
_referenceFrame = RELATIVE_TO_PARENTS;
#ifdef USE_DEPRECATED_API
_deprecated_matrix = osgNew Matrix;
_deprecated_inverse = osgNew Matrix;
_deprecated_inverseDirty = false;
#endif
}

View File

@ -147,6 +147,7 @@ void Field::addChar(char c)
{
if (_fieldCacheCapacity<MIN_CACHE_SIZE) _fieldCacheCapacity=MIN_CACHE_SIZE;
_fieldCache = osgNew char[_fieldCacheCapacity];
memset(_fieldCache,0,_fieldCacheCapacity);
_fieldCacheSize = 0;
}
else if (_fieldCacheSize>=_fieldCacheCapacity-1)
@ -155,6 +156,7 @@ void Field::addChar(char c)
while (_fieldCacheSize>=_fieldCacheCapacity-1) _fieldCacheCapacity *= 2;
char* tmp_str = _fieldCache;
_fieldCache = osgNew char[_fieldCacheCapacity];
memset(_fieldCache,0,_fieldCacheCapacity);
strncpy(_fieldCache,tmp_str,_fieldCacheSize);
osgDelete [] tmp_str;

View File

@ -74,29 +74,21 @@ class PrintVisitor : public NodeVisitor
int _step;
};
CullVisitor::CullVisitor()
CullVisitor::CullVisitor():
NodeVisitor(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN),
_currentRenderGraph(NULL),
_currentRenderBin(NULL),
_computeNearFar(COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES),
_computed_znear(FLT_MAX),
_computed_zfar(-FLT_MAX),
_tsm(OBJECT_EYE_POINT_DISTANCE),
_impostorActive(true),
_depthSortImpostorSprites(false),
_impostorPixelErrorThreshold(4.0f),
_numFramesToKeepImpostorSprites(10),
_currentReuseRenderLeafIndex(0)
{
// overide the default node visitor mode.
setTraversalMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
//_tsm = LOOK_VECTOR_DISTANCE;
_tsm = OBJECT_EYE_POINT_DISTANCE;
_computeNearFar = COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
_computed_znear = FLT_MAX;
_computed_zfar = -FLT_MAX;
_impostorActive = true;
_depthSortImpostorSprites = false;
_impostorPixelErrorThreshold = 4.0f;
_numFramesToKeepImpostorSprites = 10;
_impostorSpriteManager = osgNew ImpostorSpriteManager;
_currentRenderGraph = NULL;
_currentRenderBin = NULL;
_currentReuseRenderLeafIndex=0;
}