mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
Added old method to collect extensions
This required manual changes in generated file gl_load.c
This commit is contained in:
parent
3816b46938
commit
893d0c8915
2 changed files with 73 additions and 6 deletions
|
@ -66,10 +66,35 @@ static void CollectExtensions()
|
||||||
int max = 0;
|
int max = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &max);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &max);
|
||||||
|
|
||||||
for(int i = 0; i < max; i++)
|
if (0 == max)
|
||||||
{
|
{
|
||||||
extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
// Try old method to collect extensions
|
||||||
m_Extensions.Push(FString(extension));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 iLoop;
|
||||||
GLint iNumExtensions = 0;
|
GLint iNumExtensions = 0;
|
||||||
|
@ -2387,6 +2420,8 @@ static void ProcExtsFromExtList(void)
|
||||||
const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);
|
const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop);
|
||||||
LoadExtByName(strExtensionName);
|
LoadExtByName(strExtensionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return iNumExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ogl_LoadFunctions()
|
int ogl_LoadFunctions()
|
||||||
|
@ -2399,7 +2434,14 @@ int ogl_LoadFunctions()
|
||||||
_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi");
|
_ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi");
|
||||||
if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED;
|
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();
|
numFailed = Load_Version_3_3();
|
||||||
|
|
||||||
if(numFailed == 0)
|
if(numFailed == 0)
|
||||||
|
|
Loading…
Reference in a new issue