
#include "stdafx.h"
#include "WGlew.h"


//////////////////////////////////////////////////////////////////////////
// GLEW
//////////////////////////////////////////////////////////////////////////

C_LOG_FILE g_LogFileExt("ExtLog.txt");

void W_GLEW_Init()
{
	GLenum error = glewInit();
	g_LogFileExt.ExWrite("Init glew ..... ");
	if (GLEW_OK != error)
	{	 
		cError.ErrorMsg(0,true,true,"Glew - inicializace","Nepovedlo se inicializovat GLEW");
		g_LogFileExt.ExWriteln("FALSE");
		return;
	}
	g_LogFileExt.ExWriteln("TRUE");
	g_LogFileExt.ExWrite("Glew version : ");
	g_LogFileExt.ExWriteln( W_GLEW_GetVersion().c_str() );
}

std::string W_GLEW_GetVersion()
{
	std::string ret;
	char temp[255];
	sprintf(temp, "%s", glewGetString(GLEW_VERSION) );
	ret = temp;
	return ret;
}

bool W_GLEW_Support(const std::string name_ext)
{
	g_LogFileExt.ExWrite( name_ext.c_str() );
	g_LogFileExt.ExWrite(" supported ..... ");
	if( glewGetExtension(name_ext.c_str()) )
	{
		g_LogFileExt.ExWriteln("TRUE");
		return TRUE;
	}
	g_LogFileExt.ExWriteln("FALSE");
	return FALSE;
}

//////////////////////////////////////////////////////////////////////////
// Extensions - 
//////////////////////////////////////////////////////////////////////////
float W_EXT_GetF(const W_EXTenum target)
{
	switch (target) 
	{
	case WEXT_MAX_ANISOTROPIC:
		float ret;
		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &ret);
		return ret;
		break;
	/*case :
		break;*/
	}
	return -1.0f;
}
void W_EXT_SetF(const W_EXTenum target, const float param)
{
	switch(target) 
	{
	case WEXT_MAX_ANISOTROPIC:
		glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &param);
		break;
	/*case :
		break;*/
	}
}
