glgsg: Disable Cg support when using EGL instead of GLX

Cg is hard-wired to use GLX instead of EGL, so without hacky
monkey-patching it is not possible to use it under EGL
This commit is contained in:
rdb 2026-01-28 14:12:38 +01:00
parent f2c680ca29
commit 300090e457
6 changed files with 38 additions and 1 deletions

View File

@ -377,3 +377,12 @@ void *eglGraphicsStateGuardian::
do_get_extension_func(const char *name) {
return (void *)eglGetProcAddress(name);
}
/**
* Returns true if this implementation may support Cg shaders.
*/
bool eglGraphicsStateGuardian::
may_support_cg_shaders() {
// Never supported under EGL as CgGL is hard-wired to use GLX functions.
return false;
}

View File

@ -68,6 +68,7 @@ protected:
virtual void query_gl_version();
virtual void get_extra_extensions();
virtual void *do_get_extension_func(const char *name);
virtual bool may_support_cg_shaders();
private:
int _egl_version_major, _egl_version_minor;

View File

@ -2059,7 +2059,8 @@ reset() {
// Check for support for other types of shaders that can be used by Cg.
_supports_basic_shaders = false;
#if defined(HAVE_CG) && !defined(OPENGLES)
if (has_extension("GL_ARB_vertex_program") &&
if (may_support_cg_shaders() &&
has_extension("GL_ARB_vertex_program") &&
has_extension("GL_ARB_fragment_program")) {
_supports_basic_shaders = true;
_shader_caps._active_vprofile = (int)CG_PROFILE_ARBVP1;
@ -10236,6 +10237,18 @@ do_get_extension_func(const char *) {
return nullptr;
}
/**
* Returns true if this implementation may support Cg shaders.
*/
bool CLP(GraphicsStateGuardian)::
may_support_cg_shaders() {
#if defined(HAVE_CG) && !defined(OPENGLES)
return true;
#else
return false;
#endif
}
/**
* Sets up the glDrawBuffer to render into the buffer indicated by the
* RenderBuffer object. This only sets up the color and aux bits; it does not

View File

@ -525,6 +525,7 @@ protected:
INLINE bool is_at_least_gles_version(int major_version, int minor_version) const;
void *get_extension_func(const char *name);
virtual void *do_get_extension_func(const char *name);
virtual bool may_support_cg_shaders();
virtual void reissue_transforms();

View File

@ -572,6 +572,18 @@ do_get_extension_func(const char *name) {
return PosixGraphicsStateGuardian::do_get_extension_func(name);
}
/**
* Returns true if this implementation may support Cg shaders.
*/
bool glxGraphicsStateGuardian::
may_support_cg_shaders() {
#ifdef HAVE_CG
return true;
#else
return false;
#endif
}
/**
* Queries the GLX extension pointers.
*/

View File

@ -128,6 +128,7 @@ protected:
virtual void query_gl_version();
virtual void get_extra_extensions();
virtual void *do_get_extension_func(const char *name);
virtual bool may_support_cg_shaders();
private:
void query_glx_extensions();