/** * @brief Checks for an OpenGL extension that was announced via the OpenGL ext string. If the given extension string * includes a placeholder (###), several types are checked. Those from the ARB, those that official extensions (EXT), * and those from OpenGL ES (OES) * @param extension The extension string to check. Might also contain placeholders. E.g. GL_###_framebuffer_object, * GL_ARB_framebuffer_object * @return @c true if the extension was announced by the OpenGL driver, @c false otherwise. */ static inline bool R_CheckExtension (const char *extension) { bool found; const char *s = strstr(extension, "###"); if (s == NULL) { found = strstr(r_config.extensionsString, extension) != NULL; } else { const char *replace[] = {"ARB", "EXT", "OES"}; char targetBuf[128]; const size_t length = lengthof(targetBuf); const size_t replaceNo = lengthof(replace); size_t i; for (i = 0; i < replaceNo; i++) { if (Q_strreplace(extension, "###", replace[i], targetBuf, length)) { if (strstr(r_config.extensionsString, targetBuf) != NULL) { found = true; break; } } } if (i == replaceNo) found = false; } if (found) Com_Printf("found %s\n", extension); else Com_Printf("%s not found\n", extension); return found; }
static uintptr_t R_GetProcAddressExt (const char *functionName) { const char *s = strstr(functionName, "###"); if (s == NULL) { return R_GetProcAddress(functionName); } else { const char *replace[] = {"EXT", "OES", "ARB"}; char targetBuf[128]; const size_t length = lengthof(targetBuf); const size_t replaceNo = lengthof(replace); for (size_t i = 0; i < replaceNo; i++) { if (Q_strreplace(functionName, "###", replace[i], targetBuf, length)) { uintptr_t funcAdr = R_GetProcAddress(targetBuf); if (funcAdr != 0) return funcAdr; } } Com_Printf("%s not found\n", functionName); return 0; } }
/* ================= Sys_DefaultInstallPath ================= */ char *Sys_DefaultInstallPath(void) { static char installdir[MAX_OSPATH]; Com_sprintf(installdir, sizeof(installdir), "%s", Sys_Cwd()); Q_strreplace(installdir, sizeof(installdir), "bin32", ""); Q_strreplace(installdir, sizeof(installdir), "bin64", ""); Q_strreplace(installdir, sizeof(installdir), "src/engine", ""); Q_strreplace(installdir, sizeof(installdir), "src\\engine", ""); Q_strreplace(installdir, sizeof(installdir), "bin/win32", ""); Q_strreplace(installdir, sizeof(installdir), "bin\\win32", ""); Q_strreplace(installdir, sizeof(installdir), "bin/win64", ""); Q_strreplace(installdir, sizeof(installdir), "bin\\win64", ""); Q_strreplace(installdir, sizeof(installdir), "bin/linux-x86", ""); Q_strreplace(installdir, sizeof(installdir), "bin/linux-x86_64", ""); Q_strreplace(installdir, sizeof(installdir), "bin/freebsd-i386", ""); Q_strreplace(installdir, sizeof(installdir), "bin/freebsd-amd64", ""); // MacOS X x86 and x64 Q_strreplace(installdir, sizeof(installdir), "bin/macosx", ""); return installdir; }