PNG is now a resource.

You can now load textures threaded.
PNG will now throw exceptions when errors happend
SpriteComponent is now working without billboarding.
This commit is contained in:
Tleety
2016-02-10 17:50:17 +01:00
parent 04c23be136
commit 53265bbc90
17 changed files with 149 additions and 83 deletions
+15 -14
View File
@@ -2,24 +2,25 @@
Texture::Texture(std::string path)
{
PNG* img = ResourceManager::Load<PNG, true>(path); //TODO: Make this threaded. Catch exeptions in all other load places.
PNG image(path);
//PNG image(path);
if (image.Width == 0 && image.Height == 0 || image.Format == Image::ImageFormat::Unknown) {
//image = PNG("Textures/Core/ErrorTexture.png");
return; // Temporary fix to remove crash
/*
if (image.Width == 0 && image.Height == 0 || image.Format == Image::ImageFormat::Unknown) {
LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed.");
return;
}*/
}
//if (img->Width == 0 && img->Height == 0 || img->Format == Image::ImageFormat::Unknown) {
// //image = PNG("Textures/Core/ErrorTexture.png");
// //return; // Temporary fix to remove crash
this->Width = image.Width;
this->Height = image.Height;
// if (img->Width == 0 && img->Height == 0 || img->Format == Image::ImageFormat::Unknown) {
// LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed.");
// return;
// }
//}
this->Width = img->Width;
this->Height = img->Height;
GLint format;
switch (image.Format) {
switch (img->Format) {
case Image::ImageFormat::RGB:
format = GL_RGB;
break;
@@ -32,7 +33,7 @@ Texture::Texture(std::string path)
glGenTextures(1, &m_Texture);
glBindTexture(GL_TEXTURE_2D, m_Texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, format, image.Width, image.Height, 0, format, GL_UNSIGNED_BYTE, image.Data);
glTexImage2D(GL_TEXTURE_2D, 0, format, img->Width, img->Height, 0, format, GL_UNSIGNED_BYTE, img->Data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);