Exemplo n.º 1
0
bool ShaderData::load()
{
	unload();
	qDebug() << "+" << this << "ShaderData" << uid();

	mProgram = new QGLShaderProgram( mGLWidget );
	mProgram->addShaderFromSourceFile( QGLShader::Vertex, baseDirectory()+mName+".vert" );
	mProgram->addShaderFromSourceFile( QGLShader::Fragment, baseDirectory()+mName+".frag" );
	if( !mProgram->link() )
	{
		qWarning() << mProgram->log();
		return false;
	}

	return AResourceData::load();
}
Exemplo n.º 2
0
void SourceTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList)
{
    if (!itemList.isEmpty()) {
        m_formEditorItem = itemList.first();
        m_oldFileName =  m_formEditorItem.data()->qmlItemNode().modelValue("source").toString();

        QString openDirectory = baseDirectory(view()->model()->fileUrl());
        if (openDirectory.isEmpty())
            openDirectory = baseDirectory(view()->model()->fileUrl());

        QString fileName = QFileDialog::getOpenFileName(0,
                                                       tr("Open File"),
                                                       openDirectory);
        fileSelected(fileName);

    } else {
        view()->changeToSelectionTool();
    }
}
Exemplo n.º 3
0
static void load_system_fonts() {
    // check if we've already be called
    if (NULL != gDefaultNormal) {
        return;
    }

    SkString baseDirectory(SK_FONT_FILE_PREFIX);
    unsigned int count = 0;
    load_directory_fonts(baseDirectory, &count);

    if (0 == count) {
        SkNEW(EmptyTypeface);
    }

    // do this after all fonts are loaded. This is our default font, and it
    // acts as a sentinel so we only execute load_system_fonts() once
    static const char* gDefaultNames[] = {
#if defined(__LB_SHELL__)
        "Droid Sans",  // our preferred default
#endif
        "Arial", "Verdana", "Times New Roman", NULL
    };
    const char** names = gDefaultNames;
    while (*names) {
        SkTypeface* tf = find_typeface(*names++, SkTypeface::kNormal);
        if (tf) {
            gDefaultNormal = tf;
            break;
        }
    }
    // check if we found *something*
    if (NULL == gDefaultNormal) {
        if (NULL == gFamilyHead) {
            sk_throw();
        }
        for (int i = 0; i < 4; i++) {
            if ((gDefaultNormal = gFamilyHead->fFaces[i]) != NULL) {
                break;
            }
        }
    }
    if (NULL == gDefaultNormal) {
        sk_throw();
    }
    gFallBackTypeface = gDefaultNormal;
    gDefaultFamily = find_family(gDefaultNormal);
}
Exemplo n.º 4
0
QString QgsWFSUtils::getCacheDirectory( bool createIfNotExisting )
{
  QString baseDirectory( getBaseCacheDirectory( createIfNotExisting ) );
  QString processPath( QStringLiteral( "pid_%1" ).arg( QCoreApplication::applicationPid() ) );
  if ( createIfNotExisting )
  {
    QMutexLocker locker( &sMutex );
    if ( !QDir( baseDirectory ).exists( processPath ) )
    {
      QgsDebugMsg( QString( "Creating our cache dir %1/%2" ).arg( baseDirectory, processPath ) );
      QDir( baseDirectory ).mkpath( processPath );
    }
    if ( sCounter == 0 && sKeepAliveWorks )
    {
      sThread = new QgsWFSUtilsKeepAlive();
      sThread->start();
    }
    sCounter ++;
  }
  return QDir( baseDirectory ).filePath( processPath );
}
Exemplo n.º 5
0
void EntityClassQuake3_Construct()
{
  StringOutputStream baseDirectory(256);
  StringOutputStream gameDirectory(256);
  const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue("basegame");
  const char* gamename = GlobalRadiant().getGameName();
  baseDirectory << GlobalRadiant().getGameToolsPath() << basegame << '/';
  gameDirectory << GlobalRadiant().getGameToolsPath() << gamename << '/';

  class LoadEntityDefinitionsVisitor : public EClassModules::Visitor
  {
    const char* baseDirectory;
    const char* gameDirectory;
  public:
    LoadEntityDefinitionsVisitor(const char* baseDirectory, const char* gameDirectory)
      : baseDirectory(baseDirectory), gameDirectory(gameDirectory)
    {
    }
    void visit(const char* name, const EntityClassScanner& table) const
    {
      Paths paths;
      EntityClassQuake3_constructDirectory(baseDirectory, table.getExtension(), paths);
      if(!string_equal(baseDirectory, gameDirectory))
      {
        EntityClassQuake3_constructDirectory(gameDirectory, table.getExtension(), paths);
      }

      for(Paths::iterator i = paths.begin(); i != paths.end(); ++i)
      {
        EntityClassesLoadFile(table, (*i).second)((*i).first.c_str());
      }
    }
  };

  EntityClassManager_getEClassModules().foreachModule(LoadEntityDefinitionsVisitor(baseDirectory.c_str(), gameDirectory.c_str()));
}
Exemplo n.º 6
0
bool MaterialData::load()
{
	unload();
	qDebug() << "+" << this << "MaterialData" << uid();

	if( !QFile::exists( baseDirectory()+mName+"/material.ini" ) )
	{
		qCritical() << "!!" << this << "MaterialData" << uid() << "Could not find " << (baseDirectory()+mName+"/material.ini");
		return false;
	}

	QSettings s( baseDirectory()+mName+"/material.ini", QSettings::IniFormat );

	GLint wrapS;
	GLint wrapT;
	bool mipmap;

	s.beginGroup( "Param" );
	{
		wrapS = glGetTextureWrapFromString( s.value( "wrapS", "GL_REPEAT" ).toString() );
		wrapT = glGetTextureWrapFromString( s.value( "wrapT", "GL_REPEAT" ).toString() );
		mipmap = s.value( "mipmap", true ).toBool();
	}
	s.endGroup();

	s.beginGroup( "Textures" );
	{
		QStringList textures = s.allKeys();
		for( QStringList::const_iterator i = textures.constBegin(); i != textures.constEnd(); ++i )
		{
			QString mapPath = baseDirectory()+mName+'/' + s.value( (*i) ).toString();
			QImage map = QImage( mapPath );
			if( map.isNull() )
			{
				qFatal(
					"Texture \"%s\" from file \"%s\" could not be loaded!",
					(*i).toLocal8Bit().constData(),
					mapPath.toLocal8Bit().constData()
				);
			}
			QGLContext::BindOptions options = QGLContext::InvertedYBindOption | QGLContext::LinearFilteringBindOption;
			if( mipmap )
				options |= QGLContext::MipmapBindOption;
			GLuint texture =  mGLWidget->bindTexture( map, GL_TEXTURE_2D, GL_RGBA, options );
			glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Material::filterAnisotropy() );
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS );
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT );
			mTextures[(*i)] = texture;
		}
	}
	s.endGroup();

	s.beginGroup( "Constants" );
	{
		QStringList constants = s.allKeys();
		QStringList::const_iterator i;
		for( i = constants.constBegin(); i != constants.constEnd(); ++i )
		{
			mConstants[(*i)] = s.value( (*i) ).toFloat();
		}
	}
	s.endGroup();

	s.beginGroup( "Model" );
	{
		mAmbient = QVector4D(
			s.value( "ambientRed", 0.2f ).toFloat(),
			s.value( "ambientGreen", 0.2f ).toFloat(),
			s.value( "ambientBlue", 0.2f ).toFloat(),
			s.value( "ambientAlpha", 1.0f ).toFloat()
		);
		mDiffuse = QVector4D(
			s.value( "diffuseRed", 0.8f ).toFloat(),
			s.value( "diffuseGreen", 0.8f ).toFloat(),
			s.value( "diffuseBlue", 0.8f ).toFloat(),
			s.value( "diffuseAlpha", 1.0f ).toFloat()
		);
		mSpecular = QVector4D(
			s.value( "specularRed", 0.0f ).toFloat(),
			s.value( "specularGreen", 0.0f ).toFloat(),
			s.value( "specularBlue", 0.0f ).toFloat(),
			s.value( "specularAlpha", 1.0f ).toFloat()
		);
		mEmission = QVector4D(
			s.value( "emissionRed", 0.0f ).toFloat(),
			s.value( "emissionGreen", 0.0f ).toFloat(),
			s.value( "emissionBlue", 0.0f ).toFloat(),
			s.value( "emissionAlpha", 1.0f ).toFloat()
		);
		mShininess = s.value( "shininess", 0 ).toFloat();
	}
	s.endGroup();

	s.beginGroup( "AlphaTest" );
	{
		mAlphaTestEnabled = s.value( "enable", false ).toBool();
		mAlphaTestFunction = glGetAlphaTestFunctionFromString( s.value( "function", "GL_ALWAYS" ).toString() );
		mAlphaTestReferenceValue = s.value( "referenceValue", 0.0f ).toFloat();
	}
	s.endGroup();

	s.beginGroup( "Shader" );
	{
		mShaderNames[MaterialQuality::LOW] = s.value( "low", "simple" ).toString();
		mShaderNames[MaterialQuality::MEDIUM] = s.value( "medium", "simple" ).toString();
		mShaderNames[MaterialQuality::HIGH] = s.value( "high", "simple" ).toString();
	}
	s.endGroup();

	return AResourceData::load();
}