Merge branch 'master' of gitlab.com:4VRDriver/fall-fever into master
This commit is contained in:
@@ -6,6 +6,13 @@ Model::Model(const char* pathToModel) {
|
||||
loadModel(pathToModel);
|
||||
}
|
||||
|
||||
Model::~Model() {
|
||||
// Go through all loaded textures and delete them
|
||||
for(auto it = loadedTextures.begin(); it != loadedTextures.end(); it++) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
|
||||
void Model::draw(ShaderProgram *shaderProgram) {
|
||||
|
||||
// Iterate through every mesh and call the draw function
|
||||
@@ -106,20 +113,24 @@ std::vector<Texture*> Model::loadMaterialTextures(aiMaterial *mat, aiTextureType
|
||||
aiString filename;
|
||||
mat->GetTexture(type, i, &filename);
|
||||
|
||||
std::string currentPath = directory + '/' + filename.C_Str();
|
||||
|
||||
bool skip = 0;
|
||||
for(uint32_t j = 0; j < loadedTextures.size(); j++) {
|
||||
if(std::strcmp(loadedTextures[j].getPath().data(), filename.C_Str()) == 0) {
|
||||
textures.push_back(&loadedTextures[j]);
|
||||
for(uint j = 0; j < loadedTextures.size(); j++) {
|
||||
if(std::strcmp(loadedTextures[j]->getPath().c_str(), currentPath.c_str()) == 0) {
|
||||
textures.push_back(loadedTextures[j]);
|
||||
skip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!skip) {
|
||||
std::string path = directory + '/' + filename.C_Str();
|
||||
Texture texture(path.c_str(), textureType);
|
||||
textures.push_back(&texture);
|
||||
Texture *texture = new Texture(currentPath.c_str(), textureType);
|
||||
loadedTextures.push_back(texture);
|
||||
|
||||
// Add newest texture pointer to the mesh's texture vector
|
||||
Texture *new_tex = loadedTextures.back();
|
||||
textures.push_back(new_tex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class Model {
|
||||
public:
|
||||
|
||||
Model(const char* pathToModel);
|
||||
~Model() = default;
|
||||
~Model();
|
||||
|
||||
void draw(ShaderProgram *shaderProgram);
|
||||
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
|
||||
std::vector<Mesh> meshes;
|
||||
|
||||
std::vector<Texture> loadedTextures;
|
||||
std::vector<Texture*> loadedTextures;
|
||||
|
||||
void textureFromFile(aiMaterial *mat, aiTextureType type);
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ Texture::Texture(const char* texturePath, uint8_t textureType) {
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureBuffer);
|
||||
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Window::Window() {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Disable mouse cursor
|
||||
setGrabbedCursor(0);
|
||||
setGrabbedCursor(1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user