
#include "grafik.h"



PFNGLMULTITEXCOORD1FARBPROC		glMultiTexCoord1fARB;
PFNGLMULTITEXCOORD1DARBPROC		glMultiTexCoord1dARB;
PFNGLMULTITEXCOORD1FVARBPROC	glMultiTexCoord1fvARB;
PFNGLMULTITEXCOORD1DVARBPROC	glMultiTexCoord1dvARB;
PFNGLMULTITEXCOORD2FARBPROC		glMultiTexCoord2fARB;
PFNGLMULTITEXCOORD2DARBPROC		glMultiTexCoord2dARB; 
PFNGLMULTITEXCOORD2FVARBPROC	glMultiTexCoord2fvARB;
PFNGLMULTITEXCOORD2DVARBPROC	glMultiTexCoord2dvARB;
PFNGLMULTITEXCOORD3FARBPROC		glMultiTexCoord3fARB;
PFNGLMULTITEXCOORD3DARBPROC		glMultiTexCoord3dARB;
PFNGLMULTITEXCOORD3FVARBPROC	glMultiTexCoord3fvARB;
PFNGLMULTITEXCOORD3DVARBPROC	glMultiTexCoord3dvARB;
PFNGLMULTITEXCOORD4FARBPROC		glMultiTexCoord4fARB;
PFNGLMULTITEXCOORD4DARBPROC		glMultiTexCoord4dARB;
PFNGLMULTITEXCOORD4FVARBPROC	glMultiTexCoord4fvARB;
PFNGLMULTITEXCOORD4DVARBPROC	glMultiTexCoord4dvARB;
PFNGLACTIVETEXTUREARBPROC		glActiveTextureARB		= NULL;
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB= NULL;

bool bCheckExtension(char* a_szExtensionName, char* a_szSupportedExtensionBuffer)
{
	unsigned int l_uiNextExtension;
	char*		 l_cEndExtensions;

	l_cEndExtensions= a_szSupportedExtensionBuffer+strlen(a_szSupportedExtensionBuffer);

	while(a_szSupportedExtensionBuffer<l_cEndExtensions)
	{
		l_uiNextExtension= strcspn(a_szSupportedExtensionBuffer, " ");

		if((strlen(a_szExtensionName)==l_uiNextExtension) && (strncmp(a_szExtensionName, a_szSupportedExtensionBuffer, l_uiNextExtension)==0))
		{
			g_log.bPrint("Ekran kartinin destekledigi Extension : %s", a_szExtensionName);
			return true;
		}

		a_szSupportedExtensionBuffer+= (l_uiNextExtension+1);
	}

	g_log.bPrint("Ekran kartinin desteklemedigi Extension: %s", a_szExtensionName);
	return false;
}
void multitex()
{
	char* pu_szSupportedGLExtensions;
	int			 p_iMaxTextureUnits;

	pu_szSupportedGLExtensions= (char*)glGetString(GL_EXTENSIONS);

	bCheckExtension("GL_ARB_multitexture", pu_szSupportedGLExtensions);

	glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &p_iMaxTextureUnits);
	

	glMultiTexCoord1fARB	= (PFNGLMULTITEXCOORD1FARBPROC)		wglGetProcAddress("glMultiTexCoord1fARB");
	glMultiTexCoord1dARB	= (PFNGLMULTITEXCOORD1DARBPROC)		wglGetProcAddress("glMultiTexCoord1dARB");
	glMultiTexCoord1fvARB	= (PFNGLMULTITEXCOORD1FVARBPROC)	wglGetProcAddress("glMultiTexCoord1fvARB");
	glMultiTexCoord1dvARB	= (PFNGLMULTITEXCOORD1DVARBPROC)	wglGetProcAddress("glMultiTexCoord1dvARB");
	glMultiTexCoord2fARB	= (PFNGLMULTITEXCOORD2FARBPROC)		wglGetProcAddress("glMultiTexCoord2fARB");
	glMultiTexCoord2dARB	= (PFNGLMULTITEXCOORD2DARBPROC)		wglGetProcAddress("glMultiTexCoord2dARB");
	glMultiTexCoord2fvARB	= (PFNGLMULTITEXCOORD2FVARBPROC)	wglGetProcAddress("glMultiTexCoord2fvARB");
	glMultiTexCoord2dvARB	= (PFNGLMULTITEXCOORD2DVARBPROC)	wglGetProcAddress("glMultiTexCoord2dvARB");
	glMultiTexCoord3fARB	= (PFNGLMULTITEXCOORD3FARBPROC)		wglGetProcAddress("glMultiTexCoord3fARB");
	glMultiTexCoord3dARB	= (PFNGLMULTITEXCOORD3DARBPROC)		wglGetProcAddress("glMultiTexCoord3dARB");
	glMultiTexCoord3fvARB	= (PFNGLMULTITEXCOORD3FVARBPROC)	wglGetProcAddress("glMultiTexCoord3fvARB");
	glMultiTexCoord3dvARB	= (PFNGLMULTITEXCOORD3DVARBPROC)	wglGetProcAddress("glMultiTexCoord3dvARB");
	glMultiTexCoord4fARB	= (PFNGLMULTITEXCOORD4FARBPROC)		wglGetProcAddress("glMultiTexCoord4fARB");
	glMultiTexCoord4dARB	= (PFNGLMULTITEXCOORD4DARBPROC)		wglGetProcAddress("glMultiTexCoord4dARB");
	glMultiTexCoord4fvARB	= (PFNGLMULTITEXCOORD4FVARBPROC)	wglGetProcAddress("glMultiTexCoord4fvARB");
	glMultiTexCoord4dvARB	= (PFNGLMULTITEXCOORD4DVARBPROC)	wglGetProcAddress("glMultiTexCoord4dvARB");
	glActiveTextureARB		= (PFNGLACTIVETEXTUREARBPROC)		wglGetProcAddress("glActiveTextureARB");
	glClientActiveTextureARB= (PFNGLCLIENTACTIVETEXTUREARBPROC)	wglGetProcAddress("glClientActiveTextureARB");

	g_log.bPrint("Multitexturing , video kartinin destekledigi %d texture unit", p_iMaxTextureUnits);
	
}