OpenGL2: Add OpenGL ES 2.0+ support

This mainly targets OpenGL ES 2.0 but it also supports compiling GLSL as
ESSL 3.00. It's missing support for framebuffer objects which should be
possible on ES 2. (Though using renderbuffers instead of textures.)

opengl1 cvars that are not supported will display a message and disable
the cvar. This has not been reviewed for new opengl2 cvars. Enabling
cvars may cause rendering issues. Some of the broken cvars may be
possible to support using OpenGL ES 3 features.

The game displays okay with the default cvars.
This commit is contained in:
Zack Middleton committed 2024-06-05 21:33:08 -05:00
1 parent 1fc83e4845
commit 3b984d2b51
14 files changed
+658 -167

No files matched your search

+96 -12
View File
@@ -53,8 +53,83 @@ void GLimp_InitExtraExtensions(void)
// GL function loader, based on https://gist.github.com/rygorous/16796a0c876cf8a5f542caddb55bce8a
#define GLE(ret, name, ...) qgl##name = (name##proc *) SDL_GL_GetProcAddress("gl" #name);
//
// OpenGL ES extensions
//
if (qglesMajorVersion)
{
if (!r_allowExtensions->integer)
goto done;
extension = "GL_EXT_occlusion_query_boolean";
if (SDL_GL_ExtensionSupported(extension))
{
glRefConfig.occlusionQuery = qtrue;
glRefConfig.occlusionQueryTarget = GL_ANY_SAMPLES_PASSED;
QGL_ARB_occlusion_query_PROCS;
ri.Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_NV_read_depth
extension = "GL_NV_read_depth";
if (SDL_GL_ExtensionSupported(extension))
{
glRefConfig.readDepth = qtrue;
ri.Printf(PRINT_ALL, result[glRefConfig.readDepth], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_NV_read_stencil
extension = "GL_NV_read_stencil";
if (SDL_GL_ExtensionSupported(extension))
{
glRefConfig.readStencil = qtrue;
ri.Printf(PRINT_ALL, result[glRefConfig.readStencil], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_EXT_shadow_samplers
extension = "GL_EXT_shadow_samplers";
if (qglesMajorVersion >= 3 || SDL_GL_ExtensionSupported(extension))
{
glRefConfig.shadowSamplers = qtrue;
ri.Printf(PRINT_ALL, result[glRefConfig.shadowSamplers], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_OES_standard_derivatives
extension = "GL_OES_standard_derivatives";
if (qglesMajorVersion >= 3 || SDL_GL_ExtensionSupported(extension))
{
glRefConfig.standardDerivatives = qtrue;
ri.Printf(PRINT_ALL, result[glRefConfig.standardDerivatives], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
goto done;
}
// OpenGL 1.5 - GL_ARB_occlusion_query
glRefConfig.occlusionQuery = qtrue;
glRefConfig.occlusionQueryTarget = GL_SAMPLES_PASSED;
QGL_ARB_occlusion_query_PROCS;
// OpenGL 3.0 - GL_ARB_framebuffer_object
@@ -146,18 +221,6 @@ void GLimp_InitExtraExtensions(void)
ri.Printf(PRINT_ALL, result[2], extension);
}
// Determine GLSL version
if (1)
{
char version[256];
Q_strncpyz(version, (char *)qglGetString(GL_SHADING_LANGUAGE_VERSION), sizeof(version));
sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion);
ri.Printf(PRINT_ALL, "...using GLSL version %s\n", version);
}
glRefConfig.memInfo = MI_NONE;
// GL_NVX_gpu_memory_info
@@ -249,5 +312,26 @@ void GLimp_InitExtraExtensions(void)
ri.Printf(PRINT_ALL, result[2], extension);
}
done:
// Determine GLSL version
if (1)
{
char version[256], *version_p;
Q_strncpyz(version, (char *)qglGetString(GL_SHADING_LANGUAGE_VERSION), sizeof(version));
// Skip leading text such as "OpenGL ES GLSL ES "
version_p = version;
while ( *version_p && !isdigit( *version_p ) )
{
version_p++;
}
sscanf(version_p, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion);
ri.Printf(PRINT_ALL, "...using GLSL version %s\n", version);
}
#undef GLE
}