
#ifndef _JL_JLTexture_H_
#define _JL_JLTexture_H_

#include <stdlib.h>
#include <iostream.h>

#include "jlstring.h"
#include "glpic.h"
#include "matrix.h"

#define JLTEX_SAMPLE_POINT	1
#define JLTEX_SAMPLE_AREA	2

class JLTexture : public GLPic {

	private:
		JLString	_name;
		int			_perspective_correct;
		JLmatrix	_screen_to_tex;
		int			_sample_mode;
		float		_blur_factor;

	public: 
		JLTexture();
		JLTexture(const JLTexture &T) { CopyFrom(T); }
		virtual ~JLTexture();

		JLTexture& CopyFrom(const JLTexture&);
		JLTexture& operator=(const JLTexture &T) { return CopyFrom(T); }


		// Access Functions:

		JLString& Name() { return _name; }

		void SetPerspectiveCorrect(int p) { _perspective_correct = p; }
		int GetPerspectiveCorrect() { return _perspective_correct; }

		JLmatrix& ScreenToTexMatrix() { return _screen_to_tex; }

		void SetSampleMode(int m) { _sample_mode = m; }
		int GetSampleMode() { return _sample_mode; }

		void SetBlurFactor(float b) { _blur_factor = b; }
		float GetBlurFactor() { return _blur_factor; }


		// Texture Functions:

		PixelType SampleArea(real x1, real y1, real x2, real y2);


		// Bump Functions:

		void BumpCalcPartials();

		void BumpSample(float s, float t,
						float &b, float &dBds, float &dBdt);

		void BumpSampleLerp(float s, float t,
							float &b, float &dBds, float &dBdt);
};

#endif
