#pragma once

#include <C2/gl/GlTextureObject.h>

#include "../SDL_Include.h"



namespace gl
{


class TextureConfig
{
public:
	TextureConfig(void)
	{
		m_EnableCompress = false;
		m_EnableMipmap   = true;
	}

public:
	bool m_EnableCompress;
	bool m_EnableMipmap;
};


class GlTexture
{
public:
	GlTexture(void);
	virtual ~GlTexture(void);

	bool InitializeTexture(void);
	void FinalizeTexture(void);

	void BindGL(void);
	void SetTextureGL(const TextureConfig& config);
	void SetTextureGLAndReleaseImage(const TextureConfig& config);

	bool HasImage(void) const;
	bool HasTextureObject(void) const;

	bool LoadTextureFromFile(const char* filename, bool flip_y);

	bool SetFromSDLSurface(SDL_Surface* surface);

	void SetName( const std::string& name ) { m_Name = name; }
	const std::string& GetName(void) const { return m_Name; }

	void ReleaseOnlyBuffer(void);

	const std::string& GetSourceFilePath(void) const
	{
		return m_SourceFile;
	}

private:
	GlTexture(const GlTexture&) {}
	void operator=(const GlTexture&) {}

	void ReleaseImage(void);

private:
	lib_gl::GlTextureObject m_TexObject;
	SDL_Surface*            m_TexSDL;
	std::string             m_Name;
	std::string             m_SourceFile;
};


}
