Added old method to collect extensions

This required manual changes in generated file gl_load.c
This commit is contained in:
alexey.lysiuk 2016-04-30 13:33:54 +03:00
parent 3816b46938
commit 893d0c8915
2 changed files with 73 additions and 6 deletions

View file

@ -66,10 +66,35 @@ static void CollectExtensions()
int max = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &max);
for(int i = 0; i < max; i++)
if (0 == max)
{
extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
m_Extensions.Push(FString(extension));
// Try old method to collect extensions
const char *supported = (char *)glGetString(GL_EXTENSIONS);
if (nullptr != supported)
{
char *extensions = new char[strlen(supported) + 1];
strcpy(extensions, supported);
char *extension = strtok(extensions, " ");
while (extension)
{
m_Extensions.Push(FString(extension));
extension = strtok(nullptr, " ");
}
delete [] extensions;
}
}
else
{
// Use modern method to collect extensions
for (int i = 0; i < max; i++)
{
extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
m_Extensions.Push(FString(extension));
}
}
}

View file

@ -2375,8 +2375,41 @@ static void LoadExtByName(const char *extensionName)
}
}
static void ProcExtsFromExtString(const char *strExtList)
{
size_t iExtListLen = strlen(strExtList);
const char *strExtListEnd = strExtList + iExtListLen;
const char *strCurrPos = strExtList;
char strWorkBuff[256];
static void ProcExtsFromExtList(void)
while(*strCurrPos)
{
/*Get the extension at our position.*/
int iStrLen = 0;
const char *strEndStr = strchr(strCurrPos, ' ');
int iStop = 0;
if(strEndStr == NULL)
{
strEndStr = strExtListEnd;
iStop = 1;
}
iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);
if(iStrLen > 255)
return;
strncpy(strWorkBuff, strCurrPos, iStrLen);
strWorkBuff[iStrLen] = '\0';
LoadExtByName(strWorkBuff);
strCurrPos = strEndStr + 1;
if(iStop) break;
}
}
static int ProcExtsFromExtList(void)
{
GLint iLoop;
GLint iNumExtensions = 0;
@ -2387,6 +2420,8 @@ static void ProcExtsFromExtList(void)
const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);
LoadExtByName(strExtensionName);
}
return iNumExtensions;
}
int ogl_LoadFunctions()
@ -2398,8 +2433,15 @@ int ogl_LoadFunctions()
if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED;
_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi");
if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED;
ProcExtsFromExtList();
if (0 == ProcExtsFromExtList())
{
_ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString");
if(!_ptrc_glGetString) return ogl_LOAD_FAILED;
ProcExtsFromExtString((const char *)_ptrc_glGetString(GL_EXTENSIONS));
}
numFailed = Load_Version_3_3();
if(numFailed == 0)