#ifndef TEXTURE_H
#define TEXTURE_H

#include "globals.h"
#include "vec4.h"
#include <fstream.h>
#include <iostream.h>
#include <GL/gl.h>

enum TextureType {NONE = 1, NEAREST, LINEAR};

class Texture {
private:
  Texture () {};
  Texture (int width, int height, float sx, float sy) : _pixels (new float [4* width * height]), _width (width), _height (height), _sx(sx), _sy(sy) {}

  float *_pixels;

  void load_pgm(ifstream &infile);
  void load_ppm(ifstream& infile);

  GLuint _dlist;
  int _width, _height;
  float _sx, _sy; //scale factors
public:
  void lookup (float s, float t, Color &col, TextureType filter);

  //this is how you make a texture
  static Texture* Texture::load(char * file, float scalex, float scaley);

  int width (void) {return _width;}
  int height (void) {return _height;}
  float *data (void) {return _pixels;}
  
  void RunDisplayList (void);
};
#endif
