Bugfix for win32 loading jpg texture's

This commit is contained in:
Mark Vejvoda
2010-04-09 06:51:13 +00:00
parent d61e7cd4c3
commit 06b21ca4ee
6 changed files with 70 additions and 13 deletions

View File

@@ -137,7 +137,10 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){
glFormat, GL_UNSIGNED_BYTE, pixels);
if(error!=0){
throw runtime_error("Error building texture 1D mipmaps");
//throw runtime_error("Error building texture 1D mipmaps");
char szBuf[1024]="";
sprintf(szBuf,"Error building texture 1D mipmaps, returned: %d [%s] w = %d",error,pixmap.getPath().c_str(),pixmap.getW());
throw runtime_error(szBuf);
}
}
else{
@@ -151,7 +154,10 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy){
GLint error= glGetError();
if(error!=GL_NO_ERROR){
throw runtime_error("Error creating texture 1D");
//throw runtime_error("Error creating texture 1D");
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture 1D, returned: %d [%s] w = %d",error,pixmap.getPath().c_str(),pixmap.getW());
throw runtime_error(szBuf);
}
}
inited= true;
@@ -211,7 +217,10 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy){
glFormat, GL_UNSIGNED_BYTE, pixels);
if(error!=0){
throw runtime_error("Error building texture 2D mipmaps");
//throw runtime_error("Error building texture 2D mipmaps");
char szBuf[1024]="";
sprintf(szBuf,"Error building texture 2D mipmaps, returned: %d [%s] w = %d, h = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH());
throw runtime_error(szBuf);
}
}
else{
@@ -226,7 +235,9 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy){
GLint error= glGetError();
if(error!=GL_NO_ERROR){
throw runtime_error("Error creating texture 2D");
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture 2D, returned: %d [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat);
throw runtime_error(szBuf);
}
}
inited= true;
@@ -280,7 +291,10 @@ void Texture3DGl::init(Filter filter, int maxAnisotropy){
GLint error= glGetError();
if(error!=GL_NO_ERROR){
throw runtime_error("Error creating texture 3D");
//throw runtime_error("Error creating texture 3D");
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture 3D, returned: %d [%s] w = %d, h = %d, d = %d",error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),pixmap.getD());
throw runtime_error(szBuf);
}
inited= true;
}
@@ -343,7 +357,10 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy){
glFormat, GL_UNSIGNED_BYTE, pixels);
if(error!=0){
throw runtime_error("Error building texture cube mipmaps");
//throw runtime_error("Error building texture cube mipmaps");
char szBuf[1024]="";
sprintf(szBuf,"Error building texture cube mipmaps, returned: %d [%s] w = %d, h = %d",error,currentPixmap->getPath().c_str(),currentPixmap->getW(),currentPixmap->getH());
throw runtime_error(szBuf);
}
}
else{
@@ -353,8 +370,12 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy){
0, glFormat, GL_UNSIGNED_BYTE, pixels);
}
if(glGetError()!=GL_NO_ERROR){
throw runtime_error("Error creating texture cube");
int error = glGetError();
if(error!=GL_NO_ERROR){
//throw runtime_error("Error creating texture cube");
char szBuf[1024]="";
sprintf(szBuf,"Error creating texture cube, returned: %d [%s] w = %d, h = %d",error,currentPixmap->getPath().c_str(),currentPixmap->getW(),currentPixmap->getH());
throw runtime_error(szBuf);
}
}
inited= true;

View File

@@ -356,6 +356,8 @@ Pixmap1D::~Pixmap1D(){
}
void Pixmap1D::load(const string &path){
this->path = path;
string extension= path.substr(path.find_last_of('.')+1);
if(extension=="bmp"){
loadBmp(path);
@@ -369,6 +371,7 @@ void Pixmap1D::load(const string &path){
}
void Pixmap1D::loadBmp(const string &path){
this->path = path;
PixmapIoBmp plb;
plb.openRead(path);
@@ -396,6 +399,7 @@ void Pixmap1D::loadBmp(const string &path){
}
void Pixmap1D::loadTga(const string &path){
this->path = path;
PixmapIoTga plt;
plt.openRead(path);
@@ -464,10 +468,15 @@ Pixmap2D::~Pixmap2D(){
}
Pixmap2D* Pixmap2D::loadPath(const string& path) {
return FileReader<Pixmap2D>::readPath(path);
Pixmap2D *pixmap = FileReader<Pixmap2D>::readPath(path);
if(pixmap != NULL) {
pixmap->path = path;
}
return pixmap;
}
void Pixmap2D::load(const string &path){
this->path = path;
FileReader<Pixmap2D>::readPath(path,this);
}
@@ -764,6 +773,8 @@ Pixmap3D::~Pixmap3D(){
}
void Pixmap3D::loadSlice(const string &path, int slice){
this->path = path;
string extension= path.substr(path.find_last_of('.')+1);
if(extension=="bmp"){
loadSliceBmp(path, slice);
@@ -777,6 +788,7 @@ void Pixmap3D::loadSlice(const string &path, int slice){
}
void Pixmap3D::loadSliceBmp(const string &path, int slice){
this->path = path;
PixmapIoBmp plb;
plb.openRead(path);
@@ -796,6 +808,8 @@ void Pixmap3D::loadSliceBmp(const string &path, int slice){
}
void Pixmap3D::loadSliceTga(const string &path, int slice){
this->path = path;
PixmapIoTga plt;
plt.openRead(path);
@@ -834,6 +848,8 @@ void PixmapCube::init(int components){
//load & save
void PixmapCube::loadFace(const string &path, int face){
this->path[face] = path;
faces[face].load(path);
}

View File

@@ -10,9 +10,12 @@
// ==============================================================
#include "texture.h"
#include "util.h"
#include "leak_dumper.h"
using namespace Shared::Util;
namespace Shared{ namespace Graphics{
// =====================================================
@@ -37,6 +40,8 @@ Texture::Texture(){
void Texture1D::load(const string &path){
this->path= path;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str());
if (pixmap.getComponents() == -1) { //TODO: look where you really need that
pixmap.init(defaultComponents);
}
@@ -49,6 +54,8 @@ void Texture1D::load(const string &path){
void Texture2D::load(const string &path){
this->path= path;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str());
if (pixmap.getComponents() == -1) {
pixmap.init(defaultComponents);
}
@@ -61,6 +68,8 @@ void Texture2D::load(const string &path){
void Texture3D::loadSlice(const string &path, int slice){
this->path= path;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str());
if (pixmap.getComponents() == -1) {
pixmap.init(defaultComponents);
}
@@ -73,6 +82,8 @@ void Texture3D::loadSlice(const string &path, int slice){
void TextureCube::loadFace(const string &path, int face){
this->path= path;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str());
if (pixmap.getFace(0)->getComponents() == -1) {
pixmap.init(defaultComponents);
}