本文整理汇总了C++中TextureLoader类的典型用法代码示例。如果您正苦于以下问题:C++ TextureLoader类的具体用法?C++ TextureLoader怎么用?C++ TextureLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: InitializeSkydomeShaders
void Skydome::InitializeSkydomeShaders() {
TextureLoader textureLoader;
glTexture daySky, nightSky, redSky, sun, sunMask;
textureLoader.LoadTextureFromDisk("assets/textures/sky/clouds2.tga", &daySky);
textureLoader.LoadTextureFromDisk("assets/textures/sky/night.tga", &nightSky);
textureLoader.LoadTextureFromDisk("assets/textures/sky/red.tga", &redSky);
/*
//Vertext Shader profile
vsSkydomeProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
//Set profile
cgGLSetOptimalOptions(vsFireballProfile);
CheckForCgError("skydome", "selecting vertex profile");
//Load vertex shader
vsFireballProgram = cgCreateProgramFromFile(ShaderContext, CG_SOURCE, "assets/vertexshaders/vs_fireball.cg", vsFireballProfile, "vertMain", 0);
CheckForCgError("skydome", "creating vertex program from file");
cgGLLoadProgram(vsFireballProgram);
CheckForCgError("skydome", "loading vertex program");
texVert = cgGetNamedParameter(vsFireballProgram, "texCoordIN");
position = cgGetNamedParameter(vsFireballProgram, "posIN");
move = cgGetNamedParameter(vsFireballProgram, "move");
mvMatrix = cgGetNamedParameter(vsFireballProgram, "ModelViewProj");
*/
/////////////////////////////
//Pixel Shader
psSkydomeProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLSetOptimalOptions(psSkydomeProfile);
CheckForCgError("skydome", "selecting Skydome fragment profile");
psSkydomeProgram = cgCreateProgramFromFile(ShaderContext, CG_SOURCE, "assets/pixelshaders/ps_skydome.cg", psSkydomeProfile, "pixelMain", 0);
CheckForCgError("skydome", "creating fragment program from file");
cgGLLoadProgram(psSkydomeProgram);
CheckForCgError("skydome", "loading fragment program");
texcoord0 = cgGetNamedParameter(psSkydomeProgram, "texcoord0");
dayTime = cgGetNamedParameter(psSkydomeProgram, "lightdist");
transition = cgGetNamedParameter(psSkydomeProgram, "transition");
text1 = cgGetNamedParameter(psSkydomeProgram, "text1");
cgGLSetTextureParameter(text1, daySky.TextureID);
text2 = cgGetNamedParameter(psSkydomeProgram, "text2");
cgGLSetTextureParameter(text2, nightSky.TextureID);
text3 = cgGetNamedParameter(psSkydomeProgram, "text3");
cgGLSetTextureParameter(text3, redSky.TextureID);
CheckForCgError("skydome", "setting decal 2D texture");
textureLoader.LoadTextureFromDisk("assets/textures/sky/sun.tga", &sun);
textureLoader.LoadTextureFromDisk("assets/textures/sky/sunmask.tga", &sunMask);
psSkydomeSunProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLSetOptimalOptions(psSkydomeSunProfile);
CheckForCgError("skydome", "selecting Skydome sun fragment profile");
psSkydomeSunProgram = cgCreateProgramFromFile(ShaderContext, CG_SOURCE, "assets/pixelshaders/ps_skydomeSun.cg", psSkydomeSunProfile, "pixelMain", 0);
CheckForCgError("skydome", "creating fragment program from file");
cgGLLoadProgram(psSkydomeSunProgram);
CheckForCgError("skydome", "loading fragment program");
texcoord0 = cgGetNamedParameter(psSkydomeSunProgram, "texcoord0");
suntext1 = cgGetNamedParameter(psSkydomeSunProgram, "text1");
cgGLSetTextureParameter(suntext1, sun.TextureID);
suntext2 = cgGetNamedParameter(psSkydomeSunProgram, "text2");
cgGLSetTextureParameter(suntext2, sunMask.TextureID);
CheckForCgError("skydome", "setting decal 2D texture");
//Temporarily Unbind Texture
//glDisable(GL_TEXTURE_2D);
//glDisable(GL_BLEND); // Disable Blending
//glBindTexture(GL_TEXTURE_2D,0);
}
开发者ID:danielellis,项目名称:Sandblaster,代码行数:78,代码来源:Skydome.cpp
示例17: main
int main()
{
InitGlfw initGlfw;
ShaderLoader shaderLoader;
TextureLoader textureLoader;
TextRenderer textRenderer;
// Init
initGlfw.Init();
textRenderer.Init();
glfwSetKeyCallback(initGlfw.window, KeyCallback);
glfwSetMouseButtonCallback(initGlfw.window, MouseButtonCallback);
glfwSetCursorPosCallback(initGlfw.window, MouseMoveCallback);
// Shader loading
GLuint defaultShaderProgram;
GLuint textShaderProgram;
GLuint simpleShaderProgram;
defaultShaderProgram = shaderLoader.CreateProgram("Shaders\\vertex_shader.glsl", "Shaders\\fragment_shader.glsl");
textShaderProgram = shaderLoader.CreateProgram("Shaders\\text_vs.glsl", "Shaders\\text_fs.glsl");
simpleShaderProgram = shaderLoader.CreateProgram("Shaders\\simple_vertex_shader.glsl", "Shaders\\simple_fragment_shader.glsl");
// Load texture
GLuint texture = textureLoader.LoadRGB("Images\\container.jpg");
GLuint blankTexture = textureLoader.LoadBlank();
cout << "Blank texture status: " << blankTexture << endl;
// Define camera component vectors
float wallDistanceMargin = 0.2f;
float currentX;
float currentZ;
glm::vec3 cameraPos = glm::vec3(0.0f, -0.5f, 6.0f);
glm::vec3 cameraFront = glm::vec3(0.0f, 0.0f, -1.0f);
glm::vec3 cameraUp = glm::vec3(0.0f, 1.0f, 0.0f);
float yaw = -90.0f;
glm::vec3 front(cos(glm::radians(yaw)), 0.0f, sin(glm::radians(yaw)));
// Define model and view matrices and get shader locations
GLuint modelLocation = glGetUniformLocation(defaultShaderProgram, "model");
GLuint viewLocation = glGetUniformLocation(defaultShaderProgram, "view");
GLuint projectionLocation = glGetUniformLocation(defaultShaderProgram, "projection");
double currentTime = glfwGetTime();
double delta;
glm::mat4 view;
glm::mat4 proj1;
glm::mat4 idm = glm::mat4();
// Hard-coded virtual environment
Square backWall;
Square leftWall;
Square rightWall;
Square floorSquare;
Square frontWall;
Square rewardZone;
float corridorDepth = 10.0f;
float corridorWidth = 3.0f;
float wallHeight = 2.0f;
float rewardZoneDepth = 2.0f;
float rewardZonePosition = -3.0f;
float rewardZoneLowZ = rewardZonePosition - rewardZoneDepth;
float rewardZoneHighZ = rewardZonePosition + rewardZoneDepth;
bool inRewardZone = false;
backWall.SetColor(0.5f, 0.5f, 0.9f);
backWall.SetScaling(corridorWidth, wallHeight);
backWall.SetPosition(0.0f, wallHeight/2, -corridorDepth);
frontWall.SetColor(0.5f, 0.5f, 0.9f);
frontWall.SetScaling(corridorWidth, wallHeight);
frontWall.SetPosition(0.0f, wallHeight / 2.0f, corridorDepth);
leftWall.SetColor(0.5f, 0.9f, 0.5f);
leftWall.SetScaling(corridorDepth, wallHeight);
leftWall.SetRotation(0.0f, 90.0f, 0.0f);
leftWall.SetPosition(-corridorWidth, wallHeight/2, 0.0f);
rightWall.SetColor(0.5f, 0.9f, 0.5f);
rightWall.SetScaling(corridorDepth, wallHeight);
rightWall.SetRotation(0.0f, 90.0f, 0.0f);
rightWall.SetPosition(corridorWidth,wallHeight/2, 0.0f);
floorSquare.SetColor(0.1f, 0.1f, 0.1f);
floorSquare.SetScaling(corridorWidth, corridorDepth);
floorSquare.SetRotation(-90.0f, 0.0f, 0.0f);
floorSquare.SetPosition(0.0f, -wallHeight/2.0f, 0.0f);
rewardZone.SetColor(0.2f, 0.9f, 0.2f);
rewardZone.SetScaling(corridorWidth, rewardZoneDepth);
rewardZone.SetRotation(-90.0f, 0.0f, 0.0f);
rewardZone.SetPosition(0.0f, -wallHeight / 2.0f + 0.01f, rewardZonePosition);
proj1 = glm::perspective(45.0f, (float)2.0f*initGlfw.windowInfo.width / initGlfw.windowInfo.height, 0.1f, 100.0f);
glEnable(GL_DEPTH_TEST);
//.........这里部分代码省略.........
开发者ID:benvermaercke,项目名称:Virtual-reality,代码行数:101,代码来源:main.cpp
示例18: glMatrixMode
void LayerNode::Apply(IRenderingView *rv) {
glMatrixMode(GL_PROJECTION); // Select Projection
glPushMatrix(); // Push The Matrix
glLoadIdentity(); // Reset The Matrix
glOrtho( 0, w , h , 0, -1, 1 ); // Select Ortho Mode
glMatrixMode(GL_MODELVIEW); // Select Modelview Matrix
glPushMatrix(); // Push The Matrix
glLoadIdentity(); // Reset The Matrix
// Render HUD
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
GLboolean l = glIsEnabled(GL_LIGHTING);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for(std::list<Layer>::iterator itr = layers.begin();
itr != layers.end();
itr++) {
ITextureResourcePtr texr = itr->texr;
float width = texr->GetWidth();
float height = texr->GetHeight();
float x = itr->origin[0];
float y = itr->origin[1];
if (texr != NULL) {
if (texr->GetID() == 0) {
TextureLoader* tl = new TextureLoader();
tl->LoadTextureResource(texr);
}
glBindTexture(GL_TEXTURE_2D, texr->GetID());
} else {
glBindTexture(GL_TEXTURE_2D, 0);
}
glColor3f(1,1,1);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(x,y,0);
glTexCoord2f(0,1);
glVertex3f(x,y+height,0);
glTexCoord2f(1,1);
glVertex3f(x+width,y+height,0);
glTexCoord2f(1,0);
glVertex3f(x+width,y,0);
glEnd();
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
if (l)
glEnable(GL_LIGHTING);
// Reset state
glMatrixMode( GL_PROJECTION ); // Select Projection
glPopMatrix(); // Pop The Matrix
glMatrixMode( GL_MODELVIEW ); // Select Modelview
glPopMatrix(); // Pop The Matrix
}
开发者ID:OpenEngineDK,项目名称:extensions-OEGUI,代码行数:79,代码来源:LayerNode.cpp
示例19: fileStream
Model DuckLoader::loadDuckModel() {
vector<Vertex> vertices;
vector<GLuint> indices;
string filepath = "res/models/duck/duck.txt";
ifstream fileStream(filepath);
if(!fileStream){
throw new invalid_argument("No such duck file");
}
string line;
getline(fileStream, line);
int vertexCount = stoi(line);
for(int i = 0; i < vertexCount; i++){
getline(fileStream, line);
vector<string> vertexStr = splitString(line, " ");
if(vertexStr.size() != 8){
throw new invalid_argument("No such duck file");
}
vec3 pos = vec3(atof(vertexStr[0].c_str()),
atof(vertexStr[1].c_str()),
atof(vertexStr[2].c_str()));
vec3 norm = vec3(atof(vertexStr[3].c_str()),
atof(vertexStr[4].c_str()),
atof(vertexStr[5].c_str()));
vec2 tex = vec2(atof(vertexStr[6].c_str()),
atof(vertexStr[7].c_str()));
Vertex vertex;
vertex.Position = pos;
vertex.Normal = norm;
vertex.TexCoords = tex;
vertices.push_back(vertex);
}
getline(fileStream, line);
int indexCount = stoi(line);
for(int i = 0; i < indexCount; i++){
getline(fileStream, line);
vector<string> indexStr = splitString(line, " ");
GLuint i1 = stoi(indexStr[0]);
GLuint i2 = stoi(indexStr[1]);
GLuint i3 = stoi(indexStr[2]);
indices.push_back(i1);
indices.push_back(i2);
indices.push_back(i3);
}
TextureLoader textureLoader;
string texturePath = "res/models/duck/ducktex.jpg";
Texture texture = textureLoader.loadTexture(texturePath,
TextureTypes::DIFFUSE);
Texture textureSpec = textureLoader.loadTexture(texturePath,
TextureTypes::SPECULAR);
vector<Texture> textures = {texture, textureSpec};
Material material;
material.shininess = 32.0f;
Mesh mesh(vertices, indices, textures);
mesh.setMaterial(material);
vector<Mesh> meshes = {mesh};
Model model (meshes);
return model;
}
开发者ID:Jakub-Ciecierski,项目名称:DuckIFX,代码行数:68,代码来源:duck_loader.cpp
示例20: fprintf
//The main function
int Main::start() {
//Init
if (init() == -1) {
fprintf(stderr, "Could not initialise the program\n");
return -1;
}
//Create the scene
Scene scene = Scene(window);
Camera* camera = scene.getCamera();
camera->setFOV(45);
//Create the loaders
ModelLoader loader = ModelLoader();
TextureLoader textureLoader = TextureLoader();
//Create the models
Model texturedModel = loader.loadToVao_OBJ_Textured("models/cube.obj", "textures/cube.bmp", glm::vec3(-3, 0, -5));
Model monkey = loader.loadToVao_OBJ("models/suzanne.obj", glm::vec3(0, 0, -5));
monkey.texture(textureLoader.loadBMP_custom("textures/suzanne texture.bmp"));
monkey.setReflectivity(0.0);
//Create an array of the same entities and add them to the scene
std::vector<Entity> cubes;
std::vector<glm::vec3> positions;
int numOfCubes = 1000;
Cube cubeTemp = Cube();
//Create the positions array
for (int i = 0; i < numOfCubes; i++) {
positions.insert(positions.end(), glm::vec3(rand() % 100, rand() % 100, rand() % 100));
}
//Generate cloned cubes and put them at different positions
cubes = cubeTemp.cloneEntity(positions);
//Add the cubes to the entity map
for (int i = 0; i < cubes.size(); i++) {
scene.addEntity(&cubes[i]);
}
//Add the models to the scene
scene.addModel(texturedModel);
scene.addModel(monkey);
//Create the onclick function
auto onClick = []() {
exit(0);
};
//Create the UIs
UIButton button = UIButton(0.06f, 0.05f, glm::vec2(1, -1), window, onClick);
button.setAlignment(UIButton::ALIGN_BOTTOM_RIGHT);
button.texture(textureLoader.loadBMP_custom("textures/Exit.bmp"));
UIElement* ui = &button;
//Add the UI
scene.addPauseUI(ui);
//Main loop
while (!window.shouldClose()) {
//Run the scene
scene.run();
//Run the UI
//Swap the buffers and poll events
glfwSwapBuffers(window.getWindow());
glfwPollEvents();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
//Terminate glfw
glfwTerminate();
return 0;
}
开发者ID:imitablerabbit,项目名称:opengl-3d-engine,代码行数:80,代码来源:Main.cpp
注:本文中的TextureLoader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论