diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 191072ed58..f2f0a00fce 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/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 diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 1b78e56a91..8f8a530e69 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/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; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 18e6409381..1dfd1f3bb8 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/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 diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index 6c94e62740..77a140bf19 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/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(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 7d08495eae..6dccf8bee9 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/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 diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index e8823bf592..14685d4165 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/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();