/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
#ifndef TEXTURE_H
#define TEXTURE_H
#include <string>
#include <vector>
#include <map>
#include <glew/glew.h>
#include <glm/glm.hpp>
using namespace std;



// Some useful defines

enum ETextureFiltering
{
	TEXTURE_FILTER_MAG_NEAREST = 0, // Nearest criterion for magnification
	TEXTURE_FILTER_MAG_BILINEAR, // Bilinear criterion for magnification
	TEXTURE_FILTER_MIN_NEAREST, // Nearest criterion for minification
	TEXTURE_FILTER_MIN_BILINEAR, // Bilinear criterion for minification
	TEXTURE_FILTER_MIN_NEAREST_MIPMAP, // Nearest criterion for minification, but on closest mipmap
	TEXTURE_FILTER_MIN_BILINEAR_MIPMAP, // Bilinear criterion for minification, but on closest mipmap
	TEXTURE_FILTER_MIN_TRILINEAR, // Bilinear criterion for minification on two closest mipmaps, then averaged
};

class Texture
{
public:
	void greateEmptyTexture(int a_iWidth, int a_iHeight, GLenum format);

	void createFromData(unsigned char* bData, int a_iWidth, int a_iHeight, GLenum format, bool bGenerateMipMaps = false);

    bool loadTexture2DFromBuffer(unsigned char* buffer,int width,int height);

	void bindTexture(int iTextureUnit);

	void setFiltering(int a_tfMagnification, int a_tfMinification);

	void setSamplerParameter(GLenum parameter, GLenum value);

	void deleteTexture();

	Texture();
private:

	unsigned int mTexture; // Texture name

	unsigned int mSampler; // Sampler name

	bool mMipMapsGenerated;

	int mMinification;
    int mMagnification;

	string mPath;
};
#endif
