当前位置: 首页>>代码示例>>C++>>正文


C++ TextureLoader类代码示例

本文整理汇总了C++中TextureLoader的典型用法代码示例。如果您正苦于以下问题:C++ TextureLoader类的具体用法?C++ TextureLoader怎么用?C++ TextureLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TextureLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: string

vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial* mat,
                                                  aiTextureType type,
                                                  TextureTypes texType) {
    TextureLoader textureLoader;

    vector<Texture> textures;
    for(GLuint i = 0; i < mat->GetTextureCount(type); i++) {
        aiString str;
        mat->GetTexture(type, i, &str);
        GLboolean skip = false;
        for(GLuint j = 0; j < textureCache.size(); j++) {
            if(textureCache[j].path == string(str.C_Str()))
            {
                textures.push_back(textureCache[j]);
                skip = true;
                break;
            }
        }
        if(!skip) {
            std::string filepath = directory + '/' + string(str.C_Str());
            Texture texture = textureLoader.loadTexture(filepath,
                                                        texType);
            texture.path = string(str.C_Str());
            textures.push_back(texture);
            this->textureCache.push_back(texture);
        }
    }
    return textures;
}
开发者ID:Jakub-Ciecierski,项目名称:DuckIFX,代码行数:29,代码来源:model_loader.cpp

示例2: loadTextureHost

      dp::sg::core::TextureHostSharedPtr loadTextureHost( const std::string & filename, const std::vector<std::string> &searchPaths )
      {
        dp::sg::core::TextureHostSharedPtr tih;
        // appropriate search paths for the loader dll and the sample file.
        vector<string> binSearchPaths = searchPaths;

        std::string curDir = dp::util::getCurrentPath();
        if ( find( binSearchPaths.begin(), binSearchPaths.end(), curDir ) == binSearchPaths.end() )
        {
          binSearchPaths.push_back(curDir);
        }

        std::string modulePath = dp::util::getModulePath();
        if ( find( binSearchPaths.begin(), binSearchPaths.end(), modulePath ) == binSearchPaths.end() )
        {
          binSearchPaths.push_back(modulePath);
        }

        std::string ext = dp::util::getFileExtension( filename );

        dp::util::UPIID piid = dp::util::UPIID( ext.c_str(), dp::util::UPITID(UPITID_TEXTURE_LOADER, UPITID_VERSION) );

        dp::util::PlugIn * plug = 0;

        // TODO - Update me for stereo images
        TextureLoader * tls;
        if ( getInterface( binSearchPaths, piid, plug ) && dp::util::fileExists( filename ) )
        {
          tls = reinterpret_cast<TextureLoader *>(plug);
          tih = tls->load( filename );
        }
        return tih;
      }
开发者ID:mtavenrath,项目名称:pipeline,代码行数:33,代码来源:IO.cpp

示例3: Invoke

void Bitmap::Invoke(const Event &event)
{
    if (event.type == Event::COMPLETE)
    {
        TextureLoader* loader = (TextureLoader*)(event.target);
        cache[source_path] = source = loader->getTexture();
        inner_size.x = source->width();
        inner_size.y = source->height();
        loader->removeEventListener(this);
        loader->deleteLater();
    }
}
开发者ID:khovanskiy,项目名称:Rush,代码行数:12,代码来源:bitmap.cpp

示例4: texturize

    /**
     * Overwrites the texturize method for the pane
     */
    void Pane::texturize(std::string textureName){
		TextureLoader* textureLoader = TextureLoader::getInstance();
        GLuint textureId = textureLoader->getTextureId(textureName);

        glEnable(GL_TEXTURE_2D);
 		glBindTexture(GL_TEXTURE_2D, textureId);
 		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	}
开发者ID:MaliusArth,项目名称:CSE,代码行数:16,代码来源:pane.cpp

示例5: DrawBackground

void Background::DrawBackground() const {
    TextureLoader* textureLoader = TextureLoader::Instance();
    int texBackground = textureLoader->Load("stars.png");

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texBackground);
    glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f);
        glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, -1.0f);
        glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f);
        glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, 1.0f);
    glEnd();
    glDisable(GL_TEXTURE_2D);
}
开发者ID:Kr0oked,项目名称:SpaceInvadersVisualStudio,代码行数:15,代码来源:Background.cpp

示例6: GetSetting

//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectImplemented::UnloadResources()
{
	Setting* loader = GetSetting();
	
	TextureLoader* textureLoader = loader->GetTextureLoader();
	if( textureLoader != NULL )
	{
		for( int32_t ind = 0; ind < m_ImageCount; ind++ )
		{
			textureLoader->Unload( m_pImages[ind] );
			m_pImages[ind] = NULL;
		}

		for (int32_t ind = 0; ind < m_normalImageCount; ind++)
		{
			textureLoader->Unload(m_normalImages[ind]);
			m_normalImages[ind] = NULL;
		}

		for (int32_t ind = 0; ind < m_distortionImageCount; ind++)
		{
			textureLoader->Unload(m_distortionImages[ind]);
			m_distortionImages[ind] = NULL;
		}
	}

	SoundLoader* soundLoader = loader->GetSoundLoader();
	if( soundLoader != NULL )
	{
		for( int32_t ind = 0; ind < m_WaveCount; ind++ )
		{
			soundLoader->Unload( m_pWaves[ind] );
			m_pWaves[ind] = NULL;
		}
	}

	{
		ModelLoader* modelLoader = loader->GetModelLoader();
		if( modelLoader != NULL )
		{
			for( int32_t ind = 0; ind < m_modelCount; ind++ )
			{
				modelLoader->Unload( m_pModels[ind] );
				m_pModels[ind] = NULL;
			}
		}
	}
}
开发者ID:ariessanchezsulit,项目名称:Effekseer,代码行数:51,代码来源:Effekseer.Effect.cpp

示例7: Camera

void GameContextDemo::init() {
    angle = 0;
    camera = new Camera(0,0,-200,0);
   	// reset model position
	TextureLoader loader;
	loader.loadFile("images/man.jpg");
	unsigned char * rawData = loader.getData();
    	glEnable(GL_TEXTURE_2D);
    	glEnable(GL_BLEND);
    	glBlendFunc(GL_ONE, GL_SRC_COLOR);

	glBindTexture(GL_TEXTURE_2D, texture);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, rawData);

	texCoords = new GLfloat[8];
	texCoords[0] = 0.0;
	texCoords[1] = 1.0;
	texCoords[2] = 1.0;
	texCoords[3] = 1.0;
	texCoords[4] = 0.0;
	texCoords[5] = 0.0;
	texCoords[6] = 1.0;
	texCoords[7] = 0.0;

	mVertices = new signed short[12];
	mVertices[0] = -80;
	mVertices[1] = -80;
	mVertices[2] = 0;
    	mVertices[3] = 80;
	mVertices[4] = -80;
	mVertices[5] = 0;
	mVertices[6] = -80;
	mVertices[7] = 80;
	mVertices[8] = 0;
	mVertices[9] = 80;
	mVertices[10] = 80;
	mVertices[11] = 0;

    	glEnableClientState(GL_VERTEX_ARRAY);
    	glVertexPointer(3, GL_SHORT, 0, mVertices);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glPointSize(4);
}
开发者ID:julitopower,项目名称:NewOpenGlTest,代码行数:46,代码来源:GameContextDemo.cpp

示例8:

Enemy::Enemy(TextureLoader& tl, Vector2f position)
{
	type = 'n';
	_sprite = (tl.getSprite("player"));
	_sprite.setColor(Color::Red);
	middleOrigin();
	_sprite.setPosition(position);
}
开发者ID:wnatti,项目名称:sfml-something,代码行数:8,代码来源:Enemy.cpp

示例9:

Bullet::Bullet(Vector2f pos, float rotation, TextureLoader tl, float velocity)
{
	_sprite = (tl.getSprite("bullet"));
	_sprite.setPosition(pos);
	_sprite.scale(1.5f,1.0f);
	_rotation = rotation;
	//_boundaries = _sprite.getGlobalBounds();
	_sprite.setRotation(_rotation+90);
	_velocity = velocity;
}
开发者ID:wnatti,项目名称:SFML-projekt,代码行数:10,代码来源:Bullet.cpp

示例10: string

vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial* mat,
                                                  aiTextureType type,
                                                  TextureTypes texType) {
    TextureLoader textureLoader;

    vector<Texture> textures;
    for(GLuint i = 0; i < mat->GetTextureCount(type); i++) {
        aiString str;
        mat->GetTexture(type, i, &str);
        string filename = string(str.C_Str());
/*
        // <Eagle HASK> :(
        string filenameTMP = string(str.C_Str());
        string filename = "";
        for(int i = 4; i < filenameTMP.size(); i++){
            if(filenameTMP[i] == '\\')
                filename += "/";
            else
                filename += filenameTMP[i];
        }
        // </Eagle HASK> :(
*/
        GLboolean skip = false;
        for(GLuint j = 0; j < textureCache.size(); j++) {
            if(textureCache[j].path == filename)
            {
                textures.push_back(textureCache[j]);
                skip = true;
                break;
            }
        }
        if(!skip) {
            std::string filepath = directory + '/' + filename;
            Texture texture = textureLoader.loadTexture(filepath,
                                                        texType);

            texture.path = string(str.C_Str());
            textures.push_back(texture);
            this->textureCache.push_back(texture);
        }
    }
    return textures;
}
开发者ID:Jakub-Ciecierski,项目名称:InfinityX2,代码行数:43,代码来源:model_loader.cpp

示例11: TextureLoader

void MS3D::reloadTextures()
{
    for ( int i = 0; i < m_numMaterials; i++ )
    {
        if ( strlen( m_pMaterials[i].m_pTextureFilename ) > 0 )
        {
            std::stringstream fn;
            std::string file = m_pMaterials[i].m_pTextureFilename;
            file = file.substr(0, file.length() - 4);
            fn << _path << file << ".png";
            TextureLoader *tload = new TextureLoader();
            m_pMaterials[i].m_texture = tload->LoadTexture( fn.str().c_str() );
            delete tload;
        }
        else
        {
            m_pMaterials[i].m_texture = 0;
        }
    }
}
开发者ID:GiR-Zippo,项目名称:GWAN-Engine,代码行数:20,代码来源:MS3D.cpp

示例12: loadHeightmap

void Heightmap::loadHeightmap(string filename, float strength) {
    TextureLoader tl;
    Texture t = tl.loadTexture(filename, 1);
    
    if(t.getWidth() < columns || t.getHeight() < rows) {
        cout << "The provided file " << filename << " (" << t.getWidth() << "x" << t.getHeight() << ") is too small and cannot be used for this heightmap (" << columns << "x" << rows << ")" << endl;
        return;
    }
    
    int dx = t.getWidth()/columns;
    int dy = t.getHeight()/rows;
    
    for(int row = 0; row <= rows; row++) {
        for(int column = 0; column <= columns; column++) {
            setHeightAt(column, row, (t.getData()[row * t.getWidth() * dy + column * dx] / 255.0f) * strength);
            //assert(0.0f <= getHeightAt(column, row) && getHeightAt(column, row) <= strength);
        }
    }
    
    calculateNormals();
}
开发者ID:bernhardfritz,项目名称:Bachelorarbeit,代码行数:21,代码来源:Heightmap.cpp

示例13: InitializeFreezeParticleShader

void FreezeParticle::InitializeFreezeParticleShader()
{
	TextureLoader textureLoader;
	glTexture FreezeParticleTexture;

	FreezeParticleProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
	cgGLSetOptimalOptions(FreezeParticleProfile);
	CheckForCgError("FreezeParticle", "selecting fragment profile");

	FreezeParticleProgram = cgCreateProgramFromFile(ShaderContext, CG_SOURCE, "assets/pixelshaders/ps_freezeparticle.cg", FreezeParticleProfile, "pixelMain", 0);
	CheckForCgError("FreezeParticle", "creating fragment program from file");
	cgGLLoadProgram(FreezeParticleProgram);
	CheckForCgError("FreezeParticle", "loading fragment program");

	FreezeParticleCoord0 = cgGetNamedParameter(FreezeParticleProgram, "texcoord0");

	textureLoader.LoadTextureFromDisk("assets/textures/weapon/freezeparticle.tga", &FreezeParticleTexture);
	FreezeParticleText1 = cgGetNamedParameter(FreezeParticleProgram, "text1");
	cgGLSetTextureParameter(FreezeParticleText1, FreezeParticleTexture.TextureID);
	CheckForCgError("FreezeParticle", "setting decal 2D texture");
}
开发者ID:danielellis,项目名称:Sandblaster,代码行数:21,代码来源:FreezeParticle.cpp

示例14: getSkybox

Model getSkybox(const std::vector<std::string>& skyboxTextures)
{ 
	std::vector<Vertex> vertices(36);
	for (unsigned int i = 0; i < vertices.size(); i++) {
		vertices[i].position = glm::vec3(skybox_verts[i*3], skybox_verts[i*3+1], skybox_verts[i*3+2]);
	}

	std::vector<GLuint> indexes(36);
	for (unsigned int i = 0; i < indexes.size(); i++) {
		indexes[i] = i;
	}

	std::vector<Texture> textures;
	TextureLoader textureLoader;
	Texture texture = textureLoader.loadCubemap(skyboxTextures);
	textures.push_back(texture);

	Mesh mesh(vertices, indexes);
	Material material;
	material.setTextures(textures);
	return Model(mesh, material);
}
开发者ID:Chaosed0,项目名称:OpenGLTest,代码行数:22,代码来源:Box.cpp

示例15: UnloadResources

//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectImplemented::ReloadResources( const EFK_CHAR* materialPath )
{
	UnloadResources();

	const EFK_CHAR* matPath = materialPath != NULL ? materialPath : m_materialPath.c_str();
	
	Setting* loader = GetSetting();

	{
		TextureLoader* textureLoader = loader->GetTextureLoader();
		if( textureLoader != NULL )
		{
			for( int32_t ind = 0; ind < m_ImageCount; ind++ )
			{
				EFK_CHAR fullPath[512];
				PathCombine( fullPath, matPath, m_ImagePaths[ ind ] );
				m_pImages[ind] = textureLoader->Load( fullPath, TextureType::Color );
			}
		}
	}

	{
		TextureLoader* textureLoader = loader->GetTextureLoader();
		if (textureLoader != NULL)
		{
			for (int32_t ind = 0; ind < m_normalImageCount; ind++)
			{
				EFK_CHAR fullPath[512];
				PathCombine(fullPath, matPath, m_normalImagePaths[ind]);
				m_normalImages[ind] = textureLoader->Load(fullPath, TextureType::Normal);
			}
		}

	}
		{
			TextureLoader* textureLoader = loader->GetTextureLoader();
			if (textureLoader != NULL)
			{
				for (int32_t ind = 0; ind < m_distortionImageCount; ind++)
				{
					EFK_CHAR fullPath[512];
					PathCombine(fullPath, matPath, m_distortionImagePaths[ind]);
					m_distortionImages[ind] = textureLoader->Load(fullPath, TextureType::Distortion);
				}
			}
		}

	

	{
		SoundLoader* soundLoader = loader->GetSoundLoader();
		if( soundLoader != NULL )
		{
			for( int32_t ind = 0; ind < m_WaveCount; ind++ )
			{
				EFK_CHAR fullPath[512];
				PathCombine( fullPath, matPath, m_WavePaths[ ind ] );
				m_pWaves[ind] = soundLoader->Load( fullPath );
			}
		}
	}

	{
		ModelLoader* modelLoader = loader->GetModelLoader();
		
		if( modelLoader != NULL )
		{
			for( int32_t ind = 0; ind < m_modelCount; ind++ )
			{
				EFK_CHAR fullPath[512];
				PathCombine( fullPath, matPath, m_modelPaths[ ind ] );
				m_pModels[ind] = modelLoader->Load( fullPath );
			}
		}
	}
}
开发者ID:ariessanchezsulit,项目名称:Effekseer,代码行数:79,代码来源:Effekseer.Effect.cpp


注:本文中的TextureLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。