#ifndef CTEXTURE_H
#define CTEXTURE_H

class CTexture
{
  GLuint textureID;
  int Width, Height;
  std::string Name;

 public:
  CTexture(std::string FileName = std::string("")) : Name(FileName)
    {
      pngInfo info;
      textureID = pngBind(FileName.c_str(),
                          PNG_NOMIPMAP,
                          PNG_ALPHA,
                          &info,
                          GL_REPEAT,
                          GL_NEAREST,
                          GL_NEAREST);

      if (textureID == 0)
        throw "Unable to load texture.";

      Width = info.Width;
      Height = info.Height;
    }
  CTexture(const CTexture& copy)
    {
      textureID = copy.textureID;
      Width = copy.Width;
      Height = copy.Height;
      Name = copy.Name;
    }
  const CTexture& operator = (const CTexture& copy)
    {
      textureID = copy.textureID;
      Width = copy.Width;
      Height = copy.Height;
      Name = copy.Name;

      return (*this);
    }

  ~CTexture() { glDeleteTextures(1,&textureID); }

  void Bind() const { glBindTexture(GL_TEXTURE_2D, textureID); }
  int GetWitdh() const { return Width; }
  int GetHeight() const { return Height; }
  std::string GetName() const { return Name; }
};

#endif
