/** * Parse GLX/WGL_ARB_create_context attribute list. */ glprofile::Profile parseContextAttribList(const trace::Value *attribs) { // {GLX,WGL}_CONTEXT_MAJOR_VERSION_ARB int major_version = parseAttrib(attribs, 0x2091, 1); // {GLX,WGL}_CONTEXT_MINOR_VERSION_ARB int minor_version = parseAttrib(attribs, 0x2092, 0); int profile_mask = parseAttrib(attribs, GL_CONTEXT_PROFILE_MASK, GL_CONTEXT_CORE_PROFILE_BIT); bool core_profile = profile_mask & GL_CONTEXT_CORE_PROFILE_BIT; if (major_version < 3 || (major_version == 3 && minor_version < 2)) { core_profile = false; } // {GLX,WGL}_CONTEXT_ES_PROFILE_BIT_EXT bool es_profile = profile_mask & 0x0004; glprofile::Profile profile; if (es_profile) { profile.api = glprofile::API_GLES; } else { profile.api = glprofile::API_GL; profile.core = core_profile; } profile.major = major_version; profile.minor = minor_version; return profile; }
/** * Parse GLX/WGL_ARB_create_context attribute list. */ glws::Profile parseContextAttribList(const trace::Value *attribs) { int major_version = parseAttrib(attribs, 0x2091, 1); int minor_version = parseAttrib(attribs, 0x2092, 0); int profile_mask = parseAttrib(attribs, GL_CONTEXT_PROFILE_MASK, 0); bool core_profile = profile_mask & GL_CONTEXT_CORE_PROFILE_BIT; glws::Profile profile = glws::PROFILE_COMPAT; if (major_version >= 3) { profile = (glws::Profile)((core_profile ? 0x100 : 0) | (major_version << 4) | minor_version); } return profile; }
/** * Parse GLX/WGL_ARB_create_context attribute list. */ glfeatures::Profile parseContextAttribList(const trace::Value *attribs) { // {GLX,WGL}_CONTEXT_MAJOR_VERSION_ARB int major_version = parseAttrib(attribs, 0x2091, 1); // {GLX,WGL}_CONTEXT_MINOR_VERSION_ARB int minor_version = parseAttrib(attribs, 0x2092, 0); int profile_mask = parseAttrib(attribs, GL_CONTEXT_PROFILE_MASK, GL_CONTEXT_CORE_PROFILE_BIT); bool core_profile = profile_mask & GL_CONTEXT_CORE_PROFILE_BIT; if (major_version < 3 || (major_version == 3 && minor_version < 2)) { core_profile = false; } int context_flags = parseAttrib(attribs, GL_CONTEXT_FLAGS, 0); bool forward_compatible = context_flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; if (major_version < 3) { forward_compatible = false; } // {GLX,WGL}_CONTEXT_ES_PROFILE_BIT_EXT bool es_profile = profile_mask & 0x0004; glfeatures::Profile profile; if (es_profile) { profile.api = glfeatures::API_GLES; } else { profile.api = glfeatures::API_GL; profile.core = core_profile; profile.forwardCompatible = forward_compatible; } profile.major = major_version; profile.minor = minor_version; return profile; }
//----------------------------------------------------------------------- void OldMaterialReader::parseScript(DataStreamPtr& stream) { String line; MaterialPtr pMat; char tempBuf[512]; while(!stream->eof()) { line = stream->getLine(); // Ignore comments & blanks if (!(line.length() == 0 || line.substr(0,2) == "//")) { if (pMat.isNull()) { // No current material // So first valid data should be a material name pMat = MaterialManager::getSingleton().create(line, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // Skip to and over next { stream->readLine(tempBuf, 511, "{"); } else { // Already in a material if (line == "}") { // Finished material pMat.setNull(); } else if (line == "{") { // new pass parseNewTextureLayer(stream, pMat); } else { // Attribute StringUtil::toLowerCase(line); parseAttrib(line, pMat); } } } } }
//--------------------------------------------------------------------- void OverlayManager::parseScript(DataStreamPtr& stream, const String& groupName) { // check if we've seen this script before (can happen if included // multiple times) if (!stream->getName().empty() && mLoadedScripts.find(stream->getName()) != mLoadedScripts.end()) { LogManager::getSingleton().logMessage( "Skipping loading overlay include: '" + stream->getName() + " as it is already loaded."); return; } String line; Overlay* pOverlay = 0; bool skipLine; while(!stream->eof()) { bool isATemplate = false; skipLine = false; line = stream->getLine(); // Ignore comments & blanks if (!(line.length() == 0 || line.substr(0,2) == "//")) { if (line.substr(0,8) == "#include") { vector<String>::type params = StringUtil::split(line, "\t\n ()<>"); DataStreamPtr includeStream = ResourceGroupManager::getSingleton().openResource( params[1], groupName); parseScript(includeStream, groupName); continue; } if (!pOverlay) { // No current overlay // check to see if there is a template if (line.substr(0,8) == "template") { isATemplate = true; } else { // So first valid data should be overlay name if (StringUtil::startsWith(line, "overlay ")) { // chop off the 'particle_system ' needed by new compilers line = line.substr(8); } pOverlay = create(line); pOverlay->_notifyOrigin(stream->getName()); // Skip to and over next { skipToNextOpenBrace(stream); skipLine = true; } } if ((pOverlay && !skipLine) || isATemplate) { // Already in overlay vector<String>::type params = StringUtil::split(line, "\t\n ()"); if (line == "}") { // Finished overlay pOverlay = 0; } else if (parseChildren(stream,line, pOverlay, isATemplate, NULL)) { } else { // Attribute if (!isATemplate) { parseAttrib(line, pOverlay); } } } } } // record as parsed mLoadedScripts.insert(stream->getName()); }
//----------------------------------------------------------------------- void ParticleSystemManager::parseScript(DataStreamPtr& stream, const String& groupName) { #if OGRE_USE_NEW_COMPILERS == 1 ScriptCompilerManager::getSingleton().parseScript(stream, groupName); #else // OGRE_USE_NEW_COMPILERS String line; ParticleSystem* pSys; std::vector<String> vecparams; pSys = 0; while(!stream->eof()) { line = stream->getLine(); // Ignore comments & blanks if (!(line.length() == 0 || line.substr(0,2) == "//")) { if (pSys == 0) { // No current system // So first valid data should be a system name if (StringUtil::startsWith(line, "particle_system ")) { // chop off the 'particle_system ' needed by new compilers line = line.substr(16); } pSys = createTemplate(line, groupName); pSys->_notifyOrigin(stream->getName()); // Skip to and over next { skipToNextOpenBrace(stream); } else { // Already in a system if (line == "}") { // Finished system pSys = 0; } else if (line.substr(0,7) == "emitter") { // new emitter // Get typename vecparams = StringUtil::split(line, "\t "); if (vecparams.size() < 2) { // Oops, bad emitter LogManager::getSingleton().logMessage("Bad particle system emitter line: '" + line + "' in " + pSys->getName()); skipToNextCloseBrace(stream); } skipToNextOpenBrace(stream); parseNewEmitter(vecparams[1], stream, pSys); } else if (line.substr(0,8) == "affector") { // new affector // Get typename vecparams = StringUtil::split(line, "\t "); if (vecparams.size() < 2) { // Oops, bad affector LogManager::getSingleton().logMessage("Bad particle system affector line: '" + line + "' in " + pSys->getName()); skipToNextCloseBrace(stream); } skipToNextOpenBrace(stream); parseNewAffector(vecparams[1],stream, pSys); } else { // Attribute parseAttrib(line, pSys); } } } } #endif // OGRE_USE_NEW_COMPILERS }