Skip to content

Commit

Permalink
Add textures to renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyDaSilva committed Feb 18, 2016
1 parent 4bdd53e commit e715d50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Model::get_bounding_box(aiVector3D* min, aiVector3D* max) const
}

void
Model::recursive_render(const struct aiScene *sc, const aiNode* nd) const
Model::recursive_render(const struct aiScene *sc, const aiNode* nd, int j) const
{
int i;
unsigned int n = 0, t;
Expand All @@ -199,10 +199,11 @@ Model::recursive_render(const struct aiScene *sc, const aiNode* nd) const
// draw all meshes assigned to this node
for (; n < nd->mNumMeshes; ++n)
{
glEnable(GL_TEXTURE_2D);
const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];

if (n < texturesAndPaths.size())
glBindTexture(GL_TEXTURE_2D, texturesAndPaths[n].hTexture);
glBindTexture(GL_TEXTURE_2D, texturesAndPaths[j].hTexture);

apply_material(sc->mMaterials[mesh->mMaterialIndex]);

Expand Down Expand Up @@ -257,15 +258,15 @@ Model::recursive_render(const struct aiScene *sc, const aiNode* nd) const

// draw all children
for (n = 0; n < nd->mNumChildren; ++n)
recursive_render(sc, nd->mChildren[n]);
recursive_render(sc, nd->mChildren[n],n);

glPopMatrix();
}

void
Model::Draw() const
{
recursive_render(scene, scene->mRootNode);
recursive_render(scene, scene->mRootNode, 0);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Model
void
recursiveTextureLoad(const struct aiScene *sc, const struct aiNode* nd);
void
recursive_render(const struct aiScene *sc, const struct aiNode* nd) const;
recursive_render(const struct aiScene *sc, const struct aiNode* nd, const int j) const;

void
get_bounding_box_for_node(const aiNode* nd, aiVector3D* min, aiVector3D* max, aiMatrix4x4* trafo) const;
Expand Down

0 comments on commit e715d50

Please sign in to comment.