mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
extended shader input system support for Cg (see Panda SE Project 2010-03-17 blog post for more details)
This commit is contained in:
parent
749cb5c059
commit
6418e6f221
@ -1,5 +1,6 @@
|
||||
// Filename: graphicsStateGuardian.cxx
|
||||
// Created by: drose (02Feb99)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added fetch_ptr_parameter)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -895,7 +896,7 @@ compute_distance_to(const LPoint3f &point) const {
|
||||
const LMatrix4f *GraphicsStateGuardian::
|
||||
fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) {
|
||||
LVecBase3f v;
|
||||
|
||||
|
||||
if (altered & spec._dep[0]) {
|
||||
const LMatrix4f *t = fetch_specified_part(spec._part[0], spec._arg[0], spec._cache[0]);
|
||||
if (t != &spec._cache[0]) {
|
||||
@ -1250,6 +1251,16 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::fetch_ptr_parameter
|
||||
// Access: Public
|
||||
// Description: Return a pointer to struct ShaderPtrData
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const Shader::ShaderPtrData *GraphicsStateGuardian::
|
||||
fetch_ptr_parameter(const Shader::ShaderPtrSpec& spec){
|
||||
return (_target_shader->get_shader_input_ptr(spec._arg));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::prepare_display_region
|
||||
// Access: Public, Virtual
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Filename: graphicsStateGuardian.h
|
||||
// Created by: drose (02Feb99)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added fetch_ptr_parameter)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -224,7 +225,8 @@ public:
|
||||
|
||||
const LMatrix4f *fetch_specified_value(Shader::ShaderMatSpec &spec, int altered);
|
||||
const LMatrix4f *fetch_specified_part(Shader::ShaderMatInput input, InternalName *name, LMatrix4f &t);
|
||||
|
||||
const Shader::ShaderPtrData *fetch_ptr_parameter(const Shader::ShaderPtrSpec& spec);
|
||||
|
||||
virtual void prepare_display_region(DisplayRegionPipelineReader *dr,
|
||||
Lens::StereoChannel stereo_channel);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Filename: glShaderContext_src.cxx
|
||||
// Created by: jyelon (01Sep05)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (updated CLP with note that some
|
||||
// parameter types only supported under Cg)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -519,6 +521,105 @@ issue_parameters(GSG *gsg, int altered) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate through _ptr parameters
|
||||
for (int i=0; i<(int)_shader->_ptr_spec.size(); i++) {
|
||||
if(altered & (_shader->_ptr_spec[i]._dep[0] | _shader->_ptr_spec[i]._dep[1])){
|
||||
if (_shader->get_language() == Shader::SL_GLSL){
|
||||
GLCAT.error() << _shader->_ptr_spec[i]._id._name << ": parameter type supported only in Cg\n";
|
||||
release_resources(gsg);
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_CG
|
||||
else if (_shader->get_language() == Shader::SL_Cg) {
|
||||
const Shader::ShaderPtrSpec& _ptr = _shader->_ptr_spec[i];
|
||||
Shader::ShaderPtrData* _ptr_data =
|
||||
const_cast< Shader::ShaderPtrData*>(gsg->fetch_ptr_parameter(_ptr));
|
||||
|
||||
if (_ptr_data == NULL){ //the input is not contained in ShaderPtrData
|
||||
release_resources(gsg);
|
||||
return;
|
||||
}
|
||||
//check if the data must be shipped to the GPU
|
||||
/*if (!_ptr_data->_updated)
|
||||
continue;
|
||||
_ptr_data->_updated = false;*/
|
||||
|
||||
//Check if the size of the shader input and _ptr_data match
|
||||
int input_size = _ptr._dim[0] * _ptr._dim[1] * _ptr._dim[2];
|
||||
|
||||
// dimension is negative only if the parameter had the (deprecated)k_ prefix.
|
||||
if ((input_size != _ptr_data->_size) && (_ptr._dim[0] > 0)) {
|
||||
GLCAT.error() << _ptr._id._name << ": incorrect number of elements, expected "
|
||||
<< input_size <<" got " << _ptr_data->_size << "\n";
|
||||
release_resources(gsg);
|
||||
return;
|
||||
}
|
||||
CGparameter p = _cg_parameter_map[_ptr._id._seqno];
|
||||
|
||||
switch(_ptr_data->_type) {
|
||||
case Shader::SPT_float:
|
||||
switch(_ptr._info._class) {
|
||||
case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAC_vector:
|
||||
switch(_ptr._info._type) {
|
||||
case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)_ptr_data->_ptr); continue;
|
||||
}
|
||||
case Shader::SAC_matrix: cgGLSetMatrixParameterfr(p,(float*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAC_array: {
|
||||
switch(_ptr._info._subclass) {
|
||||
case Shader::SAC_scalar:
|
||||
cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAC_vector:
|
||||
switch(_ptr._dim[2]) {
|
||||
case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue;
|
||||
case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue;
|
||||
case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue;
|
||||
case 4: cgGLSetParameterArray4f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue;
|
||||
}
|
||||
case Shader::SAC_matrix:
|
||||
cgGLSetMatrixParameterArrayfr(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
case Shader::SPT_double:
|
||||
switch(_ptr._info._class) {
|
||||
case Shader::SAC_scalar: cgSetParameter1dv(p,(double*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAC_vector:
|
||||
switch(_ptr._info._type) {
|
||||
case Shader::SAT_vec1: cgSetParameter1dv(p,(double*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)_ptr_data->_ptr); continue;
|
||||
}
|
||||
case Shader::SAC_matrix: cgGLSetMatrixParameterdr(p,(double*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAC_array: {
|
||||
switch(_ptr._info._subclass) {
|
||||
case Shader::SAC_scalar:
|
||||
cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue;
|
||||
case Shader::SAC_vector:
|
||||
switch(_ptr._dim[2]) {
|
||||
case 1: cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue;
|
||||
case 2: cgGLSetParameterArray2d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue;
|
||||
case 3: cgGLSetParameterArray3d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue;
|
||||
case 4: cgGLSetParameterArray4d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue;
|
||||
}
|
||||
case Shader::SAC_matrix:
|
||||
cgGLSetMatrixParameterArraydr(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
default: GLCAT.error() << _ptr._id._name << ":" << "unrecognized parameter type\n";
|
||||
release_resources(gsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: this could be much faster if we used deferred parameter setting.
|
||||
|
||||
for (int i=0; i<(int)_shader->_mat_spec.size(); i++) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Filename: shader.I
|
||||
// Heavily Modified: jyelon (Sep05)
|
||||
//
|
||||
// Updated by: fperazzi, PandaSE(06Apr10)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
@ -45,10 +45,10 @@ get_filename(const ShaderType &type) const {
|
||||
// Access: Public
|
||||
// Description: Return the Shader's text for the given shader type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const string &Shader::
|
||||
INLINE const string Shader::
|
||||
get_text(const ShaderType &type) const {
|
||||
if (_text->_separate) {
|
||||
nassertr(type != ST_none || !_text->_shared.empty(), _text->_shared);
|
||||
nassertr(type != ST_none || !_text->_shared.empty(), "");
|
||||
switch (type) {
|
||||
case ST_vertex:
|
||||
return _text->_vertex;
|
||||
@ -162,3 +162,281 @@ operator == (const ShaderCaps &other) const {
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData():
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(NULL),
|
||||
_type(SPT_unknown),
|
||||
_updated(true),
|
||||
_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_float& ptr):
|
||||
_pta_float(ptr),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(ptr.size())
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_double& ptr):
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(ptr),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_double),
|
||||
_updated(true),
|
||||
_size(ptr.size())
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_LMatrix4f& ptr):
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(ptr),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(ptr.size()*16)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_LMatrix3f& ptr):
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(ptr),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(ptr.size()*9)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_LVecBase4f& ptr):
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(ptr),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(ptr.size()*4)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_LVecBase3f& ptr):
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(ptr),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(ptr.size()*3)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const PTA_LVecBase2f& ptr):
|
||||
_pta_float(PTA_float::empty_array(0)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(ptr),
|
||||
_ptr(ptr.p()),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(ptr.size()*2)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const LVecBase4f& lvec4):
|
||||
_pta_float(PTA_float::empty_array(4)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(4)
|
||||
{
|
||||
_ptr = _pta_float.p();
|
||||
memcpy(_pta_float, lvec4._v.data, sizeof(lvec4._v.data));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const LVecBase3f& lvec3):
|
||||
_pta_float(PTA_float::empty_array(3)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(3)
|
||||
{
|
||||
_ptr = _pta_float.p();
|
||||
memcpy(_pta_float, lvec3._v.data, sizeof(lvec3._v.data));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const LVecBase2f& lvec2):
|
||||
_pta_float(PTA_float::empty_array(2)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_type(SPT_double),
|
||||
_updated(true),
|
||||
_size(2)
|
||||
{
|
||||
_ptr = _pta_float.p();
|
||||
memcpy(_pta_float,lvec2._v.data, sizeof(lvec2._v.data));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const LMatrix4f& lmat4):
|
||||
_pta_float(PTA_float::empty_array(16)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(16)
|
||||
{
|
||||
_ptr = _pta_float.p();
|
||||
memcpy(_pta_float,lmat4._m.data, sizeof(lmat4._m.data));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::ShaderPtrData Constructor
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Shader::ShaderPtrData::
|
||||
ShaderPtrData(const LMatrix3f& lmat3):
|
||||
_pta_float(PTA_float::empty_array(9)),
|
||||
_pta_double(PTA_double::empty_array(0)),
|
||||
_pta_lmat4f(PTA_LMatrix4f::empty_array(0)),
|
||||
_pta_lmat3f(PTA_LMatrix3f::empty_array(0)),
|
||||
_pta_lvec4f(PTA_LVecBase4f::empty_array(0)),
|
||||
_pta_lvec3f(PTA_LVecBase3f::empty_array(0)),
|
||||
_pta_lvec2f(PTA_LVecBase2f::empty_array(0)),
|
||||
_type(SPT_float),
|
||||
_updated(true),
|
||||
_size(9)
|
||||
{
|
||||
_ptr = _pta_float.p();
|
||||
memcpy(_pta_float,lmat3._m.data, sizeof(lmat3._m.data));
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Filename: shader.cxx
|
||||
// Created by: jyelon (01Sep05)
|
||||
//
|
||||
// Updated by: fperazzi, PandaSE(06Apr10)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
@ -37,33 +37,67 @@ ShaderUtilization Shader::_shader_utilization = SUT_UNSPECIFIED;
|
||||
// of the specified parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Shader::
|
||||
cp_report_error(ShaderArgInfo &p, const string &msg) {
|
||||
cp_report_error(ShaderArgInfo &p, const string &msg) {
|
||||
|
||||
string vstr;
|
||||
if (p._varying) vstr = "varying ";
|
||||
else vstr = "uniform ";
|
||||
if (p._varying) {
|
||||
vstr = "varying ";
|
||||
} else {
|
||||
vstr = "uniform ";
|
||||
}
|
||||
|
||||
string dstr = "unknown ";
|
||||
if (p._direction == SAD_in) dstr = "in ";
|
||||
if (p._direction == SAD_out) dstr = "out ";
|
||||
if (p._direction == SAD_inout) dstr = "inout ";
|
||||
if (p._direction == SAD_in) {
|
||||
dstr = "in ";
|
||||
} else if (p._direction == SAD_out) {
|
||||
dstr = "out ";
|
||||
} else if (p._direction == SAD_inout) {
|
||||
dstr = "inout ";
|
||||
}
|
||||
|
||||
string tstr = "invalid ";
|
||||
switch (p._type) {
|
||||
case SAT_float1: tstr = "float1 "; break;
|
||||
case SAT_float2: tstr = "float2 "; break;
|
||||
case SAT_float3: tstr = "float3 "; break;
|
||||
case SAT_float4: tstr = "float4 "; break;
|
||||
case SAT_float4x4: tstr = "float4x4 "; break;
|
||||
case SAT_sampler1d: tstr = "sampler1d "; break;
|
||||
case SAT_sampler2d: tstr = "sampler2d "; break;
|
||||
case SAT_sampler3d: tstr = "sampler3d "; break;
|
||||
case SAT_samplercube: tstr = "samplercube "; break;
|
||||
case SAT_unknown: tstr = "unknown "; break;
|
||||
case SAT_scalar: tstr = "scalar "; break;
|
||||
case SAT_vec1: tstr = "vec1 "; break;
|
||||
case SAT_vec2: tstr = "vec2 "; break;
|
||||
case SAT_vec3: tstr = "vec3 "; break;
|
||||
case SAT_vec4: tstr = "vec4 "; break;
|
||||
case SAT_mat1x1: tstr = "mat1x1 "; break;
|
||||
case SAT_mat1x2: tstr = "mat1x2 "; break;
|
||||
case SAT_mat1x3: tstr = "mat1x3 "; break;
|
||||
case SAT_mat1x4: tstr = "mat1x4 "; break;
|
||||
case SAT_mat2x1: tstr = "mat2x1 "; break;
|
||||
case SAT_mat2x2: tstr = "mat2x2 "; break;
|
||||
case SAT_mat2x3: tstr = "mat2x3 "; break;
|
||||
case SAT_mat2x4: tstr = "mat2x4 "; break;
|
||||
case SAT_mat3x1: tstr = "mat3x1 "; break;
|
||||
case SAT_mat3x2: tstr = "mat3x2 "; break;
|
||||
case SAT_mat3x3: tstr = "mat3x3 "; break;
|
||||
case SAT_mat3x4: tstr = "mat3x4 "; break;
|
||||
case SAT_mat4x1: tstr = "mat4x1 "; break;
|
||||
case SAT_mat4x2: tstr = "mat4x2 "; break;
|
||||
case SAT_mat4x3: tstr = "mat4x3 "; break;
|
||||
case SAT_mat4x4: tstr = "mat4x4 "; break;
|
||||
case SAT_sampler1d: tstr = "sampler1d "; break;
|
||||
case SAT_sampler2d: tstr = "sampler2d "; break;
|
||||
case SAT_sampler3d: tstr = "sampler3d "; break;
|
||||
case SAT_samplercube: tstr = "samplercube "; break;
|
||||
default: tstr = "unknown "; break;
|
||||
}
|
||||
|
||||
string cstr = "invalid";
|
||||
switch (p._class) {
|
||||
case SAC_scalar: cstr = "scalar "; break;
|
||||
case SAC_vector: cstr = "vector "; break;
|
||||
case SAC_matrix: cstr = "matrix "; break;
|
||||
case SAC_sampler: cstr = "sampler "; break;
|
||||
case SAC_array: cstr = "array "; break;
|
||||
default: cstr = "unknown ";break;
|
||||
}
|
||||
|
||||
Filename fn = get_filename(p._id._type);
|
||||
p._cat->error() << fn << ": " << msg << " (" <<
|
||||
vstr << dstr << tstr << p._id._name << ")\n";
|
||||
p._cat->error() << fn << ": " << vstr << dstr << tstr <<
|
||||
p._id._name << ": " << msg << "\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -148,21 +182,50 @@ cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi)
|
||||
{
|
||||
int nfloat;
|
||||
switch (p._type) {
|
||||
case SAT_float1: nfloat = 1; break;
|
||||
case SAT_float2: nfloat = 2; break;
|
||||
case SAT_float3: nfloat = 3; break;
|
||||
case SAT_float4: nfloat = 4; break;
|
||||
case SAT_float4x4: nfloat = 16; break;
|
||||
case SAT_scalar: nfloat = 1; break;
|
||||
case SAT_vec2: nfloat = 2; break;
|
||||
case SAT_vec3: nfloat = 3; break;
|
||||
case SAT_vec4: nfloat = 4; break;
|
||||
case SAT_mat4x4: nfloat = 16; break;
|
||||
default: nfloat = 0; break;
|
||||
}
|
||||
if ((nfloat < lo)||(nfloat > hi)) {
|
||||
string msg = "wrong type for parameter: should be float";
|
||||
string msg = "wrong type for parameter:";
|
||||
cp_report_error(p, msg);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::cp_errchk_parameter_ptr
|
||||
// Access: Public, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Shader::
|
||||
cp_errchk_parameter_ptr(ShaderArgInfo &p)
|
||||
{
|
||||
switch(p._class) {
|
||||
case SAC_scalar: return true;
|
||||
case SAC_vector: return true;
|
||||
case SAC_matrix: return true;
|
||||
case SAC_array:
|
||||
switch(p._subclass){
|
||||
case SAC_scalar: return true;
|
||||
case SAC_vector: return true;
|
||||
case SAC_matrix: return true;
|
||||
default:
|
||||
string msg = "unsupported array subclass.";
|
||||
cp_report_error(p,msg);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
string msg = "unsupported class.";
|
||||
cp_report_error(p,msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::cp_errchk_parameter_sampler
|
||||
// Access: Public, Static
|
||||
@ -352,9 +415,9 @@ cp_dependency(ShaderMatInput inp) {
|
||||
(inp == SMO_plight_x)||
|
||||
(inp == SMO_slight_x)||
|
||||
(inp == SMO_satten_x)||
|
||||
(inp == SMO_clipplane_x)||
|
||||
(inp == SMO_mat_constant_x)||
|
||||
(inp == SMO_vec_constant_x)||
|
||||
(inp == SMO_clipplane_x)||
|
||||
(inp == SMO_view_x_to_view)||
|
||||
(inp == SMO_view_to_view_x)||
|
||||
(inp == SMO_apiview_x_to_view)||
|
||||
@ -406,6 +469,59 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) {
|
||||
spec._dep[1] = cp_dependency(spec._part[1]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::recurse_parameters
|
||||
// Access: Public
|
||||
// Description:
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Shader::recurse_parameters(CGparameter parameter,
|
||||
const ShaderType& type, bool& success) {
|
||||
|
||||
if (parameter == 0)
|
||||
return;
|
||||
|
||||
do {
|
||||
int arg_dim[] = {1,0,0};
|
||||
ShaderArgDir arg_dir = cg_parameter_dir(parameter);
|
||||
ShaderArgType arg_type = cg_parameter_type(parameter);
|
||||
ShaderArgClass arg_class = cg_parameter_class(parameter);
|
||||
ShaderArgClass arg_subclass = arg_class;
|
||||
|
||||
CGenum vbl = cgGetParameterVariability(parameter);
|
||||
|
||||
if ((vbl==CG_VARYING)||(vbl==CG_UNIFORM)){
|
||||
switch(cgGetParameterType(parameter)) {
|
||||
case CG_STRUCT:
|
||||
recurse_parameters(
|
||||
cgGetFirstStructParameter(parameter),type,success); break;
|
||||
|
||||
case CG_ARRAY:
|
||||
arg_type = cg_parameter_type(cgGetFirstStructParameter(parameter));
|
||||
arg_subclass = cg_parameter_class(cgGetFirstStructParameter(parameter));
|
||||
|
||||
arg_dim[0] = cgGetArraySize(parameter,0);
|
||||
|
||||
//Uncomment this to parse the array[n] as n separeted elements
|
||||
//recurse_program_parameters(
|
||||
// cgGetFirstStructParameter(parameter),type,success); break;
|
||||
|
||||
default:{
|
||||
arg_dim[1] = cgGetParameterRows(parameter);
|
||||
arg_dim[2] = cgGetParameterColumns(parameter);
|
||||
|
||||
ShaderArgId id;
|
||||
id._name = cgGetParameterName(parameter);
|
||||
id._type = type;
|
||||
id._seqno = -1;
|
||||
success &= compile_parameter(id, arg_class, arg_subclass, arg_type,
|
||||
arg_dir, (vbl == CG_VARYING), arg_dim, gobj_cat.get_safe_ptr()); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while((parameter = cgGetNextParameter(parameter))!= 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::compile_parameter
|
||||
// Access: Public
|
||||
@ -418,14 +534,19 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) {
|
||||
// an error message onto the error messages.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Shader::
|
||||
compile_parameter(const ShaderArgId &arg_id,
|
||||
ShaderArgType arg_type,
|
||||
ShaderArgDir arg_direction,
|
||||
bool arg_varying,
|
||||
NotifyCategory *arg_cat)
|
||||
compile_parameter(const ShaderArgId &arg_id,
|
||||
const ShaderArgClass &arg_class,
|
||||
const ShaderArgClass &arg_subclass,
|
||||
const ShaderArgType &arg_type,
|
||||
const ShaderArgDir &arg_direction,
|
||||
bool arg_varying,
|
||||
int *arg_dim,
|
||||
NotifyCategory *arg_cat)
|
||||
{
|
||||
ShaderArgInfo p;
|
||||
p._id = arg_id;
|
||||
p._class = arg_class;
|
||||
p._subclass = arg_subclass;
|
||||
p._type = arg_type;
|
||||
p._direction = arg_direction;
|
||||
p._varying = arg_varying;
|
||||
@ -437,28 +558,24 @@ compile_parameter(const ShaderArgId &arg_id,
|
||||
// It could be inside a struct, strip off
|
||||
// everything before the last dot.
|
||||
size_t loc = p._id._name.find_last_of('.');
|
||||
|
||||
string basename (p._id._name);
|
||||
if (loc < string::npos) {
|
||||
string struct_name ("");
|
||||
|
||||
if (loc < string::npos) {
|
||||
basename = p._id._name.substr(loc + 1);
|
||||
struct_name = p._id._name.substr(0,loc+1);
|
||||
}
|
||||
|
||||
// Ignore inputs that are prefixed by two underscores
|
||||
// This is to support geometry shaders correctly.
|
||||
if (basename.size() >= 2 && basename.substr(0, 2) == "__") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Split it at the underscores.
|
||||
vector_string pieces;
|
||||
tokenize(basename, pieces, "_");
|
||||
|
||||
if (pieces.size() < 2) {
|
||||
cp_report_error(p, "invalid parameter name");
|
||||
return false;
|
||||
if (basename.size() >= 2 && basename.substr(0, 2) == "__") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implement vtx parameters - the varying kind.
|
||||
|
||||
if (pieces[0] == "vtx") {
|
||||
if ((!cp_errchk_parameter_in(p)) ||
|
||||
(!cp_errchk_parameter_varying(p)) ||
|
||||
@ -919,88 +1036,6 @@ compile_parameter(const ShaderArgId &arg_id,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keywords to access constants.
|
||||
|
||||
if (pieces[0] == "k") {
|
||||
if ((!cp_errchk_parameter_in(p)) ||
|
||||
(!cp_errchk_parameter_uniform(p)))
|
||||
return false;
|
||||
// In the case of k-parameters, we allow underscores in the name.
|
||||
PT(InternalName) kinputname = InternalName::make(basename.substr(2));
|
||||
switch (p._type) {
|
||||
case SAT_float1:
|
||||
case SAT_float2:
|
||||
case SAT_float3:
|
||||
case SAT_float4: {
|
||||
ShaderMatSpec bind;
|
||||
bind._id = arg_id;
|
||||
switch (p._type) {
|
||||
case SAT_float1: bind._piece = SMP_row3x1; break;
|
||||
case SAT_float2: bind._piece = SMP_row3x2; break;
|
||||
case SAT_float3: bind._piece = SMP_row3x3; break;
|
||||
case SAT_float4: bind._piece = SMP_row3; break;
|
||||
}
|
||||
bind._func = SMF_first;
|
||||
bind._part[0] = SMO_vec_constant_x;
|
||||
bind._arg[0] = kinputname;
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
cp_optimize_mat_spec(bind);
|
||||
_mat_spec.push_back(bind);
|
||||
break;
|
||||
}
|
||||
case SAT_float4x4: {
|
||||
ShaderMatSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._piece = SMP_whole;
|
||||
bind._func = SMF_first;
|
||||
bind._part[0] = SMO_mat_constant_x;
|
||||
bind._arg[0] = kinputname;
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
cp_optimize_mat_spec(bind);
|
||||
_mat_spec.push_back(bind);
|
||||
break;
|
||||
}
|
||||
case SAT_sampler1d: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type=Texture::TT_1d_texture;
|
||||
_tex_spec.push_back(bind);
|
||||
break;
|
||||
}
|
||||
case SAT_sampler2d: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type=Texture::TT_2d_texture;
|
||||
_tex_spec.push_back(bind);
|
||||
break;
|
||||
}
|
||||
case SAT_sampler3d: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type=Texture::TT_3d_texture;
|
||||
_tex_spec.push_back(bind);
|
||||
break;
|
||||
}
|
||||
case SAT_samplercube: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type = Texture::TT_cube_map;
|
||||
_tex_spec.push_back(bind);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
cp_report_error(p, "Invalid type for a k-parameter");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keywords to fetch texture parameter data.
|
||||
|
||||
if (pieces[0] == "texpad") {
|
||||
@ -1053,6 +1088,89 @@ compile_parameter(const ShaderArgId &arg_id,
|
||||
return true; // Cg handles this automatically.
|
||||
}
|
||||
|
||||
// Fetch uniform parameters without prefix
|
||||
|
||||
if ((!cp_errchk_parameter_in(p)) ||
|
||||
(!cp_errchk_parameter_uniform(p))) {
|
||||
return false;
|
||||
}
|
||||
bool k_prefix = false;
|
||||
|
||||
// solve backward compatibility issue
|
||||
if (pieces[0] == "k") {
|
||||
k_prefix = true;
|
||||
basename = basename.substr(2);
|
||||
}
|
||||
|
||||
PT(InternalName) kinputname = InternalName::make(struct_name + basename);
|
||||
|
||||
switch (p._class) {
|
||||
case SAC_vector:
|
||||
case SAC_matrix:
|
||||
case SAC_scalar:
|
||||
case SAC_array: {
|
||||
if (!cp_errchk_parameter_ptr(p))
|
||||
return false;
|
||||
|
||||
ShaderPtrSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._arg = kinputname;
|
||||
bind._info = p;
|
||||
bind._dep[0] = SSD_general | SSD_shaderinputs;
|
||||
bind._dep[1] = SSD_general | SSD_NONE;
|
||||
|
||||
memcpy(bind._dim,arg_dim,sizeof(int)*3);
|
||||
|
||||
// if dim[0] = -1, glShaderContext will not check the param size
|
||||
if (k_prefix) bind._dim[0] = -1;
|
||||
_ptr_spec.push_back(bind);
|
||||
return true;
|
||||
}
|
||||
|
||||
case SAC_sampler: {
|
||||
switch (p._type) {
|
||||
case SAT_sampler1d: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type=Texture::TT_1d_texture;
|
||||
_tex_spec.push_back(bind);
|
||||
return true;
|
||||
}
|
||||
case SAT_sampler2d: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type=Texture::TT_2d_texture;
|
||||
_tex_spec.push_back(bind);
|
||||
return true;
|
||||
}
|
||||
case SAT_sampler3d: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type=Texture::TT_3d_texture;
|
||||
_tex_spec.push_back(bind);
|
||||
return true;
|
||||
}
|
||||
case SAT_samplercube: {
|
||||
ShaderTexSpec bind;
|
||||
bind._id = arg_id;
|
||||
bind._name = kinputname;
|
||||
bind._desired_type = Texture::TT_cube_map;
|
||||
_tex_spec.push_back(bind);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
cp_report_error(p, "invalid type for non-prefix parameter");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
cp_report_error(p, "invalid class for non-prefix parameter");
|
||||
return false;
|
||||
}
|
||||
|
||||
cp_report_error(p, "unrecognized parameter name");
|
||||
return false;
|
||||
}
|
||||
@ -1078,17 +1196,79 @@ clear_parameters() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Shader::ShaderArgType Shader::
|
||||
cg_parameter_type(CGparameter p) {
|
||||
switch (cgGetParameterType(p)) {
|
||||
case CG_FLOAT1: return Shader::SAT_float1;
|
||||
case CG_FLOAT2: return Shader::SAT_float2;
|
||||
case CG_FLOAT3: return Shader::SAT_float3;
|
||||
case CG_FLOAT4: return Shader::SAT_float4;
|
||||
case CG_FLOAT4x4: return Shader::SAT_float4x4;
|
||||
case CG_SAMPLER1D: return Shader::SAT_sampler1d;
|
||||
case CG_SAMPLER2D: return Shader::SAT_sampler2d;
|
||||
case CG_SAMPLER3D: return Shader::SAT_sampler3d;
|
||||
case CG_SAMPLERCUBE: return Shader::SAT_samplercube;
|
||||
default: return Shader::SAT_unknown;
|
||||
|
||||
switch (cgGetParameterClass(p)) {
|
||||
case CG_PARAMETERCLASS_SCALAR: return SAT_scalar;
|
||||
case CG_PARAMETERCLASS_VECTOR:
|
||||
switch(cgGetParameterColumns(p)){
|
||||
case 1: return SAT_vec1;
|
||||
case 2: return SAT_vec2;
|
||||
case 3: return SAT_vec3;
|
||||
case 4: return SAT_vec4;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
case CG_PARAMETERCLASS_MATRIX:
|
||||
switch(cgGetParameterRows(p)){
|
||||
case 1:
|
||||
switch(cgGetParameterColumns(p)){
|
||||
case 1: return SAT_mat1x1;
|
||||
case 2: return SAT_mat1x2;
|
||||
case 3: return SAT_mat1x3;
|
||||
case 4: return SAT_mat1x4;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
case 2:
|
||||
switch(cgGetParameterColumns(p)){
|
||||
case 1: return SAT_mat2x1;
|
||||
case 2: return SAT_mat2x2;
|
||||
case 3: return SAT_mat2x3;
|
||||
case 4: return SAT_mat2x4;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
case 3:
|
||||
switch(cgGetParameterColumns(p)){
|
||||
case 1: return SAT_mat3x1;
|
||||
case 2: return SAT_mat3x2;
|
||||
case 3: return SAT_mat3x3;
|
||||
case 4: return SAT_mat3x4;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
case 4:
|
||||
switch(cgGetParameterColumns(p)){
|
||||
case 1: return SAT_mat4x1;
|
||||
case 2: return SAT_mat4x2;
|
||||
case 3: return SAT_mat4x3;
|
||||
case 4: return SAT_mat4x4;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
case CG_PARAMETERCLASS_SAMPLER:
|
||||
switch(cgGetParameterType(p)){
|
||||
case CG_SAMPLER1D: return Shader::SAT_sampler1d;
|
||||
case CG_SAMPLER2D: return Shader::SAT_sampler2d;
|
||||
case CG_SAMPLER3D: return Shader::SAT_sampler3d;
|
||||
case CG_SAMPLERCUBE: return Shader::SAT_samplercube;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
case CG_PARAMETERCLASS_ARRAY: return SAT_unknown;
|
||||
default: return SAT_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Shader::cg_parameter_class
|
||||
// Access: Private
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Shader::ShaderArgClass Shader::cg_parameter_class(CGparameter p) {
|
||||
switch (cgGetParameterClass(p)) {
|
||||
case CG_PARAMETERCLASS_SCALAR: return Shader::SAC_scalar;
|
||||
case CG_PARAMETERCLASS_VECTOR: return Shader::SAC_vector;
|
||||
case CG_PARAMETERCLASS_MATRIX: return Shader::SAC_matrix;
|
||||
case CG_PARAMETERCLASS_SAMPLER: return Shader::SAC_sampler;
|
||||
case CG_PARAMETERCLASS_ARRAY: return Shader::SAC_array;
|
||||
default: return Shader::SAC_unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1148,20 +1328,20 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, ShaderType typ
|
||||
int active, ultimate;
|
||||
|
||||
switch(type) {
|
||||
case ST_vertex:
|
||||
active = caps._active_vprofile;
|
||||
ultimate = caps._ultimate_vprofile;
|
||||
break;
|
||||
case ST_vertex:
|
||||
active = caps._active_vprofile;
|
||||
ultimate = caps._ultimate_vprofile;
|
||||
break;
|
||||
|
||||
case ST_fragment:
|
||||
active = caps._active_fprofile;
|
||||
ultimate = caps._ultimate_fprofile;
|
||||
break;
|
||||
case ST_fragment:
|
||||
active = caps._active_fprofile;
|
||||
ultimate = caps._ultimate_fprofile;
|
||||
break;
|
||||
|
||||
case ST_geometry:
|
||||
active = caps._active_gprofile;
|
||||
ultimate = caps._ultimate_gprofile;
|
||||
break;
|
||||
case ST_geometry:
|
||||
active = caps._active_gprofile;
|
||||
ultimate = caps._ultimate_gprofile;
|
||||
break;
|
||||
};
|
||||
|
||||
cgGetError();
|
||||
@ -1285,24 +1465,8 @@ bool Shader::
|
||||
cg_analyze_entry_point(CGprogram prog, ShaderType type) {
|
||||
CGparameter parameter;
|
||||
bool success = true;
|
||||
for (parameter = cgGetFirstLeafParameter(prog, CG_PROGRAM);
|
||||
parameter != 0;
|
||||
parameter = cgGetNextLeafParameter(parameter)) {
|
||||
CGenum vbl = cgGetParameterVariability(parameter);
|
||||
|
||||
if ((vbl==CG_VARYING)||(vbl==CG_UNIFORM)) {
|
||||
ShaderArgId id;
|
||||
id._name = cgGetParameterName(parameter);
|
||||
|
||||
id._type = type;
|
||||
id._seqno = -1;
|
||||
success &= compile_parameter(id,
|
||||
cg_parameter_type(parameter),
|
||||
cg_parameter_dir(parameter),
|
||||
(vbl == CG_VARYING),
|
||||
gobj_cat.get_safe_ptr());
|
||||
}
|
||||
}
|
||||
recurse_parameters(cgGetFirstParameter(prog, CG_PROGRAM),type,success);
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -1389,6 +1553,11 @@ cg_analyze_shader(const ShaderCaps &caps) {
|
||||
_var_spec[i]._id._seqno = seqno++;
|
||||
}
|
||||
|
||||
for (int i=0; i<(int)_ptr_spec.size(); i++) {
|
||||
_ptr_spec[i]._id._seqno = seqno++;
|
||||
_ptr_spec[i]._info._id = _ptr_spec[i]._id;
|
||||
}
|
||||
|
||||
// DEBUG: output the generated program
|
||||
if (gobj_cat.is_debug()) {
|
||||
const char *vertex_program;
|
||||
@ -1580,8 +1749,9 @@ cg_compile_for(const ShaderCaps &caps,
|
||||
int n_mat = (int)_mat_spec.size();
|
||||
int n_tex = (int)_tex_spec.size();
|
||||
int n_var = (int)_var_spec.size();
|
||||
int n_ptr = (int)_ptr_spec.size();
|
||||
|
||||
map.resize(n_mat + n_tex + n_var);
|
||||
map.resize(n_mat + n_tex + n_var + n_ptr);
|
||||
|
||||
for (int i=0; i<n_mat; i++) {
|
||||
const ShaderArgId &id = _mat_spec[i]._id;
|
||||
@ -1606,9 +1776,14 @@ cg_compile_for(const ShaderCaps &caps,
|
||||
map[id._seqno] = 0;
|
||||
}
|
||||
}
|
||||
for (int i=0; i<n_ptr; i++) {
|
||||
const ShaderArgId &id = _ptr_spec[i]._id;
|
||||
|
||||
CGprogram prog = cg_program_from_shadertype(id._type); // CG2 CHANGE
|
||||
map[id._seqno] = cgGetNamedParameter(prog, id._name.c_str());
|
||||
}
|
||||
|
||||
// Transfer ownership of the compiled shader.
|
||||
|
||||
ctx = _cg_context;
|
||||
vprogram = _cg_vprogram;
|
||||
fprogram = _cg_fprogram;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Filename: shader.h
|
||||
// Created by: jyelon (01Sep05)
|
||||
//
|
||||
// Created by: jyelon (01Sep05)
|
||||
// Updated by: fperazzi, PandaSE(06Apr10)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
@ -20,20 +20,29 @@
|
||||
#include "namable.h"
|
||||
#include "graphicsStateGuardianBase.h"
|
||||
#include "internalName.h"
|
||||
#include "pta_float.h"
|
||||
#include "pta_double.h"
|
||||
#include "pta_LMatrix4f.h"
|
||||
#include "pta_LMatrix3f.h"
|
||||
#include "pta_LVecBase4f.h"
|
||||
#include "pta_LVecBase3f.h"
|
||||
#include "pta_LVecBase2f.h"
|
||||
|
||||
#ifdef HAVE_CG
|
||||
// I don't want to include the Cg header file into panda as a
|
||||
// whole. Instead, I'll just excerpt some opaque declarations.
|
||||
typedef struct _CGcontext *CGcontext;
|
||||
typedef struct _CGprogram *CGprogram;
|
||||
typedef struct _CGcontext *CGcontext;
|
||||
typedef struct _CGprogram *CGprogram;
|
||||
typedef struct _CGparameter *CGparameter;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : Shader
|
||||
// Summary:
|
||||
// Summary: The Shader class is meant to select the Shader Language,
|
||||
// select the available profile, compile the shader, and
|
||||
// finally compile and store the shader parameters
|
||||
// in the appropriate structure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EXPCL_PANDA_GOBJ Shader: public TypedReferenceCount {
|
||||
|
||||
PUBLISHED:
|
||||
@ -43,6 +52,7 @@ PUBLISHED:
|
||||
SL_Cg,
|
||||
SL_GLSL
|
||||
};
|
||||
|
||||
enum ShaderType {
|
||||
ST_none = 0,
|
||||
ST_vertex,
|
||||
@ -56,7 +66,7 @@ PUBLISHED:
|
||||
static PT(Shader) make(const ShaderLanguage &lang, const string &vertex, const string &fragment, const string &geometry = "");
|
||||
|
||||
INLINE const Filename get_filename(const ShaderType &type = ST_none) const;
|
||||
INLINE const string &get_text(const ShaderType &type = ST_none) const;
|
||||
INLINE const string get_text(const ShaderType &type = ST_none) const;
|
||||
INLINE const bool get_error_flag() const;
|
||||
INLINE const ShaderLanguage get_language() const;
|
||||
|
||||
@ -97,7 +107,7 @@ public:
|
||||
|
||||
SMO_mat_constant_x,
|
||||
SMO_vec_constant_x,
|
||||
|
||||
|
||||
SMO_world_to_view,
|
||||
SMO_view_to_world,
|
||||
|
||||
@ -127,19 +137,44 @@ public:
|
||||
|
||||
SMO_INVALID
|
||||
};
|
||||
|
||||
enum ShaderArgType {
|
||||
SAT_float1,
|
||||
SAT_float2,
|
||||
SAT_float3,
|
||||
SAT_float4,
|
||||
SAT_float4x4,
|
||||
|
||||
enum ShaderArgClass {
|
||||
SAC_scalar,
|
||||
SAC_vector,
|
||||
SAC_matrix,
|
||||
SAC_sampler,
|
||||
SAC_array,
|
||||
SAC_unknown,
|
||||
};
|
||||
|
||||
enum ShaderArgType {
|
||||
SAT_scalar,
|
||||
SAT_vec1,
|
||||
SAT_vec2,
|
||||
SAT_vec3,
|
||||
SAT_vec4,
|
||||
SAT_mat1x1,
|
||||
SAT_mat1x2,
|
||||
SAT_mat1x3,
|
||||
SAT_mat1x4,
|
||||
SAT_mat2x1,
|
||||
SAT_mat2x2,
|
||||
SAT_mat2x3,
|
||||
SAT_mat2x4,
|
||||
SAT_mat3x1,
|
||||
SAT_mat3x2,
|
||||
SAT_mat3x3,
|
||||
SAT_mat3x4,
|
||||
SAT_mat4x1,
|
||||
SAT_mat4x2,
|
||||
SAT_mat4x3,
|
||||
SAT_mat4x4,
|
||||
SAT_sampler1d,
|
||||
SAT_sampler2d,
|
||||
SAT_sampler3d,
|
||||
SAT_sampler3d,
|
||||
SAT_samplercube,
|
||||
SAT_unknown,
|
||||
};
|
||||
SAT_unknown
|
||||
};
|
||||
|
||||
enum ShaderArgDir {
|
||||
SAD_in,
|
||||
@ -185,13 +220,62 @@ public:
|
||||
SMF_transform_slight,
|
||||
SMF_first,
|
||||
};
|
||||
|
||||
|
||||
struct ShaderArgId {
|
||||
string _name;
|
||||
ShaderType _type;
|
||||
int _seqno;
|
||||
};
|
||||
};
|
||||
|
||||
struct ShaderArgInfo {
|
||||
ShaderArgId _id;
|
||||
ShaderArgClass _class;
|
||||
ShaderArgClass _subclass;
|
||||
ShaderArgType _type;
|
||||
ShaderArgDir _direction;
|
||||
bool _varying;
|
||||
NotifyCategory *_cat;
|
||||
};
|
||||
|
||||
enum ShaderPtrType {
|
||||
SPT_float,
|
||||
SPT_double,
|
||||
SPT_unknown
|
||||
};
|
||||
|
||||
// Container structure for data of parameters ShaderPtrSpec.
|
||||
struct ShaderPtrData{
|
||||
public:
|
||||
ShaderPtrType _type;
|
||||
int _size; //number of elements vec3[4]=12
|
||||
bool _updated;
|
||||
void* _ptr;
|
||||
|
||||
private:
|
||||
PTA_float _pta_float;
|
||||
PTA_double _pta_double;
|
||||
PTA_LVecBase4f _pta_lvec4f;
|
||||
PTA_LVecBase3f _pta_lvec3f;
|
||||
PTA_LVecBase2f _pta_lvec2f;
|
||||
PTA_LMatrix4f _pta_lmat4f;
|
||||
PTA_LMatrix3f _pta_lmat3f;
|
||||
|
||||
public:
|
||||
INLINE ShaderPtrData();
|
||||
INLINE ShaderPtrData(const PTA_float& ptr);
|
||||
INLINE ShaderPtrData(const PTA_double& ptr);
|
||||
INLINE ShaderPtrData(const PTA_LVecBase4f& ptr);
|
||||
INLINE ShaderPtrData(const PTA_LVecBase3f& ptr);
|
||||
INLINE ShaderPtrData(const PTA_LVecBase2f& ptr);
|
||||
INLINE ShaderPtrData(const PTA_LMatrix4f& mat);
|
||||
INLINE ShaderPtrData(const PTA_LMatrix3f& mat);
|
||||
INLINE ShaderPtrData(const LVecBase4f& vec);
|
||||
INLINE ShaderPtrData(const LVecBase3f& vec);
|
||||
INLINE ShaderPtrData(const LVecBase2f& vec);
|
||||
INLINE ShaderPtrData(const LMatrix4f& mat);
|
||||
INLINE ShaderPtrData(const LMatrix3f& mat);
|
||||
};
|
||||
|
||||
struct ShaderMatSpec {
|
||||
ShaderArgId _id;
|
||||
ShaderMatFunc _func;
|
||||
@ -216,13 +300,13 @@ public:
|
||||
PT(InternalName) _name;
|
||||
int _append_uv;
|
||||
};
|
||||
|
||||
struct ShaderArgInfo {
|
||||
|
||||
struct ShaderPtrSpec {
|
||||
ShaderArgId _id;
|
||||
ShaderArgType _type;
|
||||
ShaderArgDir _direction;
|
||||
bool _varying;
|
||||
NotifyCategory *_cat;
|
||||
int _dim[3]; //n_elements,rows,cols
|
||||
int _dep[2];
|
||||
PT(InternalName) _arg;
|
||||
ShaderArgInfo _info;
|
||||
};
|
||||
|
||||
struct ShaderCaps {
|
||||
@ -270,6 +354,7 @@ public:
|
||||
void cp_report_error(ShaderArgInfo &arg, const string &msg);
|
||||
bool cp_errchk_parameter_words(ShaderArgInfo &arg, int len);
|
||||
bool cp_errchk_parameter_in(ShaderArgInfo &arg);
|
||||
bool cp_errchk_parameter_ptr(ShaderArgInfo &p);
|
||||
bool cp_errchk_parameter_varying(ShaderArgInfo &arg);
|
||||
bool cp_errchk_parameter_uniform(ShaderArgInfo &arg);
|
||||
bool cp_errchk_parameter_float(ShaderArgInfo &arg, int lo, int hi);
|
||||
@ -285,11 +370,18 @@ public:
|
||||
int cp_dependency(ShaderMatInput inp);
|
||||
void cp_optimize_mat_spec(ShaderMatSpec &spec);
|
||||
|
||||
bool compile_parameter(const ShaderArgId &arg_id,
|
||||
ShaderArgType arg_type,
|
||||
ShaderArgDir arg_direction,
|
||||
bool arg_varying,
|
||||
NotifyCategory *arg_cat);
|
||||
void recurse_parameters(CGparameter parameter,
|
||||
const ShaderType& type,
|
||||
bool& success);
|
||||
|
||||
bool compile_parameter(const ShaderArgId &arg_id,
|
||||
const ShaderArgClass &arg_class,
|
||||
const ShaderArgClass &arg_subclass,
|
||||
const ShaderArgType &arg_type,
|
||||
const ShaderArgDir &arg_direction,
|
||||
bool arg_varying,
|
||||
int *arg_dim,
|
||||
NotifyCategory *arg_cat);
|
||||
|
||||
void clear_parameters();
|
||||
|
||||
@ -298,8 +390,9 @@ public:
|
||||
|
||||
#ifdef HAVE_CG
|
||||
private:
|
||||
ShaderArgType cg_parameter_type(CGparameter p);
|
||||
ShaderArgDir cg_parameter_dir(CGparameter p);
|
||||
ShaderArgClass cg_parameter_class(CGparameter p);
|
||||
ShaderArgType cg_parameter_type(CGparameter p);
|
||||
ShaderArgDir cg_parameter_dir(CGparameter p);
|
||||
|
||||
CGprogram cg_compile_entry_point(const char *entry, const ShaderCaps &caps, ShaderType type = ST_vertex);
|
||||
|
||||
@ -338,6 +431,7 @@ public:
|
||||
#endif
|
||||
|
||||
public:
|
||||
pvector <ShaderPtrSpec> _ptr_spec;
|
||||
pvector <ShaderMatSpec> _mat_spec;
|
||||
pvector <ShaderTexSpec> _tex_spec;
|
||||
pvector <ShaderVarSpec> _var_spec;
|
||||
|
@ -32,7 +32,8 @@
|
||||
perlinNoise2.h perlinNoise2.I \
|
||||
perlinNoise3.h perlinNoise3.I \
|
||||
plane.h plane_src.I plane_src.cxx plane_src.h \
|
||||
pta_LMatrix4f.h pta_LVecBase3f.h \
|
||||
pta_LMatrix4f.h pta_LMatrix3f.h pta_LVecBase3f.h \
|
||||
pta_LVecBase4f.h pta_LVecBase2f.h \
|
||||
randomizer.h randomizer.I \
|
||||
rotate_to.h rotate_to_src.cxx \
|
||||
stackedPerlinNoise2.h stackedPerlinNoise2.I \
|
||||
@ -55,7 +56,8 @@
|
||||
perlinNoise2.cxx \
|
||||
perlinNoise3.cxx \
|
||||
plane.cxx \
|
||||
pta_LMatrix4f.cxx pta_LVecBase3f.cxx \
|
||||
pta_LMatrix4f.cxx pta_LMatrix3f.cxx pta_LVecBase3f.cxx \
|
||||
pta_LVecBase4f.cxx pta_LVecBase2f.cxx \
|
||||
randomizer.cxx \
|
||||
rotate_to.cxx \
|
||||
stackedPerlinNoise2.cxx \
|
||||
@ -69,6 +71,8 @@
|
||||
boundingPlane.I boundingPlane.h \
|
||||
boundingSphere.I boundingSphere.h boundingVolume.I \
|
||||
boundingVolume.h config_mathutil.h fftCompressor.h \
|
||||
pta_LMatrix4f.h pta_LMatrix3f.h pta_LVecBase3f.h \
|
||||
pta_LVecBase4f.h pta_LVecBase2f.h \
|
||||
finiteBoundingVolume.h frustum.h frustum_src.I frustum_src.h \
|
||||
geometricBoundingVolume.I geometricBoundingVolume.h look_at.h \
|
||||
look_at_src.I look_at_src.h \
|
||||
|
@ -16,12 +16,34 @@ forcetype PointerToBase<ReferenceCountedVector<LMatrix4f> >
|
||||
forcetype PointerToArrayBase<LMatrix4f>
|
||||
forcetype PointerToArray<LMatrix4f>
|
||||
forcetype ConstPointerToArray<LMatrix4f>
|
||||
renametype PointerToArray<LMatrix4f> PTALMatrix4f
|
||||
renametype ConstPointerToArray<LMatrix4f> CPTALMatrix4f
|
||||
renametype PointerToArray<LMatrix4f> PTAMat4
|
||||
renametype ConstPointerToArray<LMatrix4f> CPTAMat4
|
||||
|
||||
forcetype PointerToBase<ReferenceCountedVector<LMatrix3f> >
|
||||
forcetype PointerToArrayBase<LMatrix3f>
|
||||
forcetype PointerToArray<LMatrix3f>
|
||||
forcetype ConstPointerToArray<LMatrix3f>
|
||||
renametype PointerToArray<LMatrix3f> PTAMat3
|
||||
renametype ConstPointerToArray<LMatrix3f> CPTAMat3
|
||||
|
||||
forcetype PointerToBase<ReferenceCountedVector<LVecBase4f> >
|
||||
forcetype PointerToArrayBase<LVecBase4f>
|
||||
forcetype PointerToArray<LVecBase4f>
|
||||
forcetype ConstPointerToArray<LVecBase4f>
|
||||
renametype PointerToArray<LVecBase4f> PTAVecBase4
|
||||
renametype ConstPointerToArray<LVecBase4f> PTAVecBase4
|
||||
|
||||
forcetype PointerToBase<ReferenceCountedVector<LVecBase3f> >
|
||||
forcetype PointerToArrayBase<LVecBase3f>
|
||||
forcetype PointerToArray<LVecBase3f>
|
||||
forcetype ConstPointerToArray<LVecBase3f>
|
||||
renametype PointerToArray<LVecBase3f> PTALVecBase3f
|
||||
renametype ConstPointerToArray<LVecBase3f> CPTALVecBase3f
|
||||
renametype PointerToArray<LVecBase3f> PTAVecBase3
|
||||
renametype ConstPointerToArray<LVecBase3f> PTAVecBase3
|
||||
|
||||
forcetype PointerToBase<ReferenceCountedVector<LVecBase2f> >
|
||||
forcetype PointerToArrayBase<LVecBase2f>
|
||||
forcetype PointerToArray<LVecBase2f>
|
||||
forcetype ConstPointerToArray<LVecBase2f>
|
||||
renametype PointerToArray<LVecBase2f> PTAVecBase2
|
||||
renametype ConstPointerToArray<LVecBase2f> PTAVecBase2
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
#include "perlinNoise3.cxx"
|
||||
#include "plane.cxx"
|
||||
#include "pta_LMatrix4f.cxx"
|
||||
#include "pta_LMatrix3f.cxx"
|
||||
#include "pta_LVecBase4f.cxx"
|
||||
#include "pta_LVecBase3f.cxx"
|
||||
#include "pta_LVecBase2f.cxx"
|
||||
#include "randomizer.cxx"
|
||||
#include "rotate_to.cxx"
|
||||
#include "stackedPerlinNoise2.cxx"
|
||||
|
20
panda/src/mathutil/pta_LMatrix3f.cxx
Normal file
20
panda/src/mathutil/pta_LMatrix3f.cxx
Normal file
@ -0,0 +1,20 @@
|
||||
// Filename: pta_LMatrix3f.cxx
|
||||
// Created by: drose (27Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pta_LMatrix3f.h"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
44
panda/src/mathutil/pta_LMatrix3f.h
Normal file
44
panda/src/mathutil/pta_LMatrix3f.h
Normal file
@ -0,0 +1,44 @@
|
||||
// Filename: pta_lmatrix3f.h
|
||||
// Created by: drose (27Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PTA_LMATRIX3F_H
|
||||
#define PTA_LMATRIX3F_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "luse.h"
|
||||
#include "pointerToArray.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PTA_LMatrix3f
|
||||
// Description : A pta of LMatrix3fs. This class is defined once here,
|
||||
// and exported to PANDA.DLL; other packages that want
|
||||
// to use a pta of this type (whether they need to
|
||||
// export it or not) should include this header file,
|
||||
// rather than defining the pta again.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LMatrix3f> >)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LMatrix3f>)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LMatrix3f>)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LMatrix3f>)
|
||||
|
||||
typedef PointerToArray<LMatrix3f> PTA_LMatrix3f;
|
||||
typedef ConstPointerToArray<LMatrix3f> CPTA_LMatrix3f;
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
20
panda/src/mathutil/pta_LVecBase2f.cxx
Normal file
20
panda/src/mathutil/pta_LVecBase2f.cxx
Normal file
@ -0,0 +1,20 @@
|
||||
// Filename: pta_LVecBase2f.cxx
|
||||
// Created by: drose (27Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pta_LVecBase2f.h"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
44
panda/src/mathutil/pta_LVecBase2f.h
Normal file
44
panda/src/mathutil/pta_LVecBase2f.h
Normal file
@ -0,0 +1,44 @@
|
||||
// Filename: pta_LVecBase2f.h
|
||||
// Created by: drose (27Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 2D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PTA_LVECBASE2F_H
|
||||
#define PTA_LVECBASE2F_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "luse.h"
|
||||
#include "pointerToArray.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PTA_LVecBase2f
|
||||
// Description : A pta of LVecBase2fs. This class is defined once here,
|
||||
// and exported to PANDA.DLL; other packages that want
|
||||
// to use a pta of this type (whether they need to
|
||||
// export it or not) should include this header file,
|
||||
// rather than defining the pta again.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LVecBase2f> >)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LVecBase2f>)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LVecBase2f>)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LVecBase2f>)
|
||||
|
||||
typedef PointerToArray<LVecBase2f> PTA_LVecBase2f;
|
||||
typedef ConstPointerToArray<LVecBase2f> CPTA_LVecBase2f;
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
20
panda/src/mathutil/pta_LVecBase4f.cxx
Normal file
20
panda/src/mathutil/pta_LVecBase4f.cxx
Normal file
@ -0,0 +1,20 @@
|
||||
// Filename: pta_LVecBase4f.cxx
|
||||
// Created by: drose (27Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pta_LVecBase4f.h"
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma implementation
|
||||
#endif
|
44
panda/src/mathutil/pta_LVecBase4f.h
Normal file
44
panda/src/mathutil/pta_LVecBase4f.h
Normal file
@ -0,0 +1,44 @@
|
||||
// Filename: pta_LVecBase4f.h
|
||||
// Created by: drose (27Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 4D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PTA_LVECBASE4F_H
|
||||
#define PTA_LVECBASE4F_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "luse.h"
|
||||
#include "pointerToArray.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PTA_LVecBase4f
|
||||
// Description : A pta of LVecBase4fs. This class is defined once here,
|
||||
// and exported to PANDA.DLL; other packages that want
|
||||
// to use a pta of this type (whether they need to
|
||||
// export it or not) should include this header file,
|
||||
// rather than defining the pta again.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase<ReferenceCountedVector<LVecBase4f> >)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase<LVecBase4f>)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray<LVecBase4f>)
|
||||
EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray<LVecBase4f>)
|
||||
|
||||
typedef PointerToArray<LVecBase4f> PTA_LVecBase4f;
|
||||
typedef ConstPointerToArray<LVecBase4f> CPTA_LVecBase4f;
|
||||
|
||||
// Tell GCC that we'll take care of the instantiation explicitly here.
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
// Filename: nodePath.cxx
|
||||
// Created by: drose (25Feb02)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads
|
||||
// for set_shader_input)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -3823,6 +3825,128 @@ clear_shader_input(InternalName *id) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_float &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_double &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const LVecBase4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const LVecBase3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const LVecBase2f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const LMatrix4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const LMatrix3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
@ -3848,9 +3972,9 @@ set_shader_input(InternalName *id, const NodePath &np, int priority) {
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, const LVector4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(id,v,priority));
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, int priority) {
|
||||
set_shader_input(new ShaderInput(id, LVecBase4f(n1, n2, n3, n4), priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -3858,11 +3982,121 @@ set_shader_input(InternalName *id, const LVector4f &v, int priority) {
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, int priority) {
|
||||
set_shader_input(new ShaderInput(id,LVector4f(n1,n2,n3,n4),priority));
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_float &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_double &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const LVecBase4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const LVecBase3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const LVecBase2f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const LMatrix4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const LMatrix3f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
@ -3888,19 +4122,9 @@ set_shader_input(const string &id, const NodePath &np, int priority) {
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, const LVector4f &v, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
void NodePath::
|
||||
set_shader_input(const string &id, double n1, double n2, double n3, double n4, int priority) {
|
||||
set_shader_input(new ShaderInput(InternalName::make(id),LVector4f(n1,n2,n3,n4),priority));
|
||||
set_shader_input(new ShaderInput(InternalName::make(id), LVecBase4f(n1, n2, n3, n4), priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Filename: nodePath.h
|
||||
// Created by: drose (25Feb02)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads
|
||||
// for set_shader_input)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -27,6 +29,13 @@
|
||||
#include "referenceCount.h"
|
||||
#include "pnotify.h"
|
||||
#include "typedObject.h"
|
||||
#include "pta_float.h"
|
||||
#include "pta_double.h"
|
||||
#include "pta_LMatrix4f.h"
|
||||
#include "pta_LMatrix3f.h"
|
||||
#include "pta_LVecBase4f.h"
|
||||
#include "pta_LVecBase3f.h"
|
||||
#include "pta_LVecBase2f.h"
|
||||
|
||||
class NodePathCollection;
|
||||
class FindApproxPath;
|
||||
@ -596,15 +605,42 @@ PUBLISHED:
|
||||
void set_shader_off(int priority = 0);
|
||||
void set_shader_auto(int priority = 0);
|
||||
void clear_shader();
|
||||
|
||||
void set_shader_input(const ShaderInput *inp);
|
||||
void set_shader_input(InternalName *id, Texture *tex, int priority=0);
|
||||
void set_shader_input(InternalName *id, const NodePath &np, int priority=0);
|
||||
void set_shader_input(InternalName *id, const LVector4f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_float &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_double &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const LVecBase4f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const LVecBase3f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const LVecBase2f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const LMatrix4f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, const LMatrix3f &v, int priority=0);
|
||||
void set_shader_input(InternalName *id, double n1=0, double n2=0, double n3=0,
|
||||
double n4=1, int priority=0);
|
||||
|
||||
void set_shader_input(const string &id, Texture *tex, int priority=0);
|
||||
void set_shader_input(const string &id, const NodePath &np, int priority=0);
|
||||
void set_shader_input(const string &id, const LVector4f &v, int priority=0);
|
||||
void set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_float &v, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_double &v, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const LVecBase4f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const LVecBase3f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const LVecBase2f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const LMatrix4f &v, int priority=0);
|
||||
void set_shader_input(const string &id, const LMatrix3f &v, int priority=0);
|
||||
void set_shader_input(const string &id, double n1=0, double n2=0, double n3=0,
|
||||
double n4=1, int priority=0);
|
||||
|
||||
void clear_shader_input(InternalName *id);
|
||||
void clear_shader_input(const string &id);
|
||||
void set_instance_count(int instance_count);
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Filename: shaderAttrib.cxx
|
||||
// Created by: sshodhan (10Jul04)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads
|
||||
// for set_shader_input)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -178,6 +180,127 @@ set_shader_input(const ShaderInput *input) const {
|
||||
return return_new(result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_float &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_double &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const LVecBase4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const LVecBase3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const LVecBase2f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const LMatrix4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const LMatrix3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id,v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
@ -185,7 +308,7 @@ set_shader_input(const ShaderInput *input) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, Texture *tex, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id, tex, priority));
|
||||
return set_shader_input(new ShaderInput(id,tex,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -195,17 +318,7 @@ set_shader_input(InternalName *id, Texture *tex, int priority) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const NodePath &np, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id, np, priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, const LVector4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id, v, priority));
|
||||
return set_shader_input(new ShaderInput(id,np,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -215,9 +328,129 @@ set_shader_input(InternalName *id, const LVector4f &v, int priority) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, int priority) const {
|
||||
return set_shader_input(new ShaderInput(id, LVector4f(n1,n2,n3,n4), priority));
|
||||
return set_shader_input(new ShaderInput(id, LVecBase4f(n1,n2,n3,n4), priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_float &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_double &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const LVecBase4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const LVecBase3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const LVecBase2f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const LMatrix4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const LMatrix3f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),v,priority));
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
@ -225,7 +458,7 @@ set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, i
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, Texture *tex, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id), tex, priority));
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),tex,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -235,17 +468,7 @@ set_shader_input(const string &id, Texture *tex, int priority) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const NodePath &np, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id), np, priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_input
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, const LVector4f &v, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id), v, priority));
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id),np,priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -255,7 +478,7 @@ set_shader_input(const string &id, const LVector4f &v, int priority) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_input(const string &id, double n1, double n2, double n3, double n4, int priority) const {
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id), LVector4f(n1,n2,n3,n4), priority));
|
||||
return set_shader_input(new ShaderInput(InternalName::make(id), LVecBase4f(n1,n2,n3,n4), priority));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -383,7 +606,7 @@ get_shader_input_vector(InternalName *id) const {
|
||||
return resfail;
|
||||
} else {
|
||||
const ShaderInput *p = (*i).second;
|
||||
if (p->get_value_type() != ShaderInput::M_vector) {
|
||||
if (p->get_value_type() != ShaderInput::M_numeric) {
|
||||
ostringstream strm;
|
||||
strm << "Shader input " << id->get_name() << " is not a vector.\n";
|
||||
nassert_raise(strm.str());
|
||||
@ -393,6 +616,33 @@ get_shader_input_vector(InternalName *id) const {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::get_shader_input_ptr
|
||||
// Access: Published
|
||||
// Description: Returns the ShaderInput as a ShaderPtrData struct.
|
||||
// Assertion fails if there is none. or if it is not
|
||||
// a PTA(double/float)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const Shader::ShaderPtrData *ShaderAttrib::
|
||||
get_shader_input_ptr(InternalName *id) const {
|
||||
Inputs::const_iterator i = _inputs.find(id);
|
||||
if (i == _inputs.end()) {
|
||||
ostringstream strm;
|
||||
strm << "Shader input " << id->get_name() << " is not present.\n";
|
||||
nassert_raise(strm.str());
|
||||
return NULL;
|
||||
} else {
|
||||
const ShaderInput *p = (*i).second;
|
||||
if (p->get_value_type() != ShaderInput::M_numeric) {
|
||||
ostringstream strm;
|
||||
strm << "Shader input " << id->get_name() << " is not a PTA(float/double) type.\n";
|
||||
nassert_raise(strm.str());
|
||||
return NULL;
|
||||
}
|
||||
return &(p->get_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::get_shader_input_texture
|
||||
// Access: Published
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Filename: shaderAttrib.h
|
||||
// Created by: jyelon (01Sep05)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads
|
||||
// for set_shader_input)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -20,6 +22,13 @@
|
||||
#include "pointerTo.h"
|
||||
#include "shaderInput.h"
|
||||
#include "shader.h"
|
||||
#include "pta_float.h"
|
||||
#include "pta_double.h"
|
||||
#include "pta_LMatrix4f.h"
|
||||
#include "pta_LMatrix3f.h"
|
||||
#include "pta_LVecBase4f.h"
|
||||
#include "pta_LVecBase3f.h"
|
||||
#include "pta_LVecBase2f.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ShaderAttrib
|
||||
@ -51,17 +60,43 @@ PUBLISHED:
|
||||
CPT(RenderAttrib) set_shader_off(int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_auto(int priority=0) const;
|
||||
CPT(RenderAttrib) clear_shader() const;
|
||||
// Shader Inputs
|
||||
CPT(RenderAttrib) set_shader_input(const ShaderInput *inp) const;
|
||||
|
||||
// InternalName* id
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, Texture *tex, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const NodePath &np, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const LVector4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_float &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_double &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const LVecBase4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const LVecBase3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const LVecBase2f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const LMatrix4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, const LMatrix3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(InternalName *id, double n1=0, double n2=0, double n3=0, double n4=1,
|
||||
int priority=0) const;
|
||||
int priority=0) const;
|
||||
// String id
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, Texture *tex, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const NodePath &np, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const LVector4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_float &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_double &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const LVecBase4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const LVecBase3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const LVecBase2f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const LMatrix4f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, const LMatrix3f &v, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1,
|
||||
int priority=0) const;
|
||||
int priority=0) const;
|
||||
|
||||
CPT(RenderAttrib) set_instance_count(int instance_count) const;
|
||||
|
||||
@ -82,7 +117,8 @@ PUBLISHED:
|
||||
const NodePath &get_shader_input_nodepath(InternalName *id) const;
|
||||
const LVector4f &get_shader_input_vector(InternalName *id) const;
|
||||
Texture* get_shader_input_texture(InternalName *id) const;
|
||||
|
||||
const Shader::ShaderPtrData *get_shader_input_ptr(InternalName *id) const;
|
||||
|
||||
static void register_with_read_factory();
|
||||
|
||||
public:
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Filename: shaderInput.I
|
||||
// Created by: jyelon (01Sep05)
|
||||
//
|
||||
// Updated by: fperazzi, PandaSE (06Apr10)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
@ -32,6 +32,7 @@ ShaderInput(InternalName *name, int priority) :
|
||||
_name(name),
|
||||
_type(M_invalid),
|
||||
_priority(priority),
|
||||
_stored_ptr(),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(LVector4f(0,0,0,1))
|
||||
@ -48,6 +49,7 @@ ShaderInput(InternalName *name, Texture *tex, int priority) :
|
||||
_name(name),
|
||||
_type(M_texture),
|
||||
_priority(priority),
|
||||
_stored_ptr(),
|
||||
_stored_texture(tex),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(LVector4f(0,0,0,1))
|
||||
@ -64,6 +66,7 @@ ShaderInput(InternalName *name, const NodePath &np, int priority) :
|
||||
_name(name),
|
||||
_type(M_nodepath),
|
||||
_priority(priority),
|
||||
_stored_ptr(),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(np),
|
||||
_stored_vector(LVector4f(0,0,0,1))
|
||||
@ -76,13 +79,201 @@ ShaderInput(InternalName *name, const NodePath &np, int priority) :
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const LVector4f &vec, int priority) :
|
||||
ShaderInput(InternalName *name, const PTA_float &ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_vector),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(vec)
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const PTA_double &ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const PTA_LVecBase4f& ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const PTA_LVecBase3f& ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const PTA_LVecBase2f& ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const LVecBase4f& vec, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(vec),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(vec) //old GLSL inputs must be supported
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const LVecBase3f& vec, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(vec),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const LVecBase2f& vec, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(vec),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const PTA_LMatrix4f& ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const PTA_LMatrix3f& ptr, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(ptr),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const LMatrix4f& mat, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(mat),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderInput::
|
||||
ShaderInput(InternalName *name, const LMatrix3f& mat, int priority) :
|
||||
_name(name),
|
||||
_type(M_numeric),
|
||||
_priority(priority),
|
||||
_stored_ptr(mat),
|
||||
_stored_texture(NULL),
|
||||
_stored_nodepath(NodePath()),
|
||||
_stored_vector(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -126,6 +317,16 @@ get_texture() const {
|
||||
return _stored_texture;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::get_ptr
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const Shader::ShaderPtrData& ShaderInput::
|
||||
get_ptr() const {
|
||||
return _stored_ptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderInput::get_nodepath
|
||||
// Access: Published
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Filename: shaderInput.h
|
||||
// Created by: jyelon (01Sep05)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -21,6 +22,14 @@
|
||||
#include "nodePath.h"
|
||||
#include "texture.h"
|
||||
#include "internalName.h"
|
||||
#include "shader.h"
|
||||
#include "pta_float.h"
|
||||
#include "pta_double.h"
|
||||
#include "pta_LMatrix4f.h"
|
||||
#include "pta_LMatrix3f.h"
|
||||
#include "pta_LVecBase4f.h"
|
||||
#include "pta_LVecBase3f.h"
|
||||
#include "pta_LVecBase2f.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : ShaderInput
|
||||
@ -37,23 +46,35 @@ PUBLISHED:
|
||||
static const ShaderInput *get_blank();
|
||||
INLINE ShaderInput(InternalName *id, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const NodePath &np, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const LVector4f &v, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, Texture *tex, int priority=0);
|
||||
|
||||
INLINE ShaderInput(InternalName *id, const PTA_float &ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const PTA_double &ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const PTA_LVecBase4f& ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const PTA_LVecBase3f& ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const PTA_LVecBase2f& ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const PTA_LMatrix4f& ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const PTA_LMatrix3f& ptr, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const LVecBase4f& vec, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const LVecBase3f& vec, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const LVecBase2f& vec, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const LMatrix4f& mat, int priority=0);
|
||||
INLINE ShaderInput(InternalName *id, const LMatrix3f& mat, int priority=0);
|
||||
|
||||
enum ShaderInputType {
|
||||
M_invalid = 0,
|
||||
M_texture,
|
||||
M_nodepath,
|
||||
M_vector
|
||||
M_numeric
|
||||
};
|
||||
|
||||
INLINE InternalName *get_name() const;
|
||||
|
||||
INLINE int get_value_type() const;
|
||||
INLINE int get_priority() const;
|
||||
INLINE Texture *get_texture() const;
|
||||
INLINE const NodePath &get_nodepath() const;
|
||||
INLINE const LVector4f &get_vector() const;
|
||||
INLINE int get_value_type() const;
|
||||
INLINE int get_priority() const;
|
||||
INLINE Texture *get_texture() const;
|
||||
INLINE const NodePath &get_nodepath() const;
|
||||
INLINE const LVector4f &get_vector() const;
|
||||
INLINE const Shader::ShaderPtrData &get_ptr() const;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
@ -62,9 +83,10 @@ private:
|
||||
PT(InternalName) _name;
|
||||
int _type;
|
||||
int _priority;
|
||||
PT(Texture) _stored_texture;
|
||||
NodePath _stored_nodepath;
|
||||
LVector4f _stored_vector;
|
||||
PT(Texture) _stored_texture;
|
||||
NodePath _stored_nodepath;
|
||||
LVector4f _stored_vector;
|
||||
Shader::ShaderPtrData _stored_ptr;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user