Commit 9f4fb499 authored by Janis Born's avatar Janis Born
Browse files

* rename TextureDataControlFilePPM -> TextureDataControlFilePNM

* remove debug outputs
parent 6b3d318e
......@@ -3,8 +3,8 @@
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#ifndef ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILEPPM_HH
#define ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILEPPM_HH
#ifndef ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILEPNM_HH
#define ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILEPNM_HH
/**
* A minimal PNM loader (with some bugs). No external dependencies, so this is at least
......@@ -30,7 +30,7 @@
namespace ACGL{
namespace OpenGL{
class TextureDataControlFilePPM : public TextureDataControlFile
class TextureDataControlFilePNM : public TextureDataControlFile
{
friend void initStaticFileTypes(void);
......@@ -38,12 +38,12 @@ class TextureDataControlFilePPM : public TextureDataControlFile
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
TextureDataControlFilePPM(const std::string& _filename)
TextureDataControlFilePNM(const std::string& _filename)
: TextureDataControlFile(_filename,Base::Settings::the()->getFullTexturePath())
{}
virtual ~TextureDataControlFilePPM(void) {}
virtual ~TextureDataControlFilePNM(void) {}
static SharedTextureDataControlFile creator(const std::string& _filename) { return SharedTextureDataControlFile(new TextureDataControlFilePPM(_filename)); }
static SharedTextureDataControlFile creator(const std::string& _filename) { return SharedTextureDataControlFile(new TextureDataControlFilePNM(_filename)); }
// ===================================================================================================== \/
// ============================================================================================ OVERRIDE \/
......@@ -55,9 +55,9 @@ private:
static int_t registerType(void);
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureDataControlFilePPM)
ACGL_SMARTPOINTER_TYPEDEFS(TextureDataControlFilePNM)
} // OpenGL
} // ACGL
#endif // ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILEPPM_HH
#endif // ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILEPNM_HH
......@@ -3,7 +3,7 @@
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
#include <ACGL/OpenGL/Controller/TextureDataControlFilePPM.hh>
#include <ACGL/OpenGL/Controller/TextureDataControlFilePNM.hh>
#include <ACGL/OpenGL/Controller/DataControlFileFactory.hh>
#include <ACGL/OpenGL/Tools.hh>
......@@ -34,7 +34,7 @@ void skipWhitespace(std::istream& _in, uint_t _max = std::numeric_limits<std::st
}
}
std::istream& filterPPMComments(std::istream& _in)
std::istream& filterPNMComments(std::istream& _in)
{
skipWhitespace(_in);
......@@ -48,7 +48,7 @@ std::istream& filterPPMComments(std::istream& _in)
return _in;
}
bool TextureDataControlFilePPM::load(SharedTextureData& texture) const
bool TextureDataControlFilePNM::load(SharedTextureData& texture) const
{
std::ifstream fileStream( getFullFilePath().c_str(), std::ifstream::in );
......@@ -59,8 +59,7 @@ bool TextureDataControlFilePPM::load(SharedTextureData& texture) const
// Read the PNM header
std::string header;
filterPPMComments(fileStream) >> header;
debug() << "Header: \"" << header << "\"" << std::endl;
filterPNMComments(fileStream) >> header;
// The header version determines the format of the data
InputDataFormat inputDataFormat;
......@@ -79,8 +78,8 @@ bool TextureDataControlFilePPM::load(SharedTextureData& texture) const
// Read the width and height of the image
uint_t width, height;
filterPPMComments(fileStream) >> width;
filterPPMComments(fileStream) >> height;
filterPNMComments(fileStream) >> width;
filterPNMComments(fileStream) >> height;
if(!fileStream.good() || width == 0 || height == 0)
{
error() << "could not load " << getFullFilePath() << ": invalid image size" << std::endl;
......@@ -91,7 +90,7 @@ bool TextureDataControlFilePPM::load(SharedTextureData& texture) const
uint_t maxValue = 1;
if(header == "P2" || header == "P3" || header == "P5" || header == "P6")
{
filterPPMComments(fileStream) >> maxValue;
filterPNMComments(fileStream) >> maxValue;
if(!fileStream.good() || maxValue == 0)
{
......@@ -112,9 +111,6 @@ bool TextureDataControlFilePPM::load(SharedTextureData& texture) const
}
}
debug() << "Size: " << width << " x " << height << std::endl;
debug() << "Range: 0.." << maxValue << std::endl;
// If the image data has maxValue of 255 or 1, we return a GL_UNSIGNED_BYTE texture,
// otherwise the values are normalized and returned as a GL_FLOAT texture
GLenum outputDataType = GL_FLOAT;
......@@ -207,8 +203,10 @@ bool TextureDataControlFilePPM::load(SharedTextureData& texture) const
return true;
}
int_t TextureDataControlFilePPM::registerType(void)
int_t TextureDataControlFilePNM::registerType(void)
{
sTypeID = TextureDataControlFileFactory::the()->registerType("ppm", &TextureDataControlFilePPM::creator);
sTypeID = TextureDataControlFileFactory::the()->registerType("pbm", &TextureDataControlFilePNM::creator);
sTypeID = TextureDataControlFileFactory::the()->registerType("pgm", &TextureDataControlFilePNM::creator);
sTypeID = TextureDataControlFileFactory::the()->registerType("ppm", &TextureDataControlFilePNM::creator);
return sTypeID;
}
......@@ -7,7 +7,7 @@
#include <ACGL/OpenGL/Controller/TextureDataControlFileJPG.hh>
#include <ACGL/OpenGL/Controller/TextureDataControlFilePNG.hh>
#include <ACGL/OpenGL/Controller/TextureDataControlFilePPM.hh>
#include <ACGL/OpenGL/Controller/TextureDataControlFilePNM.hh>
#include <ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.hh>
#include <ACGL/OpenGL/Controller/GeometryDataControlFileATB.hh>
......@@ -23,7 +23,7 @@ void ACGL::OpenGL::initStaticFileTypes(void)
TextureDataControlFileJPG::registerType();
TextureDataControlFilePNG::registerType();
#endif
TextureDataControlFilePPM::registerType();
TextureDataControlFilePNM::registerType();
//
// Geometry, Meshes, Vertex data
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment