eggRenderMode.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Filename: eggRenderMode.h
  2. // Created by: drose (20Jan99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef EGGRENDERMODE_H
  19. #define EGGRENDERMODE_H
  20. #include "pandabase.h"
  21. #include "typedObject.h"
  22. ////////////////////////////////////////////////////////////////////
  23. // Class : EggRenderMode
  24. // Description : This class stores miscellaneous rendering properties
  25. // that is associated with geometry, and which may be
  26. // set on the geometry primitive level, on the group
  27. // above it, or indirectly via a texture. It's intended
  28. // to be a base class for egg objects that can have
  29. // these properties set.
  30. //
  31. // This class cannot inherit from EggObject, because it
  32. // causes problems at the EggPolygon level with multiple
  33. // appearances of the EggObject base class. And making
  34. // EggObject a virtual base class is just no fun.
  35. ////////////////////////////////////////////////////////////////////
  36. class EXPCL_PANDAEGG EggRenderMode {
  37. public:
  38. INLINE EggRenderMode();
  39. INLINE EggRenderMode(const EggRenderMode &copy);
  40. INLINE EggRenderMode &operator = (const EggRenderMode &copy);
  41. void write(ostream &out, int indent_level) const;
  42. enum AlphaMode { // Specifies implementation of transparency.
  43. AM_unspecified,
  44. AM_off, // No transparency.
  45. AM_on, // Use whatever the default model is.
  46. AM_blend, // Normal alpha blending, e.g. TransparencyAttrib::M_alpha.
  47. AM_blend_no_occlude, // Alpha blending w/o depth write.
  48. AM_ms, // TransparencyAttrib::M_multisample
  49. AM_ms_mask, // TransparencyAttrib::M_multisample_mask
  50. AM_binary, // TransparencyAttrib::M_binary
  51. AM_dual // TransparencyAttrib::M_dual
  52. };
  53. enum DepthWriteMode {
  54. DWM_unspecified, DWM_off, DWM_on
  55. };
  56. enum DepthTestMode {
  57. DTM_unspecified, DTM_off, DTM_on
  58. };
  59. INLINE void set_alpha_mode(AlphaMode mode);
  60. INLINE AlphaMode get_alpha_mode() const;
  61. INLINE void set_depth_write_mode(DepthWriteMode mode);
  62. INLINE DepthWriteMode get_depth_write_mode() const;
  63. INLINE void set_depth_test_mode(DepthTestMode mode);
  64. INLINE DepthTestMode get_depth_test_mode() const;
  65. INLINE void set_draw_order(int order);
  66. INLINE int get_draw_order() const;
  67. INLINE bool has_draw_order() const;
  68. INLINE void clear_draw_order();
  69. INLINE void set_bin(const string &bin);
  70. INLINE string get_bin() const;
  71. INLINE bool has_bin() const;
  72. INLINE void clear_bin();
  73. // Comparison operators are handy.
  74. bool operator == (const EggRenderMode &other) const;
  75. INLINE bool operator != (const EggRenderMode &other) const;
  76. bool operator < (const EggRenderMode &other) const;
  77. static AlphaMode string_alpha_mode(const string &string);
  78. static DepthWriteMode string_depth_write_mode(const string &string);
  79. static DepthTestMode string_depth_test_mode(const string &string);
  80. private:
  81. AlphaMode _alpha_mode;
  82. DepthWriteMode _depth_write_mode;
  83. DepthTestMode _depth_test_mode;
  84. int _draw_order;
  85. bool _has_draw_order;
  86. string _bin;
  87. public:
  88. static TypeHandle get_class_type() {
  89. return _type_handle;
  90. }
  91. static void init_type() {
  92. register_type(_type_handle, "EggRenderMode");
  93. }
  94. private:
  95. static TypeHandle _type_handle;
  96. };
  97. ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode);
  98. ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode);
  99. ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode);
  100. #include "eggRenderMode.I"
  101. #endif