Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
techmatt@gmail.com committed Jun 20, 2011
1 parent 21d973f commit 5d62d5d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion common/Assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ Model* Assets::GetModel(const Parameters &params, const std::string &modelName)
{
return _models[modelName];
}
Model *result = new Model(params.databaseDirectory + "models/", modelName);
Model *result = new Model(params.databaseDirectory + "models/", modelName, *this);
_models[modelName] = result;
return result;
}

GLuint Assets::GetTexture(const std::string &filename)
{
if(_textures.find(filename) != _textures.end())
{
return _textures[filename];
}
GLuint result = Utility::MakeOpenGLBitmap(filename);
_textures[filename] = result;
return result;
}
2 changes: 2 additions & 0 deletions common/Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class Assets
{
public:
Model* GetModel(const Parameters &params, const std::string &modelName);
GLuint GetTexture(const std::string &textureFilename);

private:
std::map<std::string, Model*> _models;
std::map<std::string, GLuint> _textures;
};
4 changes: 2 additions & 2 deletions common/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "Common.h"

Model::Model(const std::string &directory, const std::string &baseFilename)
Model::Model(const std::string &directory, const std::string &baseFilename, Assets &textureStore)
{
std::cout << " Loading model: " << baseFilename << '\n';

Expand Down Expand Up @@ -50,7 +50,7 @@ Model::Model(const std::string &directory, const std::string &baseFilename)
//
// Load the texture
//
activeMaterial->texture = Utility::MakeOpenGLBitmap(directory + textureName);
activeMaterial->texture = textureStore.GetTexture(directory + textureName);
}
}

Expand Down
3 changes: 2 additions & 1 deletion common/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

#include "Common.h"

class Assets;
class Model
{
public:
Model(const std::string &directory, const std::string &baseFilename);
Model(const std::string &directory, const std::string &baseFilename, Assets &textureStore);

void Render();

Expand Down

0 comments on commit 5d62d5d

Please sign in to comment.