00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SMLTGL_H
00019 #define SMLTGL_H
00020
00021 #include "glvector.h"
00022 #include "sml.h"
00023
00028
00029
00030 #define SML_LOAD_FIELDS \
00031 else \
00032 if( loadFieldsFromStream( in, tag ) ) \
00033 { \
00034 continue; \
00035 }
00036
00037 #define SML_LOAD_GLFLOAT(_tag) \
00038 else \
00039 if(tag.compare(#_tag) == 0) \
00040 { \
00041 in>>delim; \
00042 GLfloat f; \
00043 in>>f; \
00044 _tag = f; \
00045 continue; \
00046 }
00047
00048 #define SML_LOAD_GLUINT(_tag) \
00049 else \
00050 if(tag.compare(#_tag) == 0) \
00051 { \
00052 in>>delim; \
00053 GLuint u; \
00054 in>>u; \
00055 _tag = u; \
00056 }
00057
00058 #define SML_LOAD_GLFLOAT_WITH_FUNC(_tag, _func) \
00059 else \
00060 if(tag.compare(#_tag) == 0) \
00061 { \
00062 in>>delim; \
00063 GLfloat f; \
00064 in>>f; \
00065 _func(f); \
00066 }
00067
00068 #define SML_LOAD_GLUINT_WITH_FUNC(_tag, _func) \
00069 else \
00070 if(tag.compare(#_tag) == 0) \
00071 { \
00072 in>>delim; \
00073 GLuint u; \
00074 in>>u; \
00075 _func(u); \
00076 }
00077
00078 #define SML_LOAD_RGBA_WITH_FUNC(_tag, _func) \
00079 else \
00080 if(tag.compare(#_tag) == 0) \
00081 { \
00082 in>>delim; \
00083 GLfloat r,g,b,a; \
00084 in>>r>>g>>b>>a; \
00085 _func(r,g,b,a); \
00086 }
00087
00088 #define SML_LOAD_XYZ_WITH_FUNC(_tag, _func) \
00089 else \
00090 if(tag.compare(#_tag) == 0) \
00091 { \
00092 in>>delim; \
00093 GLfloat x,y,z; \
00094 in>>x>>y>>z; \
00095 _func(x,y,z); \
00096 }
00097
00098
00099 #define SML_LOAD_XYZW_WITH_FUNC(_tag, _func) \
00100 else \
00101 if(tag.compare(#_tag) == 0) \
00102 { \
00103 in>>delim; \
00104 GLfloat x,y,z,w; \
00105 in>>x>>y>>z>>w; \
00106 _func(x,y,z,w); \
00107 }
00108
00109
00110 #define SML_LOAD_SUB_SML_SCENE_OBJECT( _type ) \
00111 \
00112 else \
00113 if(tag.compare( startTag() ) == 0) \
00114 { \
00115 _type* newNode = new _type(this); \
00116 newNode->loadFromStream(in); \
00117 }
00118
00119
00120 #define SML_LOAD_SCENE_OBJECT_ADD_SCENE_OBJECT( _class ) \
00121 \
00122 SML_LOAD_OPTION_INIT_FOREIGN_CLASS( _class ) \
00123 SML_LOAD_FOREIGN_SUB_SML( _class ) \
00124 appendObject( _ptr ); \
00125 SML_LOAD_OPTION_END
00126
00127
00128
00129
00130 #define SML_SAVE_FIELDS \
00131 saveFieldsToStream( out );
00132
00133 #define SML_SAVE_GLFLOAT(_att) \
00134 out<<" "<<#_att<<" = "<<_att<<std::endl;
00135
00136 #define SML_SAVE_GLFLOAT_WITH_TAG(_tag, _att) \
00137 out<<" "<<#_tag<<" = "<<_att<<std::endl;
00138
00139
00140 #define SML_SAVE_GLUINT_WITH_FUNC(_tag, _func) \
00141 out<<" "<<#_tag<<" = "<<_func()<<std::endl;
00142
00143 #define SML_SAVE_GLFLOAT_WITH_FUNC(_tag, _func) \
00144 out<<" "<<#_tag<<" = "<<_func()<<std::endl;
00145
00146 #define SML_SAVE_GLFLOAT_ARRAY_3(_tag, _arr) \
00147 out<<" "<<#_tag<<" = "<<_arr[0]<<" "<<_arr[1]<<" "<<_arr[2]<<std::endl; \
00148
00149 #define SML_SAVE_GLFLOAT_ARRAY_3_WITH_FUNC(_tag, _func) \
00150 { \
00151 const GLfloat* _val = _func(); \
00152 out<<" "<<#_tag<<" = "<<_val[0]<<" "<<_val[1]<<" "<<_val[2]<<std::endl; \
00153 }
00154
00155 #define SML_SAVE_GLFLOAT_ARRAY_4(_tag, _arr) \
00156 out<<" "<<#_tag<<" = "<<_arr[0]<<" "<<_arr[1]<<" "<<_arr[2]<<" "<<_arr[3]<<std::endl;
00157
00158
00159
00161 #define SML_SAVE_SCENE_OBJECT \
00162 GLScene::SceneObjectIterator _si = sceneObjects.begin(); \
00163 GLScene::SceneObjectIterator _si_end = sceneObjects.end(); \
00164 \
00165 while( _si != _si_end ) \
00166 { \
00167 (*_si)->saveToStream(out); \
00168 ++_si; \
00169 }; \
00170
00171
00172
00173 #endif
00174