21 if (_filename._separate && type != ST_none) {
24 return _filename._vertex;
27 return _filename._fragment;
30 return _filename._geometry;
33 return _filename._tess_control;
35 case ST_tess_evaluation:
36 return _filename._tess_evaluation;
39 return _filename._compute;
42 return _filename._shared;
44 }
else if (!_filename._shared.empty()) {
45 return _filename._shared;
49 return _filename._fragment;
59 _filename._separate =
true;
62 _filename._vertex = filename;
65 _filename._fragment = filename;
68 _filename._geometry = filename;
71 _filename._tess_control = filename;
73 case ST_tess_evaluation:
74 _filename._tess_evaluation = filename;
77 _filename._compute = filename;
80 _filename._shared = filename;
81 _filename._separate =
false;
90 if (_text._separate) {
91 nassertr(type != ST_none || !_text._shared.empty(), _text._shared);
97 return _text._fragment;
100 return _text._geometry;
102 case ST_tess_control:
103 return _text._tess_control;
105 case ST_tess_evaluation:
106 return _text._tess_evaluation;
109 return _text._compute;
112 return _text._shared;
115 return _text._shared;
131 INLINE Shader::ShaderLanguage
Shader:: 142 return !_fullpath.empty();
160 return _cache_compiled_shader;
174 _cache_compiled_shader = flag;
180 INLINE Shader::ShaderCaps::
188 INLINE
bool Shader::ShaderCaps::
189 operator == (
const ShaderCaps &other)
const {
191 if ((_active_vprofile != other._active_vprofile) ||
192 (_active_fprofile != other._active_fprofile) ||
193 (_active_gprofile != other._active_gprofile) ||
194 (_ultimate_vprofile != other._ultimate_vprofile) ||
195 (_ultimate_fprofile != other._ultimate_fprofile) ||
196 (_ultimate_gprofile != other._ultimate_gprofile)) {
206 INLINE Shader::ShaderPtrData::
218 INLINE Shader::ShaderPtrData::
219 ShaderPtrData(
const PTA_float &ptr):
231 INLINE Shader::ShaderPtrData::
232 ShaderPtrData(
const PTA_LMatrix4f &ptr):
237 _size(ptr.size() * 16)
244 INLINE Shader::ShaderPtrData::
245 ShaderPtrData(
const PTA_LMatrix3f &ptr):
250 _size(ptr.size() * 9)
257 INLINE Shader::ShaderPtrData::
258 ShaderPtrData(
const PTA_LVecBase4f &ptr):
263 _size(ptr.size() * 4)
270 INLINE Shader::ShaderPtrData::
271 ShaderPtrData(
const PTA_LVecBase3f &ptr):
276 _size(ptr.size() * 3)
283 INLINE Shader::ShaderPtrData::
284 ShaderPtrData(
const PTA_LVecBase2f &ptr):
289 _size(ptr.size() * 2)
296 INLINE Shader::ShaderPtrData::
297 ShaderPtrData(
const LVecBase4f &vec) :
302 PTA_float pta = PTA_float::empty_array(4);
305 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
306 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
312 INLINE Shader::ShaderPtrData::
313 ShaderPtrData(
const LVecBase3f &vec) :
318 PTA_float pta = PTA_float::empty_array(3);
321 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
322 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
328 INLINE Shader::ShaderPtrData::
329 ShaderPtrData(
const LVecBase2f &vec) :
334 PTA_float pta = PTA_float::empty_array(2);
337 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
338 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
344 INLINE Shader::ShaderPtrData::
345 ShaderPtrData(
const LMatrix4f &mat) :
350 PTA_float pta = PTA_float::empty_array(16);
353 nassertv(
sizeof(mat(0, 0)) * mat.get_num_components() == pta.size() *
sizeof(pta[0]));
354 memcpy(_ptr, mat.get_data(),
sizeof(mat(0, 0)) * mat.get_num_components());
360 INLINE Shader::ShaderPtrData::
361 ShaderPtrData(
const LMatrix3f &mat) :
366 PTA_float pta = PTA_float::empty_array(9);
369 nassertv(
sizeof(mat(0, 0)) * mat.get_num_components() == pta.size() *
sizeof(pta[0]));
370 memcpy(_ptr, mat.get_data(),
sizeof(mat(0, 0)) * mat.get_num_components());
376 INLINE Shader::ShaderPtrData::
377 ShaderPtrData(
const PTA_double &ptr):
389 INLINE Shader::ShaderPtrData::
390 ShaderPtrData(
const PTA_LMatrix4d &ptr):
395 _size(ptr.size() * 16)
402 INLINE Shader::ShaderPtrData::
403 ShaderPtrData(
const PTA_LMatrix3d &ptr):
408 _size(ptr.size() * 9)
415 INLINE Shader::ShaderPtrData::
416 ShaderPtrData(
const PTA_LVecBase4d &ptr):
421 _size(ptr.size() * 4)
428 INLINE Shader::ShaderPtrData::
429 ShaderPtrData(
const PTA_LVecBase3d &ptr):
434 _size(ptr.size() * 3)
441 INLINE Shader::ShaderPtrData::
442 ShaderPtrData(
const PTA_LVecBase2d &ptr):
447 _size(ptr.size() * 2)
454 INLINE Shader::ShaderPtrData::
455 ShaderPtrData(
const LVecBase4d &vec) :
460 PTA_double pta = PTA_double::empty_array(4);
463 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
464 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
470 INLINE Shader::ShaderPtrData::
471 ShaderPtrData(
const LVecBase3d &vec) :
476 PTA_double pta = PTA_double::empty_array(3);
479 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
480 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
486 INLINE Shader::ShaderPtrData::
487 ShaderPtrData(
const LVecBase2d &vec) :
492 PTA_double pta = PTA_double::empty_array(2);
495 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
496 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
502 INLINE Shader::ShaderPtrData::
503 ShaderPtrData(
const LMatrix4d &mat) :
508 PTA_double pta = PTA_double::empty_array(16);
511 nassertv(
sizeof(mat(0, 0)) * mat.get_num_components() == pta.size() *
sizeof(pta[0]));
512 memcpy(_ptr, mat.get_data(),
sizeof(mat(0, 0)) * mat.get_num_components());
518 INLINE Shader::ShaderPtrData::
519 ShaderPtrData(
const LMatrix3d &mat) :
524 PTA_double pta = PTA_double::empty_array(9);
527 nassertv(
sizeof(mat(0, 0)) * mat.get_num_components() == pta.size() *
sizeof(pta[0]));
528 memcpy(_ptr, mat.get_data(),
sizeof(mat(0, 0)) * mat.get_num_components());
534 INLINE Shader::ShaderPtrData::
535 ShaderPtrData(
const PTA_int &ptr):
547 INLINE Shader::ShaderPtrData::
548 ShaderPtrData(
const PTA_LVecBase4i &ptr):
553 _size(ptr.size() * 4)
560 INLINE Shader::ShaderPtrData::
561 ShaderPtrData(
const PTA_LVecBase3i &ptr):
566 _size(ptr.size() * 3)
573 INLINE Shader::ShaderPtrData::
574 ShaderPtrData(
const PTA_LVecBase2i &ptr):
579 _size(ptr.size() * 2)
586 INLINE Shader::ShaderPtrData::
587 ShaderPtrData(
const LVecBase4i &vec) :
592 PTA_int pta = PTA_int::empty_array(4);
595 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
596 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
602 INLINE Shader::ShaderPtrData::
603 ShaderPtrData(
const LVecBase3i &vec) :
608 PTA_int pta = PTA_int::empty_array(3);
611 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
612 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
618 INLINE Shader::ShaderPtrData::
619 ShaderPtrData(
const LVecBase2i &vec) :
624 PTA_int pta = PTA_int::empty_array(2);
627 nassertv(
sizeof(vec[0]) * vec.get_num_components() == pta.size() *
sizeof(pta[0]));
628 memcpy(_ptr, vec.get_data(),
sizeof(vec[0]) * vec.get_num_components());
640 if (_type == SPT_double) {
641 const double *data = (
const double *) _ptr;
642 for (
size_t i = 0; i < _size; ++i) {
646 }
else if (_type == SPT_float) {
647 const float *data = (
const float *) _ptr;
648 for (
size_t i = 0; i < _size; ++i) {
651 }
else if (_type == SPT_int) {
652 const int *data = (
const int *) _ptr;
653 for (
size_t i = 0; i < _size; ++i) {
664 _type = (ShaderPtrType) scan.
get_uint8();
667 if (_type == SPT_double) {
668 PTA_double pta = PTA_double::empty_array(_size);
669 for (
size_t i = 0; i < _size; ++i) {
675 }
else if (_type == SPT_float) {
676 PTA_float pta = PTA_float::empty_array(_size);
677 for (
size_t i = 0; i < _size; ++i) {
683 }
else if (_type == SPT_int) {
684 PTA_int pta = PTA_int::empty_array(_size);
685 for (
size_t i = 0; i < _size; ++i) {
696 INLINE Shader::ShaderFile::
697 ShaderFile(std::string shared) :
699 _shared(std::move(shared))
706 INLINE Shader::ShaderFile::
707 ShaderFile(std::string vertex, std::string fragment, std::string geometry,
708 std::string tess_control, std::string tess_evaluation) :
710 _vertex(std::move(vertex)),
711 _fragment(std::move(fragment)),
712 _geometry(std::move(geometry)),
713 _tess_control(std::move(tess_control)),
714 _tess_evaluation(std::move(tess_evaluation))
747 if (count-- > 0) _fragment = scan.
get_string();
748 if (count-- > 0) _geometry = scan.
get_string();
749 if (count-- > 0) _tess_control = scan.
get_string();
750 if (count-- > 0) _tess_evaluation = scan.
get_string();
751 if (count-- > 0) _compute = scan.
get_string();
752 while (count-- > 0) {
766 if (_separate != other._separate) {
767 return (!_separate && other._separate);
769 if (_shared != other._shared) {
770 return (_shared < other._shared);
772 if (_vertex != other._vertex) {
773 return (_vertex < other._vertex);
775 if (_fragment != other._fragment) {
776 return (_fragment < other._fragment);
778 if (_geometry != other._geometry) {
779 return (_geometry < other._geometry);
781 if (_tess_control != other._tess_control) {
782 return (_tess_control < other._tess_control);
784 if (_tess_evaluation != other._tess_evaluation) {
785 return (_tess_evaluation < other._tess_evaluation);
787 if (_compute != other._compute) {
788 return (_compute < other._compute);
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
void add_float64(PN_float64 value)
Adds a 64-bit floating-point number to the datagram.
void write_datagram(Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
void add_float32(PN_float32 value)
Adds a 32-bit single-precision floating-point number to the datagram.
bool operator<(const ShaderFile &other) const
Ordering operator.
const std::string & get_text(ShaderType type=ST_none) const
Return the Shader's text for the given shader type.
bool get_error_flag() const
Returns true if the shader contains a compile-time error.
Filename get_filename(ShaderType type=ST_none) const
Return the Shader's filename for the given shader type.
int32_t get_int32()
Extracts a signed 32-bit integer.
ShaderLanguage get_language() const
Returns the shader language in which this shader was written.
std::string get_string()
Extracts a variable-length string.
void set_filename(ShaderType type, const Filename &filename)
Sets the Shader's filename for the given shader type.
PN_float32 get_float32()
Extracts a 32-bit single-precision floating-point number.
bool has_fullpath() const
Returns true if the fullpath has been set and is available.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
void set_cache_compiled_shader(bool flag)
Sets the cache_compiled_shader flag.
void read_datagram(DatagramIterator &source)
Reads the object from a Datagram.
const Filename & get_fullpath() const
Returns the fullpath that has been set.
void read_datagram(DatagramIterator &source)
Reads the object from a Datagram.
The name of a file, such as a texture file or an Egg file.
void write_datagram(Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
bool get_cache_compiled_shader() const
Returns the setting of the cache_compiled_shader flag.
PN_float64 get_float64()
Extracts a 64-bit floating-point number.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...