Browse Source

Expose has_extension to query whether OpenGL extension is supported

rdb 11 years ago
parent
commit
a7d1eb90c5

+ 12 - 0
panda/src/display/graphicsStateGuardian.cxx

@@ -2972,6 +2972,18 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) {
   return tex;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::has_extension
+//       Access: Public, Virtual
+//  Description: Returns true if the GSG implements the extension
+//               identified by the given string.  This currently
+//               is only implemented by the OpenGL back-end.
+////////////////////////////////////////////////////////////////////
+bool GraphicsStateGuardian::
+has_extension(const string &extension) const {
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::get_driver_vendor
 //       Access: Public, Virtual

+ 1 - 0
panda/src/display/graphicsStateGuardian.h

@@ -201,6 +201,7 @@ PUBLISHED:
 #endif
 
 PUBLISHED:
+  virtual bool has_extension(const string &extension) const;
 
   virtual string get_driver_vendor();
   virtual string get_driver_renderer();

+ 19 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.I

@@ -171,6 +171,25 @@ maybe_gl_finish() const {
 #endif
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GLGraphicsStateGuardian::has_extension
+//       Access: Published, Final
+//  Description: Returns true if the indicated extension is reported
+//               by the GL system, false otherwise.  The extension
+//               name is case-sensitive.
+////////////////////////////////////////////////////////////////////
+INLINE bool CLP(GraphicsStateGuardian)::
+has_extension(const string &extension) const {
+  bool has_ext = (_extensions.find(extension) != _extensions.end());
+#ifndef NDEBUG
+  if (GLCAT.is_debug()) {
+    GLCAT.debug()
+      << "HAS EXT " << extension << " " << has_ext << "\n";
+  }
+#endif
+  return has_ext;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::is_at_least_gl_version
 //       Access: Public

+ 0 - 21
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -6781,27 +6781,6 @@ report_extensions() const {
   }
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: GLGraphicsStateGuardian::has_extension
-//       Access: Protected
-//  Description: Returns true if the indicated extension is reported
-//               by the GL system, false otherwise.  The extension
-//               name is case-sensitive.
-////////////////////////////////////////////////////////////////////
-bool CLP(GraphicsStateGuardian)::
-has_extension(const string &extension) const {
-
-  bool state;
-
-  state = _extensions.find(extension) != _extensions.end();
-  if (GLCAT.is_debug()) {
-    GLCAT.debug()
-      << "HAS EXT " << extension << " " << state << "\n";
-  }
-
-  return state;
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::get_extension_func
 //       Access: Public

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

@@ -406,7 +406,7 @@ protected:
   void save_extensions(const char *extensions);
   virtual void get_extra_extensions();
   void report_extensions() const;
-  bool has_extension(const string &extension) const;
+  INLINE virtual bool has_extension(const string &extension) const FINAL;
   INLINE bool is_at_least_gl_version(int major_version, int minor_version) const;
   INLINE bool is_at_least_gles_version(int major_version, int minor_version) const;
   void *get_extension_func(const char *name);