Browse Source

Added get_supports_cg_profile

Mike Christel 16 years ago
parent
commit
01b720ceb9

+ 14 - 3
panda/src/display/graphicsStateGuardian.cxx

@@ -1,8 +1,8 @@
 // Filename: graphicsStateGuardian.cxx
 // Created by:  drose (02Feb99)
-// Updated by: fperazzi, PandaSE (06Apr10) (added fetch_ptr_parameter)
-// Updated by: fperazzi, PandaSE (29Apr10)  (added 
-// _max_2d_texture_array_layers, _supports_2d_texture_array)
+// Updated by: fperazzi, PandaSE (05May10) (added fetch_ptr_parameter,
+//  _max_2d_texture_array_layers, _supports_2d_texture_array,
+//  get_supports_cg_profile)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -317,6 +317,17 @@ get_supported_geom_rendering() const {
   return _supported_geom_rendering;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::get_supports_cg_profile
+//       Access: Published, Virtual
+//  Description: Returns true if this particular GSG supports the 
+//               specified Cg Shader Profile.
+////////////////////////////////////////////////////////////////////
+bool GraphicsStateGuardian::
+get_supports_cg_profile(const string &name) const {
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::set_coordinate_system
 //       Access: Published

+ 4 - 3
panda/src/display/graphicsStateGuardian.h

@@ -1,8 +1,7 @@
 // Filename: graphicsStateGuardian.h
 // Created by:  drose (02Feb99)
-// Updated by: fperazzi, PandaSE (06Apr10) (added fetch_ptr_parameter)
-// Updated by: fperazzi, PandaSE (29Apr10) (added 
-// _max_2d_texture_array_layers on z axis)
+// Updated by: fperazzi, PandaSE (05May10) (added fetch_ptr_parameter,
+//  _max_2d_texture_array_layers on z axis, get_supports_cg_profile)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -156,6 +155,8 @@ PUBLISHED:
   INLINE void set_shader_model(int shader_model);
 
   virtual int get_supported_geom_rendering() const;
+  virtual bool get_supports_cg_profile(const string &name) const;
+
 
   INLINE bool get_color_scale_via_lighting() const;
   INLINE bool get_alpha_scale_via_texture() const;

+ 21 - 0
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -1,5 +1,6 @@
 // Filename: dxGraphicsStateGuardian9.cxx
 // Created by:  mike (02Feb99)
+// Updated by: fperazzi, PandaSE (05May10) (added get_supports_cg_profile)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -5711,6 +5712,26 @@ atexit_function(void) {
   static_set_gamma(true, 1.0f);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DXGraphicsStateGuardian9::get_supports_cg_profile
+//       Access: Public, Virtual
+//  Description: Returns true if this particular GSG supports the 
+//               specified Cg Shader Profile.
+////////////////////////////////////////////////////////////////////
+bool DXGraphicsStateGuardian9::
+get_supports_cg_profile(const string &name) const {
+#ifndef HAVE_CG
+  return false;
+#endif
+  CGprofile profile = cgGetProfile(name.c_str());
+  
+  if (profile ==CG_PROFILE_UNKNOWN) {
+    dxgsg9_cat.error() << name <<", unknown Cg-profile\n";
+    return false;
+  }
+  return cgD3D9IsProfileSupported(cgGetProfile(name.c_str()));
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DXGraphicsStateGuardian9::set_cg_device
 //       Access: Protected, Static

+ 3 - 0
panda/src/dxgsg9/dxGraphicsStateGuardian9.h

@@ -1,5 +1,6 @@
 // Filename: dxGraphicsStateGuardian9.h
 // Created by:  mike (02Feb99)
+// Updated by: fperazzi, PandaSE (05May10) (added get_supports_cg_profile)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -165,6 +166,8 @@ public:
   static void atexit_function(void);
 
   static void set_cg_device(LPDIRECT3DDEVICE9 cg_device);
+  virtual bool get_supports_cg_profile(const string &name) const;
+
 
 protected:
   void do_issue_transform();

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

@@ -1,5 +1,7 @@
 // Filename: glGraphicsStateGuardian_src.cxx
 // Created by:  drose (02Feb99)
+// Updated by: fperazzi, PandaSE (05May10) (added 
+//   get_supports_cg_profile)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -9583,6 +9585,26 @@ do_point_size() {
 #endif
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GLGraphicsStateGuardian::get_supports_cg_profile
+//       Access: Public, Virtual
+//  Description: Returns true if this particular GSG supports the 
+//               specified Cg Shader Profile.
+////////////////////////////////////////////////////////////////////
+bool CLP(GraphicsStateGuardian)::
+get_supports_cg_profile(const string &name) const {
+#ifndef HAVE_CG
+  return false;
+#endif
+  CGprofile profile = cgGetProfile(name.c_str());
+  
+  if (profile ==CG_PROFILE_UNKNOWN) {
+    GLCAT.error() << name <<", unknown Cg-profile\n";
+    return false;
+  }
+  return cgGLIsProfileSupported(profile);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::bind_fbo
 //       Access: Protected

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

@@ -1,5 +1,7 @@
 // Filename: glGraphicsStateGuardian_src.h
 // Created by:  drose (02Feb99)
+// Updated by: fperazzi, PandaSE (05May10) (added 
+//   get_supports_cg_profile)
 //
 ////////////////////////////////////////////////////////////////////
 //
@@ -273,6 +275,8 @@ public:
                                        const TransformState *transform);
 
   void bind_fbo(GLuint fbo);
+  virtual bool get_supports_cg_profile(const string &name) const;
+
 
 protected:
   void do_issue_transform();