本文整理汇总了C++中DataStreamPtr类的典型用法代码示例。如果您正苦于以下问题:C++ DataStreamPtr类的具体用法?C++ DataStreamPtr怎么用?C++ DataStreamPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataStreamPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseNewAffector
//-----------------------------------------------------------------------
void ParticleSystemManager::parseNewAffector(const String& type, DataStreamPtr& stream, ParticleSystem* sys)
{
// Create new affector
ParticleAffector* pAff = sys->addAffector(type);
// Parse affector details
String line;
while(!stream->eof())
{
line = stream->getLine();
// Ignore comments & blanks
if (!(line.length() == 0 || line.substr(0,2) == "//"))
{
if (line == "}")
{
// Finished affector
break;
}
else
{
// Attribute
StringUtil::toLowerCase(line);
parseAffectorAttrib(line, pAff);
}
}
}
}
示例2: generateFragmentShader
virtual GpuProgramPtr generateFragmentShader(Perm permutation)
{
/// Create shader
if (mMasterSource.empty())
{
DataStreamPtr ptrMasterSource = ResourceGroupManager::getSingleton().openResource(
"DeferredShading/post/LightMaterial_ps.cg"
, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(ptrMasterSource.isNull()==false);
mMasterSource = ptrMasterSource->getAsString();
}
assert(mMasterSource.empty()==false);
// Create name
String name = mBaseName+StringConverter::toString(permutation)+"_ps";
// Create shader object
HighLevelGpuProgramPtr ptrProgram = HighLevelGpuProgramManager::getSingleton().createProgram(
name, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"cg", GPT_FRAGMENT_PROGRAM);
ptrProgram->setSource(mMasterSource);
ptrProgram->setParameter("entry_point","main");
ptrProgram->setParameter("profiles","ps_2_x arbfp1");
// set up the preprocessor defines
// Important to do this before any call to get parameters, i.e. before the program gets loaded
ptrProgram->setParameter("compile_arguments", getPPDefines(permutation));
setUpBaseParameters(ptrProgram->getDefaultParameters());
return GpuProgramPtr(ptrProgram);
}
示例3: parseNewEmitter
//-----------------------------------------------------------------------
void CGUIParticleSystemManager::parseNewEmitter(const CGUIString& type, DataStreamPtr& stream, CGUIParticleSystem* sys)
{
// Create new emitter
CGUIParticleEmitter* pEmit = sys->addEmitter(type);
// Parse emitter details
CGUIString line;
while(!stream->eof())
{
line = stream->getLine();
// Ignore comments & blanks
if (!(line.length() == 0 || line.substr(0,2) == "//"))
{
if (line == "}")
{
// Finished emitter
break;
}
else
{
// Attribute
StringUtil::toLowerCase(line);
parseEmitterAttrib(line, pEmit);
}
}
}
}
示例4: getPageConfigFilename
Ogre::DataStreamPtr TerrainGeometryManager::getPageConfig(int x, int z)
{
String cfg = getPageConfigFilename(x, z);
try
{
LOG("loading page config for page " + XZSTR(x,z) + " : " + cfg);
DataStreamPtr ds = ResourceGroupManager::getSingleton().openResource(cfg, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
if (!ds.isNull() && ds->isReadable())
{
return ds;
}
} catch (...)
{
}
LOG("error loading page config for page " + XZSTR(x,z) + " : " + cfg);
if (x != 0 || z != 0)
{
LOG("loading default page config: " + cfg + " instead");
return getPageConfig(0, 0);
}
return DataStreamPtr();
}
示例5: LoadScriptSection
// OgreScriptBuilder
int OgreScriptBuilder::LoadScriptSection(const char *filename)
{
// Open the script file
string scriptFile = filename;
DataStreamPtr ds;
try
{
ds = ResourceGroupManager::getSingleton().openResource(scriptFile, ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
} catch(Ogre::Exception e)
{
LOG("exception upon loading script file: " + e.getFullDescription());
return -1;
}
// Read the entire file
string code;
code.resize(ds->size());
ds->read(&code[0], ds->size());
// hash it
{
char hash_result[250];
memset(hash_result, 0, 249);
RoR::CSHA1 sha1;
sha1.UpdateHash((uint8_t *)code.c_str(), (uint32_t)code.size());
sha1.Final();
sha1.ReportHash(hash_result, RoR::CSHA1::REPORT_HEX_SHORT);
hash = String(hash_result);
}
return ProcessScriptSection(code.c_str(), filename);
}
示例6: loadMicrocodeCache
//---------------------------------------------------------------------
void GpuProgramManager::loadMicrocodeCache( DataStreamPtr stream )
{
mMicrocodeCache.clear();
// write the size of the array
uint32 sizeOfArray = 0;
stream->read(&sizeOfArray, sizeof(uint32));
// loop the array and load it
for ( uint32 i = 0 ; i < sizeOfArray ; i++ )
{
String nameOfShader;
// loads the name of the shader
uint32 stringLength = 0;
stream->read(&stringLength, sizeof(uint32));
nameOfShader.resize(stringLength);
stream->read(&nameOfShader[0], stringLength);
// loads the microcode
uint32 microcodeLength = 0;
stream->read(µcodeLength, sizeof(uint32));
Microcode microcodeOfShader(OGRE_NEW MemoryDataStream(nameOfShader, microcodeLength));
microcodeOfShader->seek(0);
stream->read(microcodeOfShader->getPtr(), microcodeLength);
mMicrocodeCache.insert(make_pair(nameOfShader, microcodeOfShader));
}
// if cache is not modified, mark it as clean.
mCacheDirty = false;
}
示例7:
size_t FileInterfaceOgre3D::Read(void* buffer, size_t size, Rocket::Core::FileHandle file)
{
if (!file) return 0;
DataStreamPtr stream = *(DataStreamPtr*)(file);
return stream->read(buffer, size);
}
示例8: getBinaryTimeStamp
time_t ScriptSerializerManager::getBinaryTimeStamp(const String& filename) {
DataStreamPtr stream = mCacheArchive->open(filename);
ScriptBlock::ScriptHeader header;
stream->read(reinterpret_cast<char*>(&header), sizeof(ScriptBlock::ScriptHeader));
stream->close();
return header.lastModifiedTime;
}
示例9: while
void MeshLoader_v0::ReadAnimStream(SubMesh * sm, DataStreamPtr & stream)
{
VertexDeclarationPtr decl = sm->GetVertexStream()->GetDeclaration();
VertexBufferPtr buffer;
int stride = 0;
chunk ck;
while (ReadChunk(ck, stream) &&
(ck.id == MC_STREAM_DECLARATION ||
ck.id == MC_STREAM_VERTEX_DATA))
{
switch (ck.id)
{
case MC_STREAM_DECLARATION:
ReadDeclaration(_ANIM_STREAM, decl, stream);
break;
case MC_STREAM_VERTEX_DATA:
ReadVertexStream(buffer, stride, sm->GetVertexStream()->GetCount(), stream);
break;
}
}
sm->GetVertexStream()->Bind(_ANIM_STREAM, buffer, stride);
//skip
if (!stream->Eof())
stream->Skip(-MC_CHUNK_SIZE);
}
示例10: sizeof
void MeshLoader_v0::ReadIndexStream(SubMesh * sm, DataStreamPtr & stream)
{
int count = sm->GetIndexStream()->GetCount();
unsigned char stride;
bool index16 = true;;
stream->Read(&stride, sizeof(unsigned char));
switch (stride)
{
case sizeof(short):
index16 = true;
break;
case sizeof(int):
index16 = false;
break;
default:
EXCEPTION_DEBUG(0, "invalid index format.");
break;
}
IndexBufferPtr pIndexBuffer = VideoBufferManager::Instance()->CreateIndexBuffer(stride * count, index16);
void * indices;
int start;
stream->Read(&start, sizeof(int));
indices = pIndexBuffer->Lock(0, 0, LOCK_DISCARD);
stream->Read(indices, stride * count);
pIndexBuffer->Unlock();
sm->GetIndexStream()->Bind(pIndexBuffer, start);
}
示例11: initializeConfig
void ScriptSerializerManager::initializeConfig(const String& configFileName) {
ConfigFile configFile;
Archive* workingDirectory = ArchiveManager::getSingleton().load(".", "FileSystem");
if (workingDirectory->exists(configFileName)) {
DataStreamPtr configStream = workingDirectory->open(configFileName);
configFile.load(configStream);
configStream->close();
}
else {
stringstream message;
message << "WARNING: Cannot find Script Cache config file:" << configFileName << ". Using default values";
LogManager::getSingleton().logMessage(message.str());
}
binaryScriptExtension = configFile.getSetting("extension", "ScriptCache", ".sbin");
scriptCacheLocation = configFile.getSetting("location", "ScriptCache", ".scriptCache");
shaderCacheFilename = configFile.getSetting("filename", "ShaderCache", "ShaderCache");
String searchExtensions = configFile.getSetting("searchExtensions", "ScriptCache", "program material particle compositor os pu");
istringstream extensions(searchExtensions);
String extension;
while (extensions >> extension) {
stringstream pattern;
pattern << "*." << extension << binaryScriptExtension;
ScriptCompilerManager::getSingleton().addScriptPattern(pattern.str());
}
}
示例12: decode
//---------------------------------------------------------------------
Codec::DecodeResult PVRTCCodec::decode(DataStreamPtr& stream) const
{
// Assume its a pvr 2 header
PVRTCTexHeaderV2 headerV2;
stream->read(&headerV2, sizeof(PVRTCTexHeaderV2));
stream->seek(0);
if (PVR2_MAGIC == headerV2.pvrTag)
{
return decodeV2(stream);
}
// Try it as pvr 3 header
PVRTCTexHeaderV3 headerV3;
stream->read(&headerV3, sizeof(PVRTCTexHeaderV3));
stream->seek(0);
if (PVR3_MAGIC == headerV3.version)
{
return decodeV3(stream);
}
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"This is not a PVR2 / PVR3 file!", "PVRTCCodec::decode");
}
示例13: loadMicrocodeCache
//---------------------------------------------------------------------
void GpuProgramManager::loadMicrocodeCache( DataStreamPtr stream )
{
mMicrocodeCache.clear();
// write the size of the array
size_t sizeOfArray = 0;
stream->read(&sizeOfArray, sizeof(size_t));
// loop the array and load it
for ( size_t i = 0 ; i < sizeOfArray ; i++ )
{
String nameOfShader;
// loads the name of the shader
size_t stringLength = 0;
stream->read(&stringLength, sizeof(size_t));
nameOfShader.resize(stringLength);
stream->read(&nameOfShader[0], stringLength);
// loads the microcode
size_t microcodeLength = 0;
stream->read(µcodeLength, sizeof(size_t));
Microcode microcodeOfShader(OGRE_NEW MemoryDataStream(nameOfShader, microcodeLength));
microcodeOfShader->seek(0);
stream->read(microcodeOfShader->getPtr(), microcodeLength);
mMicrocodeCache.insert(make_pair(nameOfShader, microcodeOfShader));
}
}
示例14: parseNewTextureLayer
//-----------------------------------------------------------------------
void OldMaterialReader::parseNewTextureLayer(DataStreamPtr& stream, MaterialPtr& pMat)
{
String line;
TextureUnitState* pLayer;
pLayer = pMat->getTechnique(0)->getPass(0)->createTextureUnitState("");
while (!stream->eof())
{
line = stream->getLine();
// Ignore comments & blanks
if (line.length() != 0 && !(line.substr(0,2) == "//"))
{
if (line == "}")
{
// end of layer
return;
}
else
{
parseLayerAttrib(line, pMat, pLayer);
}
}
}
}
示例15: generateHashFromDataStream
void generateHashFromDataStream(DataStreamPtr &ds, Ogre::String &hash)
{
size_t location = ds->tell();
// copy whole file into a buffer
uint8_t *buf = 0;
ds->seek(0); // from start
// alloc buffer
uint32_t bufSize = ds->size();
buf = (uint8_t *)malloc(bufSize+1);
// read into buffer
ds->read(buf, bufSize);
// and build the hash over it
char hash_result[250];
memset(hash_result, 0, 249);
{
RoR::CSHA1 sha1;
sha1.UpdateHash(buf, bufSize);
sha1.Final();
sha1.ReportHash(hash_result, RoR::CSHA1::REPORT_HEX_SHORT);
}
// revert DS to previous position
ds->seek(location);
// release memory
free(buf);
buf = 0;
hash = String(hash_result);
}