#include "OpenGLwrapper.h"


void selectTextureUnit(unsigned int unit_number)
{
	switch (unit_number)
	{
	case 0:
		glActiveTextureARB(GL_TEXTURE0);
	break;
	case 1:
		glActiveTextureARB(GL_TEXTURE1);
	break;
	case 2:
		glActiveTextureARB(GL_TEXTURE2);
	break;
	case 3:
		glActiveTextureARB(GL_TEXTURE3);
	break;
	case 4:
		glActiveTextureARB(GL_TEXTURE4);
	break;
	case 5:
		glActiveTextureARB(GL_TEXTURE5);
	break;
	case 6:
		glActiveTextureARB(GL_TEXTURE6);
	break;
	case 7:
		glActiveTextureARB(GL_TEXTURE7);
	break;
	default:
		assert(!"Cannot activate texture unit number:" && unit_number);
	break;
	}
}

unsigned int getTextureWidth( unsigned int texId )
{
	GLint _idtex, width;
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &_idtex);
	glBindTexture(GL_TEXTURE_2D, texId);

	glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);

	//restore previous texture
	glBindTexture(GL_TEXTURE_2D, _idtex);

	return width;

}
unsigned int getTextureHeight( unsigned int texId )
{
	GLint _idtex, height;
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &_idtex);
	glBindTexture(GL_TEXTURE_2D, texId);

	glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);

	//restore previous texture
	glBindTexture(GL_TEXTURE_2D, _idtex);

	return height;
}