Exemplo n.º 1
0
void Texture2D::init(TextureConfig config, const void * data, int texwidth, int texheight)
{

   this->conf = config;
   this->width = texwidth;
   this->height = texheight;
   bfr.setStoreFormat(config.getInputFormat());
   bfr.setRepeat(config.getWrapModeS());
   bfr.setMagnifyFiltering(config.getMagFilter());
   bfr.setMinifyFilter(config.getMinFilter());
   bfr.setData(data, texwidth, texheight, config.getOutputFormat(), config.getDataType());
}
Exemplo n.º 2
0
void Texture2D::init(TextureConfig config)
{
   this->conf = config;
   ReloadableAsset::init(config.getTextureName());
   int loadType = SOIL_LOAD_RGB;
   
   if(config.getInputFormat() == GL_RGBA || config.getInputFormat() == GL_SRGB_ALPHA)
   {
      loadType = SOIL_LOAD_RGBA;
      bfr.setRepeat(GL_CLAMP_TO_EDGE);
   }
   LOG(ERROR) << "Loading texture" << config.getTextureName();
   std::string textureName = config.getTextureName();
   if(!FileUtils::fExists(textureName))
   {
      LOG(ERROR) << "Could not find texture at " + textureName;
      textureName = "assets/textures/missing_texture.png";
   }
   bfr.setStoreFormat(config.getInputFormat());

   unsigned char* image = SOIL_load_image(textureName.c_str(), &width, &height, 0, loadType);
   bfr.setData(image, width, height, config.getOutputFormat(), config.getDataType());
   SOIL_free_image_data(image);
}