I have a requirement where i need to load a sequence of images to the memory and than play them back to back.
I load all of the files into a std::vector and after they all get loaded i play them.
this is code for loading each file.
void loadTextureFromFile(const GLchar *file)
{
// Create Texture object
Texture2D texture;
// Load image
int width, height, channels;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
unsigned char* image = SOIL_load_image(file, &width, &height, &channels, SOIL_LOAD_AUTO);
// Set The Internal Format
if (channels > 3)
{
texture.Internal_Format = GL_RGBA;
texture.Image_Format = GL_RGBA;
}
else
{
texture.Internal_Format = GL_RGB;
texture.Image_Format = GL_RGB;
}
// Now generate texture
texture.Generate(width, height, image);
imageSequence.push_back(texture);
// And finally free image data
SOIL_free_image_data(image);
}
////////////////////////////////////////////////////////
Texture2D::Texture2D()
: Width(0), Height(0), Internal_Format(GL_RGB), Image_Format(GL_RGB), Wrap_S(GL_REPEAT), Wrap_T(GL_REPEAT), Filter_Min(GL_LINEAR), Filter_Max(GL_LINEAR) , WrapMode(SumTextureDecl::TextureWrapMode::Repeat)
{
glGenTextures(1, &this->ID);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
void Texture2D::Generate(GLuint width, GLuint height, unsigned char* data)
{
float aniso = 0.0f;
this->Width = width;
this->Height = height;
glBindTexture(GL_TEXTURE_2D, this->ID);
// Set Texture wrap and filter modes
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso);
// Create Texture
glTexImage2D(GL_TEXTURE_2D, 0, this->Internal_Format, width, height, 0, this->Image_Format, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, this->Wrap_S);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, this->Wrap_T);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
// Unbind texture
glBindTexture(GL_TEXTURE_2D, 0);
}
it takes some time to load all the files of image sequence so what file format would load the fastest ?
I am using soil to load images by using some other library would the loading become more fast ?