HighLevelGpuProgramPtr WaterMaterialGenerator::createFragmentProgram() { HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton(); std::string progName = mDef->getName() + "_FP"; HighLevelGpuProgramPtr ret = mgr.getByName(progName); if (!ret.isNull()) mgr.remove(progName); ret = mgr.createProgram(progName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "cg", GPT_FRAGMENT_PROGRAM); if(MRTSupported()) ret->setParameter("profiles", "ps_4_0 ps_3_0 fp40"); else ret->setParameter("profiles", "ps_4_0 ps_3_0 fp40 arbfp1"); ret->setParameter("entry_point", "main_fp"); StringUtil::StrStreamType outStream; generateFragmentProgramSource(outStream); ret->setSource(outStream.str()); ret->load(); GpuProgramParametersSharedPtr params = ret->getDefaultParameters(); fragmentProgramParams(ret); return ret; }
void Version::ToString(String& text) const { StringUtil::StrStreamType versionText; //Find the last non-zero component int lastNonzeroComponent = -1; for (int index = MAX_COMPONENTS - 1; index >= 0; index--) { if (this->components[index] != 0) { lastNonzeroComponent = index; break; } } //Output everything up to the last non-zero component if (lastNonzeroComponent >= 0) { for (int index = 0; index <= lastNonzeroComponent; index++) { versionText << this->components[index]; if (index < lastNonzeroComponent) versionText << "."; } } else { //All components are zero versionText << "0"; } text = versionText.str(); }
//-------------------------------------------------------------------------- void MemoryTracker::reportLeaks() { StringUtil::StrStreamType os; if (mAllocations.empty()) os << "No leaks!"; else { size_t totalMem = 0; os << "Leaks detected:" << std::endl << std::endl; for (AllocationMap::const_iterator i = mAllocations.begin(); i != mAllocations.end(); ++i) { const Alloc& alloc = i->second; if (!alloc.filename.empty()) os << alloc.filename << "(" << alloc.line << ", " << alloc.function << "): "; else os << "(unknown source): "; os << alloc.bytes << " bytes"; os << std::endl; totalMem += alloc.bytes; } os << std::endl; os << mAllocations.size() << " leaks detected, " << totalMem << " bytes total"; } if (mDumpToStdOut) std::cout << os.str(); std::ofstream of; of.open(mLeakFileName.c_str()); of << os.str(); of.close(); }
//----------------------------------------------------------------------- void HardwareBufferManagerBase::_freeUnusedBufferCopies(void) { OGRE_LOCK_MUTEX(mTempBuffersMutex); size_t numFreed = 0; // Free unused temporary buffers FreeTemporaryVertexBufferMap::iterator i; i = mFreeTempVertexBufferMap.begin(); while (i != mFreeTempVertexBufferMap.end()) { FreeTemporaryVertexBufferMap::iterator icur = i++; // Free the temporary buffer that referenced by ourself only. // TODO: Some temporary buffers are bound to vertex buffer bindings // but not checked out, need to sort out method to unbind them. if (icur->second.useCount() <= 1) { ++numFreed; mFreeTempVertexBufferMap.erase(icur); } } StringUtil::StrStreamType str; if (numFreed) { str << "HardwareBufferManager: Freed " << numFreed << " unused temporary vertex buffers."; } else { str << "HardwareBufferManager: No unused temporary vertex buffers found."; } LogManager::getSingleton().logMessage(str.str(), LML_TRIVIAL); }
HardwareBuffer::Usage OgreMaxUtilities::ParseHardwareBufferUsage(const String& usage) { String usageLower = usage; StringUtil::toLowerCase(usageLower); if (usageLower == "static") return HardwareBuffer::HBU_STATIC; else if (usageLower == "dynamic") return HardwareBuffer::HBU_DYNAMIC; else if (usageLower == "writeonly") return HardwareBuffer::HBU_WRITE_ONLY; else if (usageLower == "staticwriteonly") return HardwareBuffer::HBU_STATIC_WRITE_ONLY; else if (usageLower == "dynamicwriteonly") return HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY; StringUtil::StrStreamType errorMessage; errorMessage << "Invalid hardware buffer usage specified: " << usage; OGRE_EXCEPT ( Exception::ERR_INVALIDPARAMS, errorMessage.str(), "OgreMaxUtilities::ParseHardwareBufferUsage" ); }
ShadowTechnique OgreMaxUtilities::ParseShadowTechnique(const String& technique) { String techniqueLower = technique; StringUtil::toLowerCase(techniqueLower); if (techniqueLower == "none") return SHADOWTYPE_NONE; else if (techniqueLower == "stencilmodulative") return SHADOWTYPE_STENCIL_MODULATIVE; else if (techniqueLower == "stenciladditive") return SHADOWTYPE_STENCIL_ADDITIVE; else if (techniqueLower == "texturemodulative") return SHADOWTYPE_TEXTURE_MODULATIVE; else if (techniqueLower == "textureadditive") return SHADOWTYPE_TEXTURE_ADDITIVE; else if (techniqueLower == "texturemodulativeintegrated") return SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED; else if (techniqueLower == "textureadditiveintegrated") return SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED; StringUtil::StrStreamType errorMessage; errorMessage << "Invalid shadow technique specified: " << technique; OGRE_EXCEPT ( Exception::ERR_INVALIDPARAMS, errorMessage.str(), "OgreMaxUtilities::ParseShadowTechnique" ); }
BillboardOrigin OgreMaxUtilities::ParseBillboardOrigin(const String& origin) { String originLower = origin; StringUtil::toLowerCase(originLower); if (originLower == "topleft") return BBO_TOP_LEFT; else if (originLower == "topcenter") return BBO_TOP_CENTER; else if (originLower == "topright") return BBO_TOP_RIGHT; else if (originLower == "centerleft") return BBO_CENTER_LEFT; else if (originLower == "center") return BBO_CENTER; else if (originLower == "centerright") return BBO_CENTER_RIGHT; else if (originLower == "bottomleft") return BBO_BOTTOM_LEFT; else if (originLower == "bottomcenter") return BBO_BOTTOM_CENTER; else if (originLower == "bottomright") return BBO_BOTTOM_RIGHT; StringUtil::StrStreamType errorMessage; errorMessage << "Invalid billboard origin specified: " << origin; OGRE_EXCEPT ( Exception::ERR_INVALIDPARAMS, errorMessage.str(), "OgreMaxUtilities::ParseBillboardOrigin" ); }
//----------------------------------------------------------------------- ColourInterpolatorAffector::ColourInterpolatorAffector(ParticleSystem* psys) : ParticleAffector(psys) { for (int i=0;i<MAX_STAGES;i++) { // set default colour to transparent grey, transparent since we might not want to display the particle here // grey because when a colour component is 0.5f the maximum difference to another colour component is 0.5f mColourAdj[i] = ColourValue(0.5f, 0.5f, 0.5f, 0.0f); mTimeAdj[i] = 1.0f; } mType = "ColourInterpolator"; // Init parameters if (createParamDictionary("ColourInterpolatorAffector")) { ParamDictionary* dict = getParamDictionary(); for (int i=0;i<MAX_STAGES;i++) { msColourCmd[i].mIndex = i; msTimeCmd[i].mIndex = i; StringUtil::StrStreamType stage; stage << i; String colour_title = String("colour") + stage.str(); String time_title = String("time") + stage.str(); String colour_descr = String("Stage ") + stage.str() + String(" colour."); String time_descr = String("Stage ") + stage.str() + String(" time."); dict->addParameter(ParameterDef(colour_title, colour_descr, PT_COLOURVALUE), &msColourCmd[i]); dict->addParameter(ParameterDef(time_title, time_descr, PT_REAL), &msTimeCmd[i]); } } }
HighLevelGpuProgramPtr WaterMaterialGenerator::createVertexProgram() { HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton(); std::string progName = mDef->getName() + "_VP"; HighLevelGpuProgramPtr ret = mgr.getByName(progName); if (!ret.isNull()) mgr.remove(progName); ret = mgr.createProgram(progName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "cg", GPT_VERTEX_PROGRAM); if(MRTSupported()) { ret->setParameter("profiles", "vs_4_0 vs_3_0 vp40"); } else { ret->setParameter("profiles", "vs_4_0 vs_2_x vp40 arbvp1"); } ret->setParameter("entry_point", "main_vp"); StringUtil::StrStreamType outStream; generateVertexProgramSource(outStream); ret->setSource(outStream.str()); ret->load(); vertexProgramParams(ret); return ret; }
void Win32GLSupport::setConfigOption(const String &name, const String &value) { ConfigOptionMap::iterator it = mOptions.find(name); // Update if(it != mOptions.end()) it->second.currentValue = value; else { StringUtil::StrStreamType str; str << "Option named '" << name << "' does not exist."; OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, str.str(), "Win32GLSupport::setConfigOption" ); } if( name == "Video Mode" ) refreshConfig(); if( name == "Full Screen" ) { it = mOptions.find( "Display Frequency" ); if( value == "No" ) { it->second.currentValue = "N/A"; it->second.immutable = true; } else { if (it->second.currentValue.empty() || it->second.currentValue == "N/A") it->second.currentValue = it->second.possibleValues.front(); it->second.immutable = false; } } }
//------------------------------------------------------ void MaterialService::prepareMaterialInstance(MaterialPtr& mat, unsigned int idx, int tag) { if (tag < 0) // Should not be here if the polygon is sky textured OPDE_EXCEPT("Non-instanced material instance requested", "MaterialService::prepareMaterialInstance"); mat->setReceiveShadows(true); StringUtil::StrStreamType lightmapName; lightmapName << "@lightmap" << tag; Pass *shadPass = mat->getTechnique(0)->getPass(0); if (shadPass->getNumTextureUnitStates() <= 1) { // Lightmap texture is added here TextureUnitState* tex = shadPass->createTextureUnitState(lightmapName.str()); // Blend tex->setColourOperation(LBO_MODULATE); // Use 2nd texture co-ordinate set tex->setTextureCoordSet(1); // Clamp tex->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); // Switch filtering off to see lmap pixels: TFO_NONE tex->setTextureFiltering(TFO_BILINEAR); } else { // There is a definition of the lightmapping pass already, we only update that definition TextureUnitState* tex = shadPass->getTextureUnitState(1); tex->setTextureName(lightmapName.str()); tex->setTextureCoordSet(1); } }
//--------------------------------------------------------------------- void DefaultWorkQueueBase::processResponse(Response* r) { StringUtil::StrStreamType dbgMsg; dbgMsg << "thread:" << #if OGRE_THREAD_SUPPORT OGRE_THREAD_CURRENT_ID #else "main" #endif << "): ID=" << r->getRequest()->getID() << " success=" << r->succeeded() << " messages=[" << r->getMessages() << "] channel=" << r->getRequest()->getChannel() << " requestType=" << r->getRequest()->getType(); LogManager::getSingleton().stream(LML_TRIVIAL) << "DefaultWorkQueueBase('" << mName << "') - PROCESS_RESPONSE_START(" << dbgMsg.str(); ResponseHandlerListByChannel::iterator i = mResponseHandlers.find(r->getRequest()->getChannel()); if (i != mResponseHandlers.end()) { ResponseHandlerList& handlers = i->second; for (ResponseHandlerList::reverse_iterator j = handlers.rbegin(); j != handlers.rend(); ++j) { if ((*j)->canHandleResponse(r, this)) { (*j)->handleResponse(r, this); } } } LogManager::getSingleton().stream(LML_TRIVIAL) << "DefaultWorkQueueBase('" << mName << "') - PROCESS_RESPONSE_END(" << dbgMsg.str(); }
BillboardType OgreMaxUtilities::ParseBillboardType(const String& type) { String typeLower = type; StringUtil::toLowerCase(typeLower); if (typeLower == "point") return BBT_POINT; else if (typeLower == "orientedcommon") return BBT_ORIENTED_COMMON; else if (typeLower == "orientedself") return BBT_ORIENTED_SELF; else if (typeLower == "perpendicularcommon") return BBT_PERPENDICULAR_COMMON; else if (typeLower == "perpendicularself") return BBT_PERPENDICULAR_SELF; StringUtil::StrStreamType errorMessage; errorMessage << "Invalid billboard type specified: " << type; OGRE_EXCEPT ( Exception::ERR_INVALIDPARAMS, errorMessage.str(), "OgreMaxUtilities::ParseBillboardType" ); }
BoundingVolume::Type OgreMaxUtilities::ParseBoundingVolumeType(const String& type) { String typeLower = type; StringUtil::toLowerCase(typeLower); if (typeLower == "sphere") return BoundingVolume::SPHERE; else if (typeLower == "box") return BoundingVolume::BOX; else if (typeLower == "cylinder") return BoundingVolume::CYLINDER; else if (typeLower == "capsule") return BoundingVolume::CAPSULE; else if (typeLower == "mesh") return BoundingVolume::MESH; StringUtil::StrStreamType errorMessage; errorMessage << "Invalid bounding volume type specified: " << type; OGRE_EXCEPT ( Exception::ERR_INVALIDPARAMS, errorMessage.str(), "OgreMaxUtilities::ParseBoundingVolumeType" ); }
//----------------------------------------------------------------------- Node::Node() :mParent(0), mNeedParentUpdate(false), mNeedChildUpdate(false), mParentNotified(false), mQueuedForUpdate(false), mOrientation(Quaternion::IDENTITY), mPosition(Vector3::ZERO), mScale(Vector3::UNIT_SCALE), mInheritOrientation(true), mInheritScale(true), mDerivedOrientation(Quaternion::IDENTITY), mDerivedPosition(Vector3::ZERO), mDerivedScale(Vector3::UNIT_SCALE), mInitialPosition(Vector3::ZERO), mInitialOrientation(Quaternion::IDENTITY), mInitialScale(Vector3::UNIT_SCALE), mCachedTransformOutOfDate(true), mListener(0) { // Generate a name StringUtil::StrStreamType str; str << "Unnamed_" << msNextGeneratedNameExt++; mName = str.str(); needUpdate(); }
String D3D9Driver::DriverDescription() const { StringUtil::StrStreamType str; str << "Monitor-" << (mAdapterNumber+1) << "-" << mAdapterIdentifier.Description; String driverDescription(str.str()); StringUtil::trim(driverDescription); return driverDescription; }
PixelFormat OgreMaxUtilities::ParsePixelFormat(const String& pixelFormat) { static bool initialized = false; static std::map<String, PixelFormat> nameToFormat; if (!initialized) { nameToFormat["PF_L8"] = PF_L8; nameToFormat["PF_L16"] = PF_L16; nameToFormat["PF_A8"] = PF_A8; nameToFormat["PF_A4L4"] = PF_A4L4; nameToFormat["PF_BYTE_LA"] = PF_BYTE_LA; nameToFormat["PF_R5G6B5"] = PF_R5G6B5; nameToFormat["PF_B5G6R5"] = PF_B5G6R5; nameToFormat["PF_R3G3B2"] = PF_R3G3B2; nameToFormat["PF_A4R4G4B4"] = PF_A4R4G4B4; nameToFormat["PF_A1R5G5B5"] = PF_A1R5G5B5; nameToFormat["PF_R8G8B8"] = PF_R8G8B8; nameToFormat["PF_B8G8R8"] = PF_B8G8R8; nameToFormat["PF_A8R8G8B8"] = PF_A8R8G8B8; nameToFormat["PF_A8B8G8R8"] = PF_A8B8G8R8; nameToFormat["PF_B8G8R8A8"] = PF_B8G8R8A8; nameToFormat["PF_R8G8B8A8"] = PF_R8G8B8A8; nameToFormat["PF_X8R8G8B8"] = PF_X8R8G8B8; nameToFormat["PF_X8B8G8R8"] = PF_X8B8G8R8; nameToFormat["PF_A2R10G10B10"] = PF_A2R10G10B10; nameToFormat["PF_A2B10G10R10"] = PF_A2B10G10R10; nameToFormat["PF_FLOAT16_R"] = PF_FLOAT16_R; nameToFormat["PF_FLOAT16_RGB"] = PF_FLOAT16_RGB; nameToFormat["PF_FLOAT16_RGBA"] = PF_FLOAT16_RGBA; nameToFormat["PF_FLOAT32_R"] = PF_FLOAT32_R; nameToFormat["PF_FLOAT32_RGB"] = PF_FLOAT32_RGB; nameToFormat["PF_FLOAT32_RGBA"] = PF_FLOAT32_RGBA; nameToFormat["PF_FLOAT16_GR"] = PF_FLOAT16_GR; nameToFormat["PF_FLOAT32_GR"] = PF_FLOAT32_GR; nameToFormat["PF_DEPTH"] = PF_DEPTH; nameToFormat["PF_SHORT_RGBA"] = PF_SHORT_RGBA; nameToFormat["PF_SHORT_GR"] = PF_SHORT_GR; nameToFormat["PF_SHORT_RGB"] = PF_SHORT_RGB; initialized = true; } std::map<String, PixelFormat>::iterator format = nameToFormat.find(pixelFormat); if (format != nameToFormat.end()) return format->second; StringUtil::StrStreamType errorMessage; errorMessage << "Invalid pixel format specified: " << pixelFormat; OGRE_EXCEPT ( Exception::ERR_INVALIDPARAMS, errorMessage.str(), "OgreMaxUtilities::ParsePixelFormat" ); }
HighLevelGpuProgramPtr ParticleMaterialGenerator::createSoftParticleVertexProgram() { HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton(); std::string progName = mDef->getName() + "_ambient_VP"; HighLevelGpuProgramPtr ret = mgr.getByName(progName); if (!ret.isNull()) mgr.remove(progName); ret = mgr.createProgram(progName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "cg", GPT_VERTEX_PROGRAM); ret->setParameter("profiles", "vs_4_0 vs_1_1 arbvp1"); ret->setParameter("entry_point", "main_vp"); StringUtil::StrStreamType sourceStr; sourceStr << "void main_vp( float4 position : POSITION, \n" " float4 color : COLOR, \n" " float2 texCoord : TEXCOORD0, \n" " out float4 oPosition : POSITION, \n" " out float4 objectPos : COLOR, \n" " out float4 oTexCoord : TEXCOORD0, \n" " out float4 oVertexColour : TEXCOORD1, \n" " out float4 oScreenPosition : TEXCOORD2, \n" " out float4 oWorldPosition : TEXCOORD3, \n" " uniform float enableFog, \n" " uniform float4 fogParams, \n" " uniform float4x4 wvpMat, \n" " uniform float4x4 wMat \n" ") \n" "{ \n" " oVertexColour = color; \n" " oPosition = mul(wvpMat, position); \n" " oWorldPosition = mul(wMat, position); \n" " oScreenPosition = oPosition; \n" " oTexCoord = float4(texCoord.x, texCoord.y, 1, 1); \n" " objectPos = position; \n" " objectPos.w = enableFog * saturate(fogParams.x * (oPosition.z - fogParams.y) * fogParams.w); \n" "} \n"; ret->setSource(sourceStr.str()); ret->load(); // params GpuProgramParametersSharedPtr params = ret->getDefaultParameters(); params->setIgnoreMissingParams(true); params->setNamedAutoConstant("wvpMat", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); params->setNamedAutoConstant("wMat", GpuProgramParameters::ACT_WORLD_MATRIX); params->setNamedAutoConstant("fogParams", GpuProgramParameters::ACT_FOG_PARAMS); params->setNamedConstant("enableFog", mDef->mProps->fog ? Real(1.0) : Real(0.0)); return ret; }
//----------------------------------------------------------------------- String StringConverter::toString(unsigned long val, unsigned short width, char fill, std::ios::fmtflags flags) { StringUtil::StrStreamType stream; stream.width(width); stream.fill(fill); if (flags) stream.setf(flags); stream << val; return stream.str(); }
int main(char argc, char** argv) { // Try D3D try { Root root("", "", "OgreCapsReportD3D9.log"); StringUtil::StrStreamType str; str << "RenderSystem_Direct3D9" << LIB_SUFFIX; root.loadPlugin(str.str()); RenderSystem* rs = root.getAvailableRenderers()->at(0); ConfigOption& opt = rs->getConfigOptions().find("Rendering Device")->second; opt.currentValue = opt.possibleValues[0]; root.setRenderSystem(rs); root.initialise(false); root.createRenderWindow("probe", 100, 100, false); } catch(std::exception&) { // failed D3D9 LogManager::getSingleton().logMessage("D3D9 testing failed - perhaps you " "don't have the D3D9 runtime installed on this machine?"); } // Try GL try { Root root("", "", "OgreCapsReportGL.log"); StringUtil::StrStreamType str; str << "RenderSystem_GL" << LIB_SUFFIX; root.loadPlugin(str.str()); RenderSystem* rs = root.getAvailableRenderers()->at(0); root.setRenderSystem(rs); root.initialise(false); root.createRenderWindow("probe", 100, 100, false); } catch(std::exception&) { // failed GL LogManager::getSingleton().logMessage("GL testing failed - perhaps you " "don't have a GL driver installed on this machine?"); } }
void UnloadMaterials(const std::string& filename) { if (filename.empty()) { Ogre::LogManager::getSingleton().logMessage("Filename is empty."); return; } Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(filename); if(!stream.isNull()) { try { while(!stream->eof()) { std::string line = stream->getLine(); StringUtil::trim(line); /// /// UNLOAD MATERIALS /// if (StringUtil::startsWith(line, "material")) { Ogre::vector<Ogre::String>::type vec = StringUtil::split(line," \t:"); bool skipFirst = true; for (Ogre::vector<Ogre::String>::type::iterator it = vec.begin(); it < vec.end(); ++it) { if (skipFirst) { skipFirst = false; continue; } std::string match = (*it); StringUtil::trim(match); if (!match.empty()) { UnloadResource(Ogre::MaterialManager::getSingletonPtr(), match); break; } } } } } catch (Ogre::Exception &e) { StringUtil::StrStreamType msg; msg << "Exception: FILE: " << __FILE__ << " LINE: " << __LINE__ << " DESC: " << e.getFullDescription() << std::endl; Ogre::LogManager::getSingleton().logMessage(msg.str()); } } stream->close(); }
String ImpostorBatch::generateEntityKey(Entity *entity) { StringUtil::StrStreamType entityKey; entityKey << entity->getMesh()->getName(); for (uint32 i = 0; i < entity->getNumSubEntities(); ++i){ entityKey << "-" << entity->getSubEntity(i)->getMaterialName(); } entityKey << "-" << IMPOSTOR_YAW_ANGLES << "_" << IMPOSTOR_PITCH_ANGLES; #ifdef IMPOSTOR_RENDER_ABOVE_ONLY entityKey << "_RAO"; #endif return entityKey.str(); }
//--------------------------------------------------------------------- void FreeImageCodec::startup(void) { FreeImage_Initialise(false); LogManager::getSingleton().logMessage( LML_NORMAL, "FreeImage version: " + String(FreeImage_GetVersion())); LogManager::getSingleton().logMessage( LML_NORMAL, FreeImage_GetCopyrightMessage()); // Register codecs StringUtil::StrStreamType strExt; strExt << "Supported formats: "; bool first = true; for (int i = 0; i < FreeImage_GetFIFCount(); ++i) { // Skip DDS codec since FreeImage does not have the option // to keep DXT data compressed, we'll use our own codec if ((FREE_IMAGE_FORMAT)i == FIF_DDS) continue; String exts(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i)); if (!first) { strExt << ","; } first = false; strExt << exts; // Pull off individual formats (separated by comma by FI) StringVector extsVector = StringUtil::split(exts, ","); for (StringVector::iterator v = extsVector.begin(); v != extsVector.end(); ++v) { ImageCodec* codec = OGRE_NEW FreeImageCodec(*v, i); msCodecList.push_back(codec); Codec::registerCodec(codec); } } LogManager::getSingleton().logMessage( LML_NORMAL, strExt.str()); // Set error handler FreeImage_SetOutputMessage(FreeImageErrorHandler); }
//----------------------------------------------------------------------- String StringConverter::toString(const Matrix3& val) { StringUtil::StrStreamType stream; stream << val[0][0] << " " << val[0][1] << " " << val[0][2] << " " << val[1][0] << " " << val[1][1] << " " << val[1][2] << " " << val[2][0] << " " << val[2][1] << " " << val[2][2]; return stream.str(); }
SimpleRenderable::SimpleRenderable() : MovableObject() , mWorldTransform(Matrix4::IDENTITY) , mMatName("BaseWhite") , mMaterial(MaterialManager::getSingleton().getByName("BaseWhite")) , mParentSceneManager(NULL) , mCamera(NULL) { // Generate name StringUtil::StrStreamType name; name << "SimpleRenderable" << msGenNameCount++; mName = name.str(); }
//--------------------------------------------------------------------- void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { // Callback method as required by FreeImage to report problems StringUtil::StrStreamType str; str << "FreeImage error: '" << message << "'"; const char* typeName = FreeImage_GetFormatFromFIF(fif); if (typeName) { str << " when loading format " << typeName; } LogManager::getSingleton().logMessage(str.str()); }
//----------------------------------------------------------------------- String StringConverter::toString(const StringVector& val) { StringUtil::StrStreamType stream; StringVector::const_iterator i, iend, ibegin; ibegin = val.begin(); iend = val.end(); for (i = ibegin; i != iend; ++i) { if (i != ibegin) stream << " "; stream << *i; } return stream.str(); }
//----------------------------------------------------------------------- SceneManager* SceneManagerEnumerator::createSceneManager( const String& typeName, const String& instanceName) { if (mInstances.find(instanceName) != mInstances.end()) { OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, "SceneManager instance called '" + instanceName + "' already exists", "SceneManagerEnumerator::createSceneManager"); } SceneManager* inst = 0; for(Factories::iterator i = mFactories.begin(); i != mFactories.end(); ++i) { if ((*i)->getMetaData().typeName == typeName) { if (instanceName.empty()) { // generate a name StringUtil::StrStreamType s; s << "SceneManagerInstance" << ++mInstanceCreateCount; inst = (*i)->createInstance(s.str()); } else { inst = (*i)->createInstance(instanceName); } break; } } if (!inst) { // Error! OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "No factory found for scene manager of type '" + typeName + "'", "SceneManagerEnumerator::createSceneManager"); } /// assign rs if already configured if (mCurrentRenderSystem) inst->_setDestinationRenderSystem(mCurrentRenderSystem); mInstances[inst->getName()] = inst; return inst; }
//--------------------------------------------------------------------- String Page::generateFilename() const { StringUtil::StrStreamType str; if (mParent) str << mParent->getWorld()->getName() << "_" << mParent->getName(); str << std::setw(8) << std::setfill('0') << std::hex << mID << ".page"; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS // For the iOS we need to prefix the file name with the path to the Caches folder String cacheStr(Ogre::macCachePath() + str.str()); return cacheStr; #else return str.str(); #endif }
//--------------------------------------------------------------------- WorkQueue::Response* DefaultWorkQueueBase::processRequest(Request* r) { RequestHandlerListByChannel handlerListCopy; { // lock the list only to make a copy of it, to maximise parallelism OGRE_LOCK_RW_MUTEX_READ(mRequestHandlerMutex); handlerListCopy = mRequestHandlers; } Response* response = 0; StringUtil::StrStreamType dbgMsg; dbgMsg << #if OGRE_THREAD_SUPPORT OGRE_THREAD_CURRENT_ID #else "main" #endif << "): ID=" << r->getID() << " channel=" << r->getChannel() << " requestType=" << r->getType(); LogManager::getSingleton().stream(LML_TRIVIAL) << "DefaultWorkQueueBase('" << mName << "') - PROCESS_REQUEST_START(" << dbgMsg.str(); RequestHandlerListByChannel::iterator i = handlerListCopy.find(r->getChannel()); if (i != handlerListCopy.end()) { RequestHandlerList& handlers = i->second; for (RequestHandlerList::reverse_iterator j = handlers.rbegin(); j != handlers.rend(); ++j) { // threadsafe call which tests canHandleRequest and calls it if so response = (*j)->handleRequest(r, this); if (response) break; } } LogManager::getSingleton().stream(LML_TRIVIAL) << "DefaultWorkQueueBase('" << mName << "') - PROCESS_REQUEST_END(" << dbgMsg.str() << " processed=" << (response!=0); return response; }