Panda3D
|
00001 // Filename: shader.I 00002 // Heavily Modified: jyelon (Sep05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 //////////////////////////////////////////////////////////////////// 00016 // Function: Shader::get_filename 00017 // Access: Public 00018 // Description: Return the Shader's filename for the given shader 00019 // type. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE const Filename Shader:: 00022 get_filename(const ShaderType &type) const { 00023 if (_filename->_separate) { 00024 nassertr(type != ST_none || !_filename->_shared.empty(), ""); 00025 switch (type) { 00026 case ST_vertex: 00027 return _filename->_vertex; 00028 break; 00029 case ST_fragment: 00030 return _filename->_fragment; 00031 break; 00032 case ST_geometry: 00033 return _filename->_geometry; 00034 break; 00035 default: 00036 return _filename->_shared; 00037 } 00038 } else { 00039 return _filename->_shared; 00040 } 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: Shader::get_text 00045 // Access: Public 00046 // Description: Return the Shader's text for the given shader type. 00047 //////////////////////////////////////////////////////////////////// 00048 INLINE const string Shader:: 00049 get_text(const ShaderType &type) const { 00050 if (_text->_separate) { 00051 nassertr(type != ST_none || !_text->_shared.empty(), ""); 00052 switch (type) { 00053 case ST_vertex: 00054 return _text->_vertex; 00055 break; 00056 case ST_fragment: 00057 return _text->_fragment; 00058 break; 00059 case ST_geometry: 00060 return _text->_geometry; 00061 break; 00062 default: 00063 return _text->_shared; 00064 } 00065 } else { 00066 return _text->_shared; 00067 } 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: Shader::get_error_flag 00072 // Access: Public 00073 // Description: Returns true if the shader contains a compile-time 00074 // error. This doesn't tell you whether or not the 00075 // shader is supported on the current video card. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE const bool Shader:: 00078 get_error_flag() const { 00079 return _error_flag; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: Shader::set_shader_utilization 00084 // Access: Published, Static 00085 // Description: Set this flag to SUT_none, SUT_basic, or 00086 // SUT_advanced to limit panda's automatic shader 00087 // generation facilities. 00088 //////////////////////////////////////////////////////////////////// 00089 INLINE void Shader:: 00090 set_shader_utilization(ShaderUtilization sut) { 00091 _shader_utilization = sut; 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: Shader::get_shader_utilization 00096 // Access: Published, Static 00097 // Description: This flag returns SUT_none, SUT_basic, or 00098 // SUT_advanced and controls the automatic generation 00099 // of shaders. It is initialized from the config 00100 // variable of the same name, but it can be 00101 // subsequently adjusted. 00102 //////////////////////////////////////////////////////////////////// 00103 INLINE ShaderUtilization Shader:: 00104 get_shader_utilization() { 00105 if (_shader_utilization == SUT_UNSPECIFIED) { 00106 return shader_utilization; 00107 } else { 00108 return _shader_utilization; 00109 } 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: Shader::have_shader_utilization 00114 // Access: Published, Static 00115 // Description: If true, then get_shader_utilization has been 00116 // set using set_shader_utilization. 00117 // If false, then get_shader_utilization simply 00118 // returns the config variable of the same name. 00119 //////////////////////////////////////////////////////////////////// 00120 INLINE bool Shader:: 00121 have_shader_utilization() { 00122 return (_shader_utilization != SUT_UNSPECIFIED); 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: Shader::get_language 00127 // Access: Published 00128 // Description: Returns the shader language in which this shader 00129 // was written. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE const Shader::ShaderLanguage Shader:: 00132 get_language() const { 00133 return _language; 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: Shader::ShaderCapabilities Constructor 00138 // Access: Public 00139 // Description: 00140 //////////////////////////////////////////////////////////////////// 00141 INLINE Shader::ShaderCaps:: 00142 ShaderCaps() { 00143 clear(); 00144 } 00145 00146 //////////////////////////////////////////////////////////////////// 00147 // Function: Shader::ShaderCapabilities::operator == 00148 // Access: Public 00149 // Description: 00150 //////////////////////////////////////////////////////////////////// 00151 INLINE bool Shader::ShaderCaps:: 00152 operator == (const ShaderCaps &other) const { 00153 #ifdef HAVE_CG 00154 if ((_active_vprofile != other._active_vprofile) || 00155 (_active_fprofile != other._active_fprofile) || 00156 (_active_gprofile != other._active_gprofile) || 00157 (_ultimate_vprofile != other._ultimate_vprofile) || 00158 (_ultimate_fprofile != other._ultimate_fprofile) || 00159 (_ultimate_gprofile != other._ultimate_gprofile)) { 00160 return false; 00161 } 00162 #endif 00163 return true; 00164 }