void QuadParticleSystemDrawer::fill(DrawableStatsAttachment *pStat, ParticleSystemUnrecPtr System, const MFUInt32& Sort) { if(pStat == NULL) { FINFO(("QuadParticleSystemDrawer::fill(DrawableStatsAttachment *, ParticleSystemUnrecPtr , const MFUInt32& ): " "No attachment given.\n")); return; } if(System == NULL) { FINFO(("QuadParticleSystemDrawer::fill(DrawableStatsAttachment *, ParticleSystemUnrecPtr , const MFUInt32& ): " "Particle System is NULL.\n")); return; } UInt32 NumParticles; if(Sort.size() > 0) { NumParticles = Sort.size(); } else { NumParticles = System->getNumParticles(); } pStat->setVertices(4*NumParticles); pStat->setTriangles(2*NumParticles); pStat->setValid(true); }
void RenderAction::dropFunctor(DrawEnv::DrawFunctor &func, Material *pMat, bool bIgnoreOverrides) { if(pMat == NULL) return; PrimeMaterial *pPrimeMat = pMat->finalize(_oCurrentRenderProp, _pWindow); if(pPrimeMat == NULL) return; UInt32 uiNPasses = pPrimeMat->getNPasses(); for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass) { State *st = pPrimeMat->getState(uiPass); if(st != NULL) { this->dropFunctor(func, st, pPrimeMat->getSortKey() + uiPass, bIgnoreOverrides ); } else { #ifndef WIN32 FINFO(("%s: hit material with NULL state!\n", __func__)); #else FINFO(("Hit material with NULL state!\n")); #endif } } }
void FieldContainer::subWeakReference(void) { #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT FINFO(("FieldContainer::subWeakReference [%p] [%d] [%s] START - [%d %d]\n", this, this->getId(), this->getType().getCName(), this->_iRefCount, this->_iWeakRefCount)); #endif osgSpinLock(&_uiContainerId, SpinLockBit); RefCountStore tmpWeakRefCnt = osgAtomicExchangeAndAdd(&_iWeakRefCount, -1); #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT FINFO(("FieldContainer::subWeakReference [%p] [%d] [%s] STOP - [%d %d]\n", this, this->getId(), this->getType().getCName(), this->_iRefCount, this->_iWeakRefCount)); #endif if((0x0000 != (_uiContainerId & DeadContainerBit)) && tmpWeakRefCnt <= 1) { osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); this->resolveLinks(); #ifdef OSG_MT_CPTR_ASPECT this->onDestroyAspect(Inherited::getId(), Thread::getCurrentAspect()); if(_pAspectStore->getRefCount() == 1) { this->deregister(Inherited::getId()); this->onDestroy (Inherited::getId()); } _pAspectStore->removePtrForAspect(Thread::getCurrentAspect()); OSG::subRef(_pAspectStore); _pAspectStore = NULL; #else this->deregister (Inherited::getId() ); this->onDestroyAspect(Inherited::getId(), 0); this->onDestroy (Inherited::getId() ); #endif delete this; } else { osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); } }
bool ThreadManager::init(void) { bool returnValue = true; FDEBUG(("OSGThreadManager init\n")) #if defined(OSG_USE_SPROC) usconfig(CONF_AUTOGROW, 1); usconfig(CONF_INITUSERS, 20); usconfig(CONF_INITSIZE, 10 * 1048576); usconfig(CONF_CHMOD, 0666); _pArena = usinit("/dev/zero"); if(_pArena == NULL) { SFATAL << "OSGTM : could not initialize arena " << errno << std::endl; returnValue = false; } else { SINFO << "OSGTM : got arena " << _pArena << std::endl; } #endif _storePLock = _sLockStore.getMPField("OSGTMStoreLock", "OSGLock", true); if(_storePLock == NULL) { SFATAL << "OSGTM : could not get table lock" << std::endl; returnValue = false; } else { SINFO << "OSGTM : got table lock " << _storePLock << std::endl; } if(_szAppThreadType == NULL) { FINFO(("OSGTM : create -OSGBaseThread- app thread\n")); _pAppThread = getThread("OSGAppThread", true, "OSGBaseThread"); } else { FINFO(("OSGTM : create -%s- app thread\n", _szAppThreadType)); _pAppThread = getThread("OSGAppThread", true, _szAppThreadType); } FFASSERT((_pAppThread != NULL), 1, ("OSGTM : could not get application thread \n"););
/* for parsing: loop through all the available symbols to add them ** to the parser. linfoused indicates which (latex)maptables are already used ** and fonts using that table are skipped. Undefined fonts are also ** skipped. (otherwise it would result in 256*256*2=131072 loops, now the ** maximum is 256*30*2=15360 loops, but usually much less (standard 2048). */ char *char_latex_next(Char *data, int *math) { #ifdef MATH_OLD_WAY int i,j,h,m,id; char *lh; if (!*data) for (i=0; i<30; linfoused[i++]=0); if (!*math) (*math)++; else { *math=0; (*data)++; } i=Char2Font(*data); j=Char2ASCII(*data); h = FINFO(grnr, i).lnr; lh=linfo[h].code; m=*math; while (1) { /* end if i>=256 */ if (!h || linfoused[h]) { /* font is not available or uses same coding: skip it */ i++; j=0;m=0; if (i==256) break; h = FINFO(grnr, i).lnr; lh=linfo[h].code; } else if (((m && aig(id=linfo[h].math[j])) || (!m && aig(id=linfo[h].normal[j]))) && ((lh[id]!=j) || (lh[id+1]!=0))) { /* found something of interest */ *data=(Char)Font2Char(i,j); *math=m; return lh+id; } else { /* increase (i,j,m) */ if (!m) { /* increase math tag (m) */ m=1; } else { m=0; if (j<255) { /* increase character position (j) */ j++; } else { /* increase font position (i) */ j=0; linfoused[h]=1; i++; if (i==256) break; h = FINFO(grnr,i).lnr; lh=linfo[h].code; } } } } #endif *data=0; *math=0; return 0; }
void OSBGeometryElement::read(const std::string &typeName) { OSG_OSB_LOG(("OSBGeometryElement::read: [%s]\n", typeName.c_str())); BinaryReadHandler *rh = editRoot()->getReadHandler(); rh->getValue(_version); OSG_OSB_LOG(("OSBGeometryElement::read: version: [%u]\n", _version)); if(_version >= OSGOSBHeaderVersion200) { if(_version > OSGOSBHeaderVersion200) { FINFO(("OSBGeometryElement::read: " "Unknown version, trying to read as latest.\n")); } setContainer(GeometryUnrecPtr(Geometry::create())); readFields("", ""); } else if(_version >= OSGOSBHeaderVersion100) { readV100(); } }
void SkeletonDrawable::fill(DrawableStatsAttachment *pStat) { if(pStat == NULL) { FINFO(("SkeletonDrawable::fill(DrawableStatsAttachment *): " "No attachment given.\n")); return; } if(getSkeleton() == NULL) { FWARNING(("SkeletonDrawable::fill:: no skeleton!\n"));; return; } UInt32 NumLines(0); if(getDrawPose()) { NumLines += getSkeleton()->getNumJoints()-1; } if(getDrawBindPose()) { NumLines += getSkeleton()->getNumJoints()-1; } pStat->setLines (NumLines); }
NodeTransitPtr VRMLFile::scanStream(std::istream &is) { startTime = getSystemTime(); _pSceneRootNode = NULL; _pCurrentFC = NULL; _nameFCMap.clear(); #ifdef OSG_DEBUG_VRML VRMLNodeHelper::resetIndent(); #endif if(is) { Inherited::scanStream(is); } SceneFileHandler::the()->updateReadProgress(100); NodeTransitPtr returnValue(_pSceneRootNode); _pSceneRootNode = NULL; _pCurrentFC = NULL; FINFO(("Full Time : %lf | Use Time %lf\n", getSystemTime() - startTime, useTime)); return returnValue; }
Action::ResultE MaterialDrawable::renderActionEnterHandler(Action *action) { RenderAction *a = dynamic_cast<RenderAction *>(action); Material *m = a->getMaterial(); PrimeMaterial *pPrimeMat = NULL; if(m == NULL) { if(this->getMaterial() != NULL) { pPrimeMat = this->getMaterial()->finalize(a->getRenderProperties(), a->getWindow() ); } } else { pPrimeMat = m->finalize(a->getRenderProperties(), a->getWindow ()); } if(pPrimeMat == NULL) { pPrimeMat = getDefaultMaterial(); FNOTICE(("MaterialDrawable::render: no Material!?!\n")); } UInt32 uiNPasses = pPrimeMat->getNPasses(); for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass) { State *st = pPrimeMat->getState(uiPass); if(st != NULL) { a->dropFunctor(_drawFunc, st, pPrimeMat->getSortKey() + uiPass); } else { FINFO(("%s: Material %p has NULL state for pass %d\n", OSG_FUNCNAME_MACRO, pPrimeMat, uiPass)); } } if(a->pushVisibility()) { if(a->selectVisibles() == 0) { a->popVisibility(); return Action::Skip; } } return Action::Continue; }
bool Node::unlinkChild (FieldContainer * const pChild, UInt16 const childFieldId ) { if(childFieldId == ChildrenFieldId) { FINFO(("Node::unlinkChild: this [%p] [%u] pChild [%p] [%u]\n", this, this->getId(), pChild, pChild != NULL ? pChild->getId() : 0)); Node *pTypedChild = dynamic_cast<Node *>(pChild); if(pTypedChild != NULL) { Int32 iChildIdx = _mfChildren.findIndex(pTypedChild); if(iChildIdx != -1) { editMField(ParentFieldMask, _mfChildren); _mfChildren.erase(iChildIdx); return true; } FWARNING(("Node::unlinkChild: Child <-> Parent link " "inconsistent.\n")); return false; } return false; } if(childFieldId == CoreFieldId) { NodeCore *pTypedChild = dynamic_cast<NodeCore *>(pChild); if(pTypedChild != NULL) { if(pTypedChild == getCore()) { editSField(CoreFieldMask); _sfCore.setValue(NULL); return true; } FWARNING(("Node::unlinkChild: Child <-> Parent link " "inconsistent.\n")); return false; } return false; } return Inherited::unlinkChild(pChild, childFieldId); }
void CPUSkinningAlgorithm::renderGeometry( RenderAction *ract, SkinnedGeometry *skinGeo, CPUSkinningDataAttachment *data ) { Material *pMat = ract->getMaterial(); PrimeMaterial *pPrimeMat = NULL; if(pMat == NULL) { if(skinGeo->getMaterial() != NULL) { pPrimeMat = skinGeo->getMaterial()->finalize( ract->getRenderProperties(), ract->getCurrentOverrides(), ract->getWindow()); } } else { pPrimeMat = pMat->finalize( ract->getRenderProperties(), ract->getCurrentOverrides(), ract->getWindow()); } if(pPrimeMat == NULL) { SNOTICE << "CPUSkinningAlgorithm::preDrawPrimitives: No Material " << "for SkinnedGeometry " << skinGeo << std::endl; pPrimeMat = getDefaultMaterial(); } DrawEnv::DrawFunctor drawFunc = boost::bind( &CPUSkinningAlgorithm::drawPrimitives, this, skinGeo, data, _1); UInt32 uiNPasses = pPrimeMat->getNPasses(); for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass) { State *st = pPrimeMat->getState(uiPass); if(st != NULL) { ract->dropFunctor(drawFunc, st, pPrimeMat->getSortKey() + uiPass); } else { FINFO(("%s: Material %p has NULL state for pass %d\n", OSG_FUNCNAME_MACRO, pPrimeMat, uiPass)); } } }
void ParticleSystemCore::fill(DrawableStatsAttachment *pStat) { if(getDrawer() == NULL) { FINFO(("ParticleSystemCore::fill(DrawableStatsAttachment *): " "No Drawer Attached.\n")); return; } if(getSystem() == NULL) { FINFO(("ParticleSystemCore::fill(DrawableStatsAttachment *): " "No System Attached.\n")); return; } getDrawer()->fill(pStat, getSystem(), *getMFSort()); }
void Node::resolveLinks(void) { FINFO(("Node::resolveLinks [%p] [%u]\n", this, this->getId())); Inherited::resolveLinks(); _sfCore.setValue(NULL); _mfChildren.clear(); }
void MaterialPool::sync(void) { // should be safe as the materials interface is protected. if(_mfMaterials.size() == _mats.size()) { FINFO(("MaterialPool::sync : %u materials already synced, nothing to do.\n", _mfMaterials.size())); return; } MFMaterialPtr::iterator matIt = _mfMaterials.begin(); MFMaterialPtr::const_iterator endMaterials = _mfMaterials.end (); while(matIt != endMaterials) { // this is already done in the osb loader! //addRefCP(*matIt); _mats.insert(*matIt); ++matIt; } FINFO(("MaterialPool::sync : synced %u materials\n", _mfMaterials.size())); }
/*! Constructor used for the singleton object */ EXRImageFileType::EXRImageFileType(const Char8 *mimeType, const Char8 *suffixArray[], UInt16 suffixByteCount, UInt32 flags ) : Inherited(mimeType, suffixArray, suffixByteCount, flags ) { FINFO(( "EXRImageFileType: %s\n", mimeType)); // TODO; needed for initialization of the library's global variables //Imf::staticInitialize(); }
/// Checks if FBO status is ok bool PCSSShadowMap::checkFrameBufferStatus(Window *win) { GLenum errCode, status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); switch(status) { case GL_FRAMEBUFFER_COMPLETE_EXT: FINFO(("%x: framebuffer complete!\n", status)); break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: FWARNING(("%x: framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n", status)); // choose different formats return false; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: FWARNING(("%x: framebuffer INCOMPLETE_ATTACHMENT\n", status)); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: FWARNING(("%x: framebuffer FRAMEBUFFER_MISSING_ATTACHMENT\n", status)); break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: FWARNING(("%x: framebuffer FRAMEBUFFER_DIMENSIONS\n", status)); break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: FWARNING(("%x: framebuffer INCOMPLETE_FORMATS\n", status)); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: FWARNING(("%x: framebuffer INCOMPLETE_DRAW_BUFFER\n", status)); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: FWARNING(("%x: framebuffer INCOMPLETE_READ_BUFFER\n", status)); break; case GL_FRAMEBUFFER_BINDING_EXT: FWARNING(("%x: framebuffer BINDING_EXT\n", status)); break; default: return false; } if((errCode = glGetError()) != GL_NO_ERROR) { const GLubyte *errString = gluErrorString(errCode); FWARNING(("OpenGL Error: %s!\n", errString)); return false; } return true; }
void MaterialPool::onDestroy(void) { // if we're in shutdown this is the prototype ... if(OSG::GlobalSystemState == OSG::Shutdown) return; MFMaterialPtr::iterator matIt = _mfMaterials.begin(); MFMaterialPtr::const_iterator endMaterials = _mfMaterials.end (); FINFO(("MaterialPool::onDestroy : subrefing %u materials\n", _mfMaterials.size())); while(matIt != endMaterials) { subRefCP(*matIt); ++matIt; } }
void OSBGeometryElement::postMap(void) { OSG_OSB_LOG(("OSBGeometryElement::postMap:\n")); if(_version >= OSGOSBHeaderVersion200) { if(_version > OSGOSBHeaderVersion200) { FINFO(("OSBGeometryElement::postMap: " "Unknown version, trying to process as latest.\n")); } postMapV200(); } else if(_version >= OSGOSBHeaderVersion100) { // postMap v1.0 Geometry - nothing to do. } }
/*! Returns the max buffer size needed to store the Image (Head + mimeType specific data block) */ UInt64 ImageFileType::maxBufferSize(const ImagePtr &image) { std::string value; unsigned long size, attachmentSize; unsigned long imageSize = image->getSize(), headSize = sizeof(Head); std::map<std::string, std::string>::const_iterator aI; attachmentSize = 0; // get attachment size /* ImageGenericAttPtr att=ImageGenericAttPtr::dcast( const_cast<Image*>(image.getCPtr())->findAttachment( ImageGenericAtt::getClassType().getGroupId())); if(att != NullFC) { for(i = 0; i < (att->getType().getNumFieldDescs()-1); ++i) { FieldDescription *fieldDesc=att->getType().getFieldDescription(i); Field *field=att->getField(i); if (field && fieldDesc) { field->getValueByStr(value); attachmentSize += strlen( fieldDesc->getName().str() ) + 1; attachmentSize += value.length() + 1; } else { FFATAL (("Invalid Attachment in ImageFileType::maxBufferSize()\n")); } } } */ size = headSize + imageSize + attachmentSize; FINFO (( "ImageFileType::maxBufferSize(): %lu (%lu/%lu/%lu)\n", size, headSize, imageSize, attachmentSize )); return size; }
SharedObject::SharedObject(const TChar *szName) : Inherited( ), _szName ( ), _pHandle (NULL ), _type (Invalid) { if(szName == NULL) { _szName.assign(_szApplicationObjectName); _type = Application; } else { _szName.assign(szName); _type = SharedLibrary; } FINFO(("construct SharedObject %s\n", _szName.c_str())); }
void Geometry::fill(DrawableStatsAttachment *pStat) { if(pStat == NULL) { FINFO(("Geometry::fill(DrawableStatsAttachment *): " "No attachment given.\n")); return; } // Att Bytes UInt32 storedAttBytes = 0; UInt32 attBytesPerVertex = 0; for(UInt16 i = 0; i < Geometry::MaxAttribs; ++i) { if(this->getProperty(i) == NULL) continue; attBytesPerVertex += this->getProperty(i)->getFormatSize() * this->getProperty(i)->getDimension(); storedAttBytes += this->getProperty(i)->getFormatSize() * this->getProperty(i)->getDimension() * this->getProperty(i)->size(); } GeoIntegralProperty *geoTypePtr = this->getTypes(); GeoIntegralProperty *lensPtr = this->getLengths(); UInt32 lN, tN, len, type; lN = (lensPtr == NULL) ? 0 : lensPtr ->getSize(); tN = (geoTypePtr == NULL) ? 0 : geoTypePtr->getSize(); if((tN == 0) || (lN != 0 && tN != lN) || (lN == 0 && tN != 1)) { FINFO(("GeoStatsAttachment::calc: " "Lengths and Types information mismatch.\n")); return; } UInt32 triangle = 0, line = 0, point = 0, vertices = 0, procAttBytes = 0; for(UInt32 i = 0; i < tN; ++i) { geoTypePtr->getValue(type, i); if(lN != 0) { lensPtr->getValue(len, i); } else { GeoVectorProperty *pos = this->getPositions(); if(pos == NULL) { FINFO(("GeoStatsAttachment::calc: No Positions!\n")); return; } len = pos->size(); } vertices += len; procAttBytes += len * attBytesPerVertex; switch(type) { case GL_POINTS: point += len; break; case GL_LINES: line += len / 2; break; case GL_LINE_LOOP: line += len; break; case GL_LINE_STRIP: line += len - 1; break; case GL_TRIANGLES: triangle += len / 3; break; case GL_TRIANGLE_STRIP: triangle += len - 2; break; case GL_TRIANGLE_FAN: triangle += len - 2; break; case GL_QUADS: triangle += len / 2; break; case GL_QUAD_STRIP: triangle += len - 2; break; case GL_POLYGON: triangle += len - 2; break; default: FWARNING(("GeoStatsAttachment::calc: Invalid geoType: %d\n", type)); break; } } pStat->setVertices(vertices); pStat->setPoints(point); pStat->setLines(line); pStat->setTriangles(triangle); pStat->setStoredAttributeBytes(storedAttBytes); pStat->setProcessedAttributeBytes(procAttBytes); pStat->setValid(true); }
void TreeRenderer::initialize(Window *win) { if(!_initDone) { // without this the registered extensions are not valid yet! win->frameInit(); //check support for ShadowExtension if(!win->hasExtension(_depth_texture_extension)) { SWARNING << "No ARB_depth_texture-Extension available! All shadow modes disabled." << endLog; _useShadowExt = false; } else if(!win->hasExtension(_shadow_extension)) { SWARNING << "No ARB_shadow-Extension available! All shadow modes disabled." << endLog; _useShadowExt = false; } //check support for framebuffer objects _useFBO = _shadowVP->getFboOn(); if(!win->hasExtension("GL_EXT_framebuffer_object")) _useFBO = false; if(_useFBO) { FNOTICE(("framebuffer objects supported.\n")); } else { FNOTICE( ( "framebuffer objects not supported, try new video drivers. Some shadow modes will be disabled.\n")); } //check support for non-power-of-two textures _useNPOTTextures = true; if(!win->hasExtension("GL_ARB_texture_non_power_of_two")) _useNPOTTextures = false; if(_useNPOTTextures) { FNOTICE(("texture_non_power_of_two supported.\n")); } else { FNOTICE(("texture_non_power_of_two not supported by hardware.\n")); } //check if GLSL is available _useGLSL = true; if(!win->hasExtension("GL_ARB_shading_language_100") || !win->hasExtension("GL_ARB_fragment_shader") || !win->hasExtension("GL_ARB_vertex_shader") || !win->hasExtension("GL_ARB_shader_objects")) { _useGLSL = false; } if(!_useGLSL) { FNOTICE( ( "GLSL not supported, some shadow modes and real point lights will be disabled.\n")); } else { FNOTICE(("GLSL supported.\n")); } //check for Shader Model 3.0 _useShaderModel3 = false; if(win->hasExtension("GL_NV_vertex_program3") || win->hasExtension("GL_ATI_shader_texture_lod")) _useShaderModel3 = true; if(!_useShaderModel3) { FNOTICE(("Shader Model 3.0 NOT supported.\n")); } else { FNOTICE(("Shader Model 3.0 supported.\n")); } //No NPOTTextures supportet if FBOs are disabled if(!_useFBO) _useNPOTTextures = false; if(_useFBO) { GLenum errCode; bool FBOerror = false; glBindFramebufferEXT = reinterpret_cast<OSGGLBINDFRAMEBUFFEREXTPROC>( win->getFunction(_funcBindFramebuffer)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glBindRenderbufferEXT = reinterpret_cast<OSGGLBINDRENDERBUFFEREXTPROC>( win->getFunction(_funcBindRenderbuffer)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glCheckFramebufferStatusEXT = reinterpret_cast<OSGGLCHECKFRAMEBUFFERSTATUSEXTPROC>( win->getFunction(_funcCheckFramebufferStatus)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glDeleteFramebuffersEXT = reinterpret_cast<OSGGLDELETEFRAMEBUFFERSEXTPROC>( win->getFunction(_funcDeleteFramebuffers)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glDeleteRenderbuffersEXT = reinterpret_cast<OSGGLDELETERENDERBUFFERSEXTPROC>( win->getFunction(_funcDeleteRenderbuffers)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glFramebufferRenderbufferEXT = reinterpret_cast<OSGGLFRAMEBUFFERRENDERBUFFEREXTPROC>( win->getFunction(_funcFramebufferRenderbuffer)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glFramebufferTexture1DEXT = reinterpret_cast<OSGGLFRAMEBUFFERTEXTURE1DEXTPROC>( win->getFunction(_funcFramebufferTexture1D)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glFramebufferTexture2DEXT = reinterpret_cast<OSGGLFRAMEBUFFERTEXTURE2DEXTPROC>( win->getFunction(_funcFramebufferTexture2D)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glFramebufferTexture3DEXT = reinterpret_cast<OSGGLFRAMEBUFFERTEXTURE3DEXTPROC>( win->getFunction(_funcFramebufferTexture3D)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glGenFramebuffersEXT = reinterpret_cast<OSGGLGENFRAMEBUFFERSEXTPROC>( win->getFunction(_funcGenFramebuffers)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glGenRenderbuffersEXT = reinterpret_cast<OSGGLGENRENDERBUFFERSEXTPROC>( win->getFunction(_funcGenRenderbuffers)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glGenerateMipmapEXT = reinterpret_cast<OSGGLGENERATEMIPMAPEXTPROC>( win->getFunction(_funcGenerateMipmap)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glGetFramebufferAttachmentParameterivEXT = reinterpret_cast< OSGGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC>( win->getFunction( _funcGetFramebufferAttachmentParameteriv)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glGetRenderbufferParameterivEXT = reinterpret_cast<OSGGLGETRENDERBUFFERPARAMETERIVEXTPROC>( win->getFunction(_funcGetRenderbufferParameteriv)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glIsFramebufferEXT = reinterpret_cast<OSGGLISFRAMEBUFFEREXTPROC>( win->getFunction(_funcIsFramebuffer)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glIsRenderbufferEXT = reinterpret_cast<OSGGLISRENDERBUFFEREXTPROC>( win->getFunction(_funcIsRenderbuffer)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glRenderbufferStorageEXT = reinterpret_cast<OSGGLRENDERBUFFERSTORAGEEXTPROC>( win->getFunction(_funcRenderbufferStorage)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; glDrawBuffersARB = reinterpret_cast<OSGGLDRAWBUFFERSARBPROC>( win->getFunction(_funcDrawBuffers)); if((errCode = glGetError()) != GL_NO_ERROR) FBOerror = true; GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if(FBOerror) { FNOTICE( ( "Needed FBO functions could not be initialized (error code %d), FBOs disabled. Try new video drivers!\n", errCode)); _useFBO = false; } switch(status) { case GL_FRAMEBUFFER_COMPLETE_EXT: FINFO(("%x: framebuffer complete!\n", status)); break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: FWARNING( ("%x: framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n", status)); break; default: break; } } _initDone = true; } }
bool DATImageFileType::read( Image *image, const Char8 *fileName) { bool retCode = false; std::ifstream inDat(fileName), inVolS; std::istream *inVol; std::string keyStr, objectFileName; const UInt32 lineBufferSize = 1024; Char8 *value, *keySepPos, lineBuffer[lineBufferSize]; const Char8 keySep = ':'; int fileOffset, keyL, valueL; std::map<std::string, KeyType>::iterator keyI; std::map<std::string, FormatDesc>::iterator formatI; KeyType key; Image::Type formatType; UInt32 channel = 1; UInt32 res[3]; UInt32 dataSize = 0; Image::PixelFormat pixelFormat = Image::OSG_L_PF; char *dataBuffer = 0; bool needConversion = false; // default endian type is big endian bool big_endian = true; res[0] = res[1] = res[2] = 0; fileOffset = 0; formatType = Image::OSG_INVALID_IMAGEDATATYPE; dataSize = 0; dataBuffer = 0; initTypeMap(); // read the data file for(lineBuffer[0] = 0; inDat.getline(lineBuffer, lineBufferSize); lineBuffer[0] = 0) { if((keySepPos = strchr(lineBuffer,keySep))) { keyL = keySepPos - lineBuffer; keyStr.assign( lineBuffer, keyL ); keyI = _keyStrMap.find(keyStr); key = ((keyI == _keyStrMap.end()) ? UNKNOWN_KT : keyI->second); value = keySepPos + 1; while (value && isspace(*value)) value++; valueL = int(strlen(value)); while (isspace(value[valueL-1])) value[--valueL] = 0; switch (key) { case OBJECT_FILE_NAME_KT: objectFileName = value; image->setAttachmentField ( keyStr, value ); break; case CHANNEL_KT: sscanf ( value, "%u", &(channel) ); image->setAttachmentField ( keyStr, value ); break; case RESOLUTION_KT: sscanf ( value, "%u %u %u", &(res[0]), &(res[1]), &(res[2])); image->setAttachmentField ( keyStr, value ); break; case FORMAT_KT: formatI = _formatStrMap.find(value); if (formatI != _formatStrMap.end()) { formatType = formatI->second.type; } else { formatType = Image::OSG_INVALID_IMAGEDATATYPE; } image->setAttachmentField ( keyStr, value ); break; case ENDIAN_KT: if(!strcmp(value, "LITTLE")) big_endian = false; image->setAttachmentField ( keyStr, value ); break; case FILE_OFFSET_KT: sscanf ( value, "%d", &fileOffset ); image->setAttachmentField ( keyStr, value ); break; case UNKNOWN_KT: FNOTICE (( "Uknown DAT file key: >%s<\n", keyStr.c_str() )); image->setAttachmentField ( keyStr, value ); break; case SLICE_THICKNESS_KT: default: image->setAttachmentField ( keyStr, value ); break; } } else { FINFO (("Skip DAT line\n")); } } // set pixelformat switch (channel) { case 4: pixelFormat = Image::OSG_RGBA_PF; break; case 3: pixelFormat = Image::OSG_RGB_PF; break; case 2: pixelFormat = Image::OSG_LA_PF; break; default: pixelFormat = Image::OSG_L_PF; break; } // check the setting and read the raw vol data if (objectFileName.empty() == false) { if((res[0] > 0) && (res[1] > 0) && (res[2] > 0)) { if(formatType != Image::OSG_INVALID_IMAGEDATATYPE) { inVolS.open(objectFileName.c_str(), std::ios::in | std::ios::binary); if (inVolS.fail() && ImageFileHandler::the()->getPathHandler()) { // Try to find the file in the search path inVolS.clear(); // reset the error state PathHandler *ph = ImageFileHandler::the()->getPathHandler(); inVolS.open(ph->findFile(objectFileName.c_str()).c_str(), std::ios::in | std::ios::binary ); } if(inVolS.fail()) { // Maybe compressed and name not changed? std::string gzname = objectFileName + ".gz"; inVolS.clear(); // reset the error state inVolS.open(gzname.c_str(), std::ios::in | std::ios::binary ); if(inVolS.fail() && ImageFileHandler::the()->getPathHandler()) { // Try to find the file in the search path inVolS.clear(); // reset the error state PathHandler *ph = ImageFileHandler::the()->getPathHandler(); inVolS.open(ph->findFile(gzname.c_str()).c_str(), std::ios::in | std::ios::binary ); } } if(inVolS.good()) { #ifdef OSG_WITH_ZLIB zip_istream *unzipper = NULL; #endif image->set(pixelFormat, res[0], res[1], res[2], 1, 1, 0.0, 0, formatType); image->clear(); dataSize = image->getSize(); UInt32 fileDataSize = dataSize; if(isGZip(inVolS)) { #ifdef OSG_WITH_ZLIB unzipper = new zip_istream(inVolS); inVol = unzipper; #else SFATAL << "Compressed streams are not supported! " << "Configure with --enable-png " << "--with-png=DIR options." << std::endl; #endif } else { inVol = &inVolS; // get length of the stream. inVol->seekg(0, std::ios::end); UInt64 length = inVol->tellg(); inVol->seekg(0, std::ios::beg); if(length < dataSize - fileOffset) { // correct dataSize. fileDataSize = length; FWARNING (( "RAW file length to small!\n" )); } else if(length > dataSize - fileOffset) { FWARNING (( "RAW file length to big!\n" )); } } if(needConversion) { dataBuffer = new char [ dataSize ]; } else { dataBuffer = reinterpret_cast<char *>(image->editData()); } if(fileOffset != 0) inVol->ignore (fileOffset); inVol->read ( dataBuffer, fileDataSize ); #ifdef OSG_WITH_ZLIB if(unzipper != NULL) delete unzipper; #endif } else { FWARNING (( "Can not open %s image data\n", objectFileName.c_str() )); } } else { FWARNING (( "Invalid/Missing DAT Format\n" )); } } else { FWARNING (( "Invalid/Missing DAT Resolution\n" )); } } else { FWARNING (( "Invalid/Missing DAT ObjectFileName\n" )); } // check/reformat vol data if (dataSize && dataBuffer) { // check host endian type UInt16 word = 0x0001; UInt8 *byte = reinterpret_cast<UInt8 *>(&word); bool host_big_endian = byte[0] ? false : true; if(big_endian != host_big_endian) image->swapDataEndian(); if (needConversion) { FLOG (("DAT-Data convert not impl. yet !\n")); { switch (formatType) { case Image::OSG_UINT8_IMAGEDATA: break; case Image::OSG_UINT16_IMAGEDATA: break; case Image::OSG_UINT32_IMAGEDATA: break; case Image::OSG_FLOAT32_IMAGEDATA: break; default: ; } } } else { retCode = true; } } /* TODO std::ifstream in(fileName); Head head; void *headData = (void*)(&head); unsigned dataSize, headSize = sizeof(Head); if ( in && in.read(static_cast<char *>(headData), headSize) && head.netToHost() && image.set ( Image::PixelFormat(head.pixelFormat), head.width, head.height, head.depth, head.mipmapCount, head.frameCount, float(head.frameDelay) / 1000.0) && (dataSize = image.getSize()) && in.read((char *)(image.getData()), dataSize )) retCode = true; else retCode = false; */ return retCode; }
/*! Tries to fill the image object with the data read from the given input stream. Returns true on success. */ bool NRRDImageFileType::read(ImagePtr &image, std::istream &in, const std::string &mimetype) { bool retCode = false; bool isSigned = false, littleEndian = true, rawEncoding = true; int width = 1, height = 1, depth = 1, dimension = 3, channel = 1; HeadElem dataType = INVALID_HE; unsigned i, n, m; UChar8 *data = 0; std::string line; std::vector < std::string > tokenVec; bool inHead; osg::Image::PixelFormat pixelFormat; osg::Image::Type imageType; if (in.good()) { for (inHead = true; inHead;) { std::getline(in,line); tokenVec.clear(); if ((n = stringTokenizer (line, tokenVec, ": \n"))) { switch (mapElem(tokenVec[0])){ case TYPE_HE: switch (n) { case 2: dataType = mapElem(tokenVec[1]); break; case 3: isSigned = (mapElem(tokenVec[1]) == SIGNED_HE); dataType = mapElem(tokenVec[2]); break; default: FFATAL (( "Invalid %s/%d in NRRD header\n", tokenVec[0].c_str(), n )); break; } break; case DIMENSION_HE: switch (n) { case 2: dimension = atoi(tokenVec[1].c_str()); break; default: FFATAL (( "Invalid %s/%d in NRRD header\n", tokenVec[0].c_str(), n )); break; } break; case SIZES_HE: switch (n) { case 5: channel = atoi(tokenVec[1].c_str()); width = atoi(tokenVec[2].c_str()); height = atoi(tokenVec[3].c_str()); depth = atoi(tokenVec[4].c_str()); break; case 4: width = atoi(tokenVec[1].c_str()); height = atoi(tokenVec[2].c_str()); depth = atoi(tokenVec[3].c_str()); break; case 3: width = atoi(tokenVec[1].c_str()); height = atoi(tokenVec[2].c_str()); depth = 1; break; case 2: width = atoi(tokenVec[1].c_str()); height = 1; depth = 1; break; default: FFATAL (( "Invalid %s/%d in NRRD header\n", tokenVec[0].c_str(), n )); break; } if ((n <= 4) && (width <= 4)) { channel = width; width = height; height = depth; depth = 1; } break; case ENDIAN_HE: switch (n) { case 2: littleEndian = (mapElem(tokenVec[1]) == LITTLE_HE); break; default: FFATAL (( "Invalid %s/%d in NRRD header\n", tokenVec[0].c_str(), n )); break; } break; case ENCODING_HE: switch (n) { case 2: rawEncoding = (mapElem(tokenVec[1]) == RAW_HE); break; default: FFATAL (( "Invalid %s/%d in NRRD header\n", tokenVec[0].c_str(), n )); break; } break; default: break; } } else inHead = false; } switch (dataType) { case SHORT_HE: imageType = osg::Image::OSG_UINT16_IMAGEDATA; break; default: imageType = osg::Image::OSG_UINT8_IMAGEDATA; break; } switch (channel) { case 4: pixelFormat = osg::Image::OSG_RGBA_PF; break; case 3: pixelFormat = osg::Image::OSG_RGB_PF; break; case 2: pixelFormat = osg::Image::OSG_LA_PF; break; default: pixelFormat = osg::Image::OSG_L_PF; break; } if (isSigned) { FFATAL (( "Read signed data not supported\n" )); } FINFO(("NRRDImageFileType::read: got %d D %s endian %s data.\n", dimension, littleEndian?"little":"big", rawEncoding?"raw":"cooked")); image->set ( pixelFormat, width, height, depth, 1, 1, 0.0, 0, imageType ); n = image->getSize(); data = image->editData(); in.read (reinterpret_cast<char*>(data), n); retCode = true; } return retCode; }
/*! Reads a SFFieldContainerAttachmentPtrMap from the stream. It has the given \a fieldId in the container it belongs to and size \a fieldSize. \param[in] fieldId Id of the field in the container it belongs to. \param[in] fieldSize Size in byte of the field. \return Iterator that points to the PtrFieldInfo structure that was created for this field. */ OSBCommonElement::PtrFieldListIt OSBCommonElement::readAttachmentMapField( const UInt32 fieldId, const UInt32 fieldSize) { OSG_OSB_LOG(("OSBCommonElement::readAttachmentMapField: " "fieldId: [%u]\n", fieldId)); bool hasBindingInfo = false; UInt32 ptrId; UInt32 numElements; OSBRootElement *root = editRoot(); BinaryReadHandler *rh = editRoot()->getReadHandler(); root->editPtrFieldList().push_back(PtrFieldInfo(getContainer(), fieldId)); PtrFieldInfo &pfi = root->editPtrFieldList().back(); rh->getValue(numElements); // keep these ordered from highest to lowest version if(root->getHeaderVersion() >= OSGOSBHeaderVersion200) { if(root->getHeaderVersion() > OSGOSBHeaderVersion200) { FINFO(("OSBCommonElement::readAttachmentMapField: " "Unknown header version, trying to read as latest.\n")); } hasBindingInfo = true; } else if(root->getHeaderVersion() >= OSGOSBHeaderVersion100) { // distinguish format with or without binding info if(fieldSize == (sizeof(UInt32) + numElements * sizeof(UInt32))) { hasBindingInfo = false; } else { hasBindingInfo = true; } } if(hasBindingInfo == true) { OSG_OSB_LOG(("OSBCommonElement::readAttachmentMapField: " "reading [%u] attachments with binding info.\n", numElements)); EditMapFieldHandlePtr sfMapField = boost::dynamic_pointer_cast<EditMapFieldHandle>( getContainer()->editField(fieldId)); if(sfMapField == NULL || sfMapField->isValid() == false) return --(root->editPtrFieldList().end()); pfi.setHandledField(sfMapField->loadFromBin(rh, numElements, hasBindingInfo, pfi.editBindingStore(), pfi.editIdStore ())); #if 0 for(UInt32 i = 0; i < numElements; ++i) { rh->getValue(binding); rh->getValue(ptrId ); OSG_OSB_LOG(("OSBCommonElement::readAttachmentMapField: " "attachment [%u], binding [%u], id [%u].\n", i, binding, ptrId)); pfi.editBindingStore().push_back(binding); pfi.editIdStore ().push_back(ptrId ); } #endif } else { OSG_OSB_LOG(("OSBCommonElement::readAttachmentMapField: " "reading [%u] attachments without binding info.\n", numElements)); for(UInt32 i = 0; i < numElements; ++i) { rh->getValue(ptrId); OSG_OSB_LOG(("OSBCommonElement::readAttachmentMapField: " "attachment [%u], id [%u].\n", i, ptrId)); pfi.editBindingStore().push_back(0 ); pfi.editIdStore ().push_back(ptrId); } } return --(root->editPtrFieldList().end()); }
SharedObject::~SharedObject(void) { FINFO(("destroy SharedObject %s\n", _szName.c_str())); }
Action::ResultE GeometryMergeGraphOp::traverseLeave( Node * const node, Action::ResultE res) { if(isInExcludeList(node)) return Action::Skip; NodeCore *core = node->getCore(); // skip cores with a dependency on the children number/order // TODO: find a way to make this extendable if(core == NULL || core->getType().isDerivedFrom(DistanceLOD::getClassType()) || core->getType().isDerivedFrom(ScreenLOD ::getClassType()) || core->getType().isDerivedFrom(Switch ::getClassType()) || core->getType().isDerivedFrom(MultiCore ::getClassType()) ) { return Action::Continue; } typedef std::vector<NodeUnrecPtr> NodeStore; NodeStore addStore; // nodes to add as children to current one NodeStore subStore; // nodes (children) to remove from current one typedef std::vector<Node * > MergeGroup; // geometries that can be merged typedef std::vector<MergeGroup> MergeList; // list of merge groups MergeList ml; Node::MFChildrenType::const_iterator childIt = node->getMFChildren()->begin(); Node::MFChildrenType::const_iterator childEnd = node->getMFChildren()->end (); // group geometry children that are mergeable for(; childIt != childEnd; ++childIt) { if((*childIt)->getCore()->getType() != Geometry::getClassType()) continue; if(isInExcludeList(*childIt) || isInPreserveList(*childIt)) continue; Geometry *geo = dynamic_cast<Geometry *>((*childIt)->getCore()); Material *mat = geo->getMaterial(); MergeList::iterator mlIt = ml.begin(); MergeList::iterator mlEnd = ml.end (); bool done = false; for(; mlIt != mlEnd && !done; ++mlIt) { Geometry *mlGeo = dynamic_cast<Geometry *>(mlIt->front()->getCore()); Material *mlMat = mlGeo->getMaterial(); if(compareContainerEqual(mlMat, mat) && mergeableGeo (mlGeo, geo) ) { mlIt->push_back(*childIt); done = true; } } if(!done) { ml .push_back(MergeGroup()); ml.back().push_back(*childIt ); } } // merge geometry in the same group and replace obsolete children with // new geometry MergeList::iterator mlIt = ml.begin(); MergeList::iterator mlEnd = ml.end (); for(; mlIt != mlEnd; ++mlIt) { // only one geometry in merge group -> nothing to do if(mlIt->size() <= 1) continue; FINFO(("GeometryMergeGraphOp::traverseLeave: Merging [%" PRISize "] " "Geometries.\n", mlIt->size())); GeometryUnrecPtr geo1; GeometryUnrecPtr geo2; NodeUnrecPtr newNode = Node::create(); MergeGroup::iterator mgIt = mlIt->begin(); MergeGroup::iterator mgEnd = mlIt->end (); geo1 = dynamic_cast<Geometry *>((*mgIt)->getCore()); // remove the first geo as well subStore.push_back(*mgIt); ++mgIt; for(UInt32 i = 0; mgIt != mgEnd; ++mgIt, ++i) { geo2 = dynamic_cast<Geometry *>((*mgIt)->getCore()); if(i > _mergeThreshold && (mgIt + 1) != mgEnd) { newNode->setCore(geo1); addStore.push_back(newNode); i = 0; newNode = Node::create(); geo1 = dynamic_cast<Geometry *>((*mgIt)->getCore()); ++mgIt; } geo1 = mergeGeo(geo1, geo2); geo1->setMaterial(geo2->getMaterial()); subStore.push_back(*mgIt); } newNode->setCore(geo1); addStore.push_back(newNode); } // add newly created geometries to current node NodeStore::const_iterator storeIt = subStore.begin(); NodeStore::const_iterator storeEnd = subStore.end (); for(; storeIt != storeEnd; ++storeIt) node->subChild(*storeIt); storeIt = addStore.begin(); storeEnd = addStore.end (); for(; storeIt != storeEnd; ++storeIt) node->addChild(*storeIt); return Action::Continue; }
//! low-level OpenGL calls, ignoring materials Action::ResultE DVRVolume::draw(DrawActionBase *action) { FINFO(("DVRVolume::draw\n")); Window *window = action->getWindow(); if(getShader() != NullFC) { // determine texture mode TextureManager::TextureMode mode = getTextureMode(window); FDEBUG(("DVRVolume::draw - using Shader: %s\n", //getShader()->getClassname())); getShader()->getType().getCName())); // initialization if(shadingInitialized == false) { // clear old texture chunks textureManager.clearTextures( getTextureStorage() ); // initialize shader bool result = getShader()->initialize( this, action ); if(result != true) { SFATAL << "DVRVolume::draw - error initializing shader" << std::endl; } //!! Shader::initialize may change the useMTSlabs() flag if(getShader()->useMTSlabs()) mode = TextureManager::TM_2D_Multi; // create texture chunks SINFO << "TextureMode = " << mode << std::endl; textureManager.buildTextures(getTextureStorage(), this, mode); // initialize slice clipper clipper.initialize(this); shadingInitialized = true; } // sort bricks Pnt3f eyePointWorld(0.f, 0.f, 0.f); action->getCameraToWorld().mult(eyePointWorld, eyePointWorld); Matrix modelMat = action->getActNode()->getToWorld(); // SINFO << "DVRVolume::draw - modelMat " << modelMat << std::endl; // SINFO << "DVRVolume::draw - eyePoint " << eyePointWorld << std::endl; //Brick * first = textureManager.sortBricks( // action,modelMat, eyePointWorld, this, mode); Brick *first = textureManager.sortBricks( action, modelMat, eyePointWorld.subZero(), this, mode); // render brick boundaries if(getShowBricks()) { for(Brick *current = first; current != NULL; current = current->getNext()) { current->renderBrick(); } } // initialize clipping initializeClipObjects(action, modelMat); // Texture_3D bricks need per brick clipping setup // whereas for Texture_2D bricks the clipper has to be initialized // only once in that case the reset is done in Brick::render3DSlices(..) if(mode != TextureManager::TM_3D) clipper.reset(this); //!! Rendering if(first != NULL) { getShader()->activate(this, action); // for all bricks Brick *prev = NULL; for(Brick *current = first; current != NULL; prev = current, current = current->getNext()) { //FDEBUG(("DVRVolume::draw - render Brick: %d\n" i++)); // switch to texture chunk if(getDoTextures()) { if (prev == NULL) { current->activateTexture(action); } else { current->changeFromTexture(action, prev); } } // activate shader getShader()->brickActivate(this, action, current); // render slices current->renderSlices(this, action, getShader(), &clipper, mode); } // deactivate last texture chunk prev->deactivateTexture(action); getShader()->deactivate(this, action); } } else { // Show some slices anyway Vec3f min, max; action->getActNode()->getVolume().getBounds(min, max); FDEBUG(("DVRVolume::draw dummy geometry - %f %f %f -> %f %f %f\n", min[0], min[1], min[2], max[0], max[1], max[2])); // resolution of volume in voxel UInt32 res[3] = {64, 64, 64}; // offset for slices Real32 offset[3] = {(max[0] - min[0]) / 2 / res[0], (max[1] - min[1]) / 2 / res[1], (max[2] - min[2]) / 2 / res[2]}; // increment for slices Real32 inc[3] = {(max[0] - min[0]) / res[0], (max[1] - min[1]) / res[1], (max[2] - min[2]) / res[2]}; // slices perpenticular to Z-axis Real32 value = min[2] + offset[2]; for(UInt32 i = 0; i < res[2]; i++, value += inc[2]) { glBegin(GL_LINE_LOOP); { glVertex3f(min[0] + offset[0], min[1] + offset[1], value); glTexCoord2f(0.0f + offset[0], 0.0f + offset[1]); glVertex3f(max[0] - offset[0], min[1] + offset[1], value); glTexCoord2f(1.0f - offset[0], 0.0f + offset[1]); glVertex3f(min[0] + offset[0], max[1] - offset[1], value); glTexCoord2f(0.0f + offset[0], 1.0f - offset[1]); glVertex3f(max[0] - offset[0], max[1] - offset[1], value); glTexCoord2f(1.0f - offset[0], 1.0f - offset[1]); } glEnd(); } } return Action::Skip; //return Geometry::draw(action); }
void FieldContainer::subReferenceRecorded(void) { #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT FINFO(("FieldContainer::subReference [%p] [%d] [%s] START - [%d %d]\n", this, this->getId(), this->getType().getCName(), this->_iRefCount, this->_iWeakRefCount)); #endif RefCountStore tmpRefCnt = osgAtomicExchangeAndAdd(&_iRefCount, -1); ChangeList *pChangeList = Thread::getCurrentChangeList(); if(tmpRefCnt <= 1) { pChangeList->incSubRefLevel(); this->resolveLinks(); pChangeList->decSubRefLevel(); pChangeList->addSubRefd (Inherited::getId()); osgSpinLock(&_uiContainerId, SpinLockBit); RefCountStore tmpWeakRefCnt = OSG_AREAD(_iWeakRefCount); _uiContainerId |= DeadContainerBit; osgSpinLockRelease(&_uiContainerId, SpinLockClearMask); if(tmpWeakRefCnt <= 0) { #ifdef OSG_MT_CPTR_ASPECT this->onDestroyAspect(Inherited::getId(), Thread::getCurrentAspect()); if(_pAspectStore->getRefCount() == 1) { this->deregister(Inherited::getId()); this->onDestroy (Inherited::getId()); } _pAspectStore->removePtrForAspect(Thread::getCurrentAspect()); OSG::subRef(_pAspectStore); _pAspectStore = NULL; #else this->deregister (Inherited::getId() ); this->onDestroyAspect(Inherited::getId(), 0); this->onDestroy (Inherited::getId() ); #endif delete this; } else { #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT FINFO( ("FieldContainer::subReference [%p] [%d] [%s] STOP A [%d %d]\n", this, this->getId(), this->getType().getCName(), this->_iRefCount, this->_iWeakRefCount)); #endif } } else { #ifndef OSG_FIELDCONTAINER_DEBUG_SILENT FINFO( ("FieldContainer::subReference [%p] [%d] [%s] STOP B [%d %d]\n", this, this->getId(), this->getType().getCName(), this->_iRefCount, this->_iWeakRefCount)); #endif pChangeList->addSubRefd(Inherited::getId()); } }
void ThreadManager::dump(void) { ThreadStore::MPFieldMapCIt tI = _sThreadStore._mFieldMap.begin(); ThreadStore::MPFieldMapCIt tE = _sThreadStore._mFieldMap.end (); for(; tI != tE; ++tI) { FLOG(("ThreadManager::dump: " "thread [%s|%p] is still alive ([%d]). \n", (*tI).first.c_str(), static_cast<void *>((*tI).second), (*tI).second->exists())); } BarrierStore::MPFieldMapCIt bI = _sBarrierStore._mFieldMap.begin(); BarrierStore::MPFieldMapCIt bE = _sBarrierStore._mFieldMap.end (); for(; bI != bE; ++bI) { FINFO(("ThreadManager::dump: " "barrier [%s|%p] is still alive\n", (*bI).first.c_str(), static_cast<void *>((*bI).second))); } CondVarStore::MPFieldMapCIt cI = _sCondVarStore._mFieldMap.begin(); CondVarStore::MPFieldMapCIt cE = _sCondVarStore._mFieldMap.end (); for(; cI != cE; ++cI) { FLOG(("ThreadManager::dump: " "condvar [%s|%p] is still alive\n", (*cI).first.c_str(), static_cast<void *>((*cI).second))); } LockStore::MPFieldMapCIt lI = _sLockStore._mFieldMap.begin(); LockStore::MPFieldMapCIt lE = _sLockStore._mFieldMap.end (); for(; lI != lE; ++lI) { FLOG(("ThreadManager::dump: " "lock [%s|%p] is still alive\n", (*lI).first.c_str(), static_cast<void *>((*lI).second))); } LockPoolStore::MPFieldMapCIt lpI = _sLockPoolStore._mFieldMap.begin(); LockPoolStore::MPFieldMapCIt lpE = _sLockPoolStore._mFieldMap.end (); for(; lpI != lpE; ++lpI) { FLOG(("ThreadManager::dump: " "lockpool [%s|%p] is still alive\n", (*lpI).first.c_str(), static_cast<void *>((*lpI).second))); } SemaphoreStore::MPFieldMapCIt sI = _sSemaphoreStore._mFieldMap.begin(); SemaphoreStore::MPFieldMapCIt sE = _sSemaphoreStore._mFieldMap.end (); for(; sI != sE; ++sI) { FLOG(("ThreadManager::dump: " "semaphore [%s|%p] is still alive\n", (*sI).first.c_str(), static_cast<void *>((*sI).second))); } FLOG( ("Sizes: ThreadStore: %" PRISize " BarrierStore: %" PRISize " CondVarStore: %" PRISize " LockStore: %" PRISize " LockPoolStore: %" PRISize " SemaphoreStore: %" PRISize "\n", _sThreadStore ._mFieldMap.size(), _sBarrierStore ._mFieldMap.size(), _sCondVarStore ._mFieldMap.size(), _sLockStore ._mFieldMap.size(), _sLockPoolStore ._mFieldMap.size(), _sSemaphoreStore._mFieldMap.size())); }