You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
2.4 KiB

/******************************************************
* LEGACY CODE FROM EMBRYO VERY FIRST DRAFT *
* READ AT YOUR OWN RISK *
* I cannot be held responsible for any brain damage *
* caused by the reading of this code *
* It worked at some point, so it should be pretty *
* easy to reimplment it *
******************************************************/
#include "Material.h"
#include "ExternalLib/SOIL/inc/SOIL/SOIL.h"
#include <iostream>
/******************
* Constructors *
******************/
Material::Material()
{}
Material::Material(MaterialType type, const char filename[], std::string glName_)
:glName(glName_)
{
switch (type)
{
case(Texture):
{
// loading file
int textureWidth, textureHeight;
unsigned char* texture = SOIL_load_image( filename, &textureWidth, &textureHeight
, nullptr, SOIL_LOAD_RGB);
if (texture == nullptr)
{
std::cout << "ERROR::TEXTURE MISSING" << std::endl;
std::cout << "Didn't find the input texture's picture at the adress : " << std::endl;
std::cout << filename << std::endl;
}
// generate and bind texture
glGenTextures(1, &glId); // generate 1 texture and stores it into container
glBindTexture(GL_TEXTURE_2D, glId); // binds container to global GL_TEXTURE_2D describing 2D textures
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, texture); // load the image inside global GL_TEXTURE_2D onto the graphic card
glGenerateMipmap(GL_TEXTURE_2D); // generate mipmap of GL_TEXTURE_2D's texture
// clear VAO
SOIL_free_image_data(texture); // free containerTexture
glBindTexture(GL_TEXTURE_2D, 0); // clear GL_TEXTURE_2D (will be rebind later)
break;
}
default : break;
}
}
Material::~Material()
{ }
GLuint Material::getGlId() const
{
/**
* \brief return id associated to the Material
*/
return glId;
}
std::string Material::getGlName() const
{
/**
* \brief return uniform variable name associated to the Material
*/
return glName;
}