Explorar o código

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
rdb hai 1 día
pai
achega
300090e457

+ 9 - 0
panda/src/egldisplay/eglGraphicsStateGuardian.cxx

@@ -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;
+}

+ 1 - 0
panda/src/egldisplay/eglGraphicsStateGuardian.h

@@ -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;

+ 14 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -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

+ 1 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -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();
 

+ 12 - 0
panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

@@ -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.
  */

+ 1 - 0
panda/src/glxdisplay/glxGraphicsStateGuardian.h

@@ -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();