00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "eggRenderMode.h"
00020 #include <indent.h>
00021 #include <string_utils.h>
00022 #include <notify.h>
00023
00024 TypeHandle EggRenderMode::_type_handle;
00025
00026
00027
00028
00029
00030
00031
00032 void EggRenderMode::
00033 write(ostream &out, int indent_level) const {
00034 if (get_alpha_mode() != AM_unspecified) {
00035 indent(out, indent_level)
00036 << "<Scalar> alpha { " << get_alpha_mode() << " }\n";
00037 }
00038 if (get_depth_write_mode() != DWM_unspecified) {
00039 indent(out, indent_level)
00040 << "<Scalar> depth_write { " << get_depth_write_mode() << " }\n";
00041 }
00042 if (get_depth_test_mode() != DTM_unspecified) {
00043 indent(out, indent_level)
00044 << "<Scalar> depth_test { " << get_depth_test_mode() << " }\n";
00045 }
00046 if (has_draw_order()) {
00047 indent(out, indent_level)
00048 << "<Scalar> draw-order { " << get_draw_order() << " }\n";
00049 }
00050 if (has_bin()) {
00051 indent(out, indent_level)
00052 << "<Scalar> bin { " << get_bin() << " }\n";
00053 }
00054 }
00055
00056
00057
00058
00059
00060
00061 bool EggRenderMode::
00062 operator == (const EggRenderMode &other) const {
00063 if (_alpha_mode != other._alpha_mode ||
00064 _depth_write_mode != other._depth_write_mode ||
00065 _depth_test_mode != other._depth_test_mode ||
00066 _has_draw_order != other._has_draw_order) {
00067 return false;
00068 }
00069
00070 if (_has_draw_order) {
00071 if (_draw_order != other._draw_order) {
00072 return false;
00073 }
00074 }
00075
00076 if (_bin != other._bin) {
00077 return false;
00078 }
00079
00080 return true;
00081 }
00082
00083
00084
00085
00086
00087
00088 bool EggRenderMode::
00089 operator < (const EggRenderMode &other) const {
00090 if (_alpha_mode != other._alpha_mode) {
00091 return (int)_alpha_mode < (int)other._alpha_mode;
00092 }
00093 if (_depth_write_mode != other._depth_write_mode) {
00094 return (int)_depth_write_mode < (int)other._depth_write_mode;
00095 }
00096 if (_depth_test_mode != other._depth_test_mode) {
00097 return (int)_depth_test_mode < (int)other._depth_test_mode;
00098 }
00099
00100 if (_has_draw_order != other._has_draw_order) {
00101 return (int)_has_draw_order < (int)other._has_draw_order;
00102 }
00103
00104 if (_has_draw_order) {
00105 if (_draw_order != other._draw_order) {
00106 return _draw_order < other._draw_order;
00107 }
00108 }
00109
00110 if (_bin != other._bin) {
00111 return _bin < other._bin;
00112 }
00113
00114 return false;
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124 EggRenderMode::AlphaMode EggRenderMode::
00125 string_alpha_mode(const string &string) {
00126 if (cmp_nocase_uh(string, "off") == 0) {
00127 return AM_off;
00128 } else if (cmp_nocase_uh(string, "on") == 0) {
00129 return AM_on;
00130 } else if (cmp_nocase_uh(string, "blend") == 0) {
00131 return AM_blend;
00132 } else if (cmp_nocase_uh(string, "blend_no_occlude") == 0) {
00133 return AM_blend_no_occlude;
00134 } else if (cmp_nocase_uh(string, "ms") == 0) {
00135 return AM_ms;
00136 } else if (cmp_nocase_uh(string, "ms_mask") == 0) {
00137 return AM_ms_mask;
00138 } else if (cmp_nocase_uh(string, "binary") == 0) {
00139 return AM_binary;
00140 } else if (cmp_nocase_uh(string, "dual") == 0) {
00141 return AM_dual;
00142 } else {
00143 return AM_unspecified;
00144 }
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 EggRenderMode::DepthWriteMode EggRenderMode::
00156 string_depth_write_mode(const string &string) {
00157 if (cmp_nocase_uh(string, "off") == 0) {
00158 return DWM_off;
00159 } else if (cmp_nocase_uh(string, "on") == 0) {
00160 return DWM_on;
00161 } else {
00162 return DWM_unspecified;
00163 }
00164 }
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 EggRenderMode::DepthTestMode EggRenderMode::
00175 string_depth_test_mode(const string &string) {
00176 if (cmp_nocase_uh(string, "off") == 0) {
00177 return DTM_off;
00178 } else if (cmp_nocase_uh(string, "on") == 0) {
00179 return DTM_on;
00180 } else {
00181 return DTM_unspecified;
00182 }
00183 }
00184
00185
00186
00187
00188
00189
00190 ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode) {
00191 switch (mode) {
00192 case EggRenderMode::AM_unspecified:
00193 return out << "unspecified";
00194 case EggRenderMode::AM_off:
00195 return out << "off";
00196 case EggRenderMode::AM_on:
00197 return out << "on";
00198 case EggRenderMode::AM_blend:
00199 return out << "blend";
00200 case EggRenderMode::AM_blend_no_occlude:
00201 return out << "blend_no_occlude";
00202 case EggRenderMode::AM_ms:
00203 return out << "ms";
00204 case EggRenderMode::AM_ms_mask:
00205 return out << "ms_mask";
00206 case EggRenderMode::AM_binary:
00207 return out << "binary";
00208 case EggRenderMode::AM_dual:
00209 return out << "dual";
00210 }
00211
00212 nassertr(false, out);
00213 return out << "(**invalid**)";
00214 }
00215
00216
00217
00218
00219
00220 ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode) {
00221 switch (mode) {
00222 case EggRenderMode::DWM_unspecified:
00223 return out << "unspecified";
00224 case EggRenderMode::DWM_off:
00225 return out << "off";
00226 case EggRenderMode::DWM_on:
00227 return out << "on";
00228 }
00229
00230 nassertr(false, out);
00231 return out << "(**invalid**)";
00232 }
00233
00234
00235
00236
00237
00238 ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode) {
00239 switch (mode) {
00240 case EggRenderMode::DTM_unspecified:
00241 return out << "unspecified";
00242 case EggRenderMode::DTM_off:
00243 return out << "off";
00244 case EggRenderMode::DTM_on:
00245 return out << "on";
00246 }
00247
00248 nassertr(false, out);
00249 return out << "(**invalid**)";
00250 }
00251
00252