00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00036 class PG_API pgDraw
00037 {
00038 friend class pgScr;
00039 friend class pgDrawMgr;
00040
00041 public:
00042 pgDefineException(ExceptionInvalidArgument);
00043 pgDefineException(ExceptionInvalidCall);
00044 pgDefineException(ExceptionNotInitialized);
00045
00049 enum DrawType
00050 {
00051 TYPE_NODE,
00052 TYPE_PRIM,
00053 TYPE_SPRT
00054 };
00055
00059 enum DepthTest
00060 {
00061 DEPTH_TEST_ALWAYS,
00062 DEPTH_TEST_LESS,
00063 DEPTH_TEST_GREATER,
00064 DEPTH_TEST_LEQUAL,
00065 DEPTH_TEST_GEQUAL
00066 };
00067
00071 enum BlendMode
00072 {
00073 BLEND_OFF,
00074 BLEND_HALF,
00075 BLEND_ADD,
00076 BLEND_DEST_ALPHA
00077 };
00078
00082 enum DrawFlag
00083 {
00084 FLAG_BOUND_CLIP,
00085 FLAG_SORT,
00086 FLAG_WRITE_RGB,
00087 FLAG_WRITE_ALPHA,
00088 FLAG_WRITE_DEPTH,
00089 FLAG_BACKFACE_CULLING,
00090 FLAG_BILINEAR
00091 };
00092
00096 virtual ~pgDraw();
00097
00102 bool hasScreen() const;
00103
00109 pgID getScreenID() const;
00110
00114 void setScreenID(pgID scr_id);
00115
00120 bool hasParent() const;
00121
00127 pgDraw* getParentN() const;
00128
00132 void setParent(pgDraw* parent);
00133
00140 pgDraw* getPrevAllN() const;
00141
00148 pgDraw* getNextAllN() const;
00149
00155 pgDraw* getPrevSiblingN() const;
00156
00162 pgDraw* getNextSiblingN() const;
00163
00167 pgDraw* getLastDesc() const;
00168
00172 bool hasChild() const;
00173
00177 pgDraw* getFirstChildN() const;
00178
00182 pgDraw* getLastChildN() const;
00183
00187 void moveFirst();
00188
00192 void moveLast();
00193
00197 void moveBefore(pgDraw* draw);
00198
00202 void moveAfter(pgDraw* draw);
00203
00207 DrawType getType() const;
00208
00212 bool isVisible() const;
00213
00217 void setVisible(bool is_visible);
00218
00222 pgCol getColor() const;
00223
00227 void setColor(pgCol col);
00228
00232 DepthTest getDepthTest() const;
00233
00237 void setDepthTest(DepthTest depth_test);
00238
00242 BlendMode getBlendMode() const;
00243
00247 void setBlendMode(BlendMode blend_mode);
00248
00252 bool isDrawFlag(DrawFlag draw_flag) const;
00253
00257 void setDrawFlag(DrawFlag draw_flag, bool is_on);
00258
00262 void clearDrawFlag();
00263
00267 void copyDrawFlag(const pgDraw* src);
00268
00272 void setPreset_defaultBlendOff();
00273
00277 void setPreset_defaultBlendHalf();
00278
00282 void setPreset_defaultBlendAdd();
00283
00287 const pgVec& getClipBoundMin() const;
00288
00292 const pgVec& getClipBoundMax() const;
00293
00297 void setClipBound(const pgVec& bound_min, const pgVec& bound_max);
00298
00302 const pgVec& getSortCenter() const;
00303
00307 void setSortCenter(const pgVec& sort_center);
00308
00313 r32 getSortOffset() const;
00314
00319 void setSortOffset(r32 sort_offset);
00320
00326 pgID getTextureID() const;
00327
00333 void setTextureID(pgID tex_id);
00334
00339 pgMat& local();
00340
00345 pgMat calcWorld() const;
00346
00351 pgCol calcFinalColor() const;
00352
00353 protected:
00354 enum PrivateFlag
00355 {
00356 FLAG_INITIALIZED,
00357 FLAG_VISIBLE
00358 };
00359
00360 pgDraw();
00361
00362 void setupWorld();
00363 void setupFinalColor();
00364 void setupSortValue(const pgMat& view);
00365 void setupDrawState();
00366
00367 virtual void render(const pgMat& view);
00368
00369 pgTree<pgDraw> m_tree;
00370 pgType<u8, DrawType> m_type;
00371 pgType<u8, DepthTest> m_depth_test;
00372 pgType<u8, BlendMode> m_blend_mode;
00373 pgFlag<u8, PrivateFlag> m_private_flag;
00374 pgFlag<u16, DrawFlag> m_draw_flag;
00375 pgID m_scr_id;
00376 pgTex* m_tex;
00377 pgMat m_local;
00378 pgMat m_world;
00379 pgCol m_local_col;
00380 pgCol m_final_col;
00381 pgVec m_bound_min;
00382 pgVec m_bound_max;
00383 pgVec m_sort_center;
00384 r32 m_sort_offset;
00385 r32 m_sort_value;
00386 pgDraw* m_next_sort;
00387
00388 private:
00389 pgDraw(const pgDraw&);
00390 void operator=(const pgDraw&);
00391 };