本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
}
示例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);
}
示例8:
Enemy::Enemy(TextureLoader& tl, Vector2f position)
{
type = 'n';
_sprite = (tl.getSprite("player"));
_sprite.setColor(Color::Red);
middleOrigin();
_sprite.setPosition(position);
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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();
}
示例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");
}
示例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);
}
示例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 );
}
}
}
}