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 pgDrawMgr
00037 {
00038 friend class pgTex;
00039 friend class pgFont;
00040 friend class pgShd;
00041 friend class pgLts;
00042 friend class pgScr;
00043
00044 public:
00045 pgDefineException(ExceptionCalcFontDrawWidthFailed);
00046 pgDefineException(ExceptionCreateFreeTypeFailed);
00047 pgDefineException(ExceptionDestroyFreeTypeFailed);
00048 pgDefineException(ExceptionFontFinalizerFailed);
00049 pgDefineException(ExceptionFontInitializerFailed);
00050 pgDefineException(ExceptionInvalidArgument);
00051 pgDefineException(ExceptionInvalidCall);
00052 pgDefineException(ExceptionNotFound);
00053 pgDefineException(ExceptionNotInitialized);
00054 pgDefineException(ExceptionSameIDExists);
00055 pgDefineException(ExceptionTextureInitializerFailed);
00056
00057 static const pgID INVISIBLE_SCREEN_ID;
00058 static const pgID DEFAULT_3D_SCREEN_ID;
00059 static const pgID DEFAULT_2D_SCREEN_ID;
00060 static const pgID DEFAULT_LIGHT_SET_ID;
00061 static const pgID DEFAULT_SHADER_ID;
00062 static const u32 MAX_RENDER_INTERVAL_MSEC_TIME = 100;
00063
00064 static bool isShaderAvailable();
00065
00066 static u16 getMaxTextureLength();
00067 static u16 getValidTextureLength(u16 length);
00068 static u16 getTexturePixelSize(pgTex::TexFormat format);
00069
00070 static bool isCreated();
00071 static void createAfterRes();
00072 static void destroyBeforeRes();
00073
00074 static bool isRender();
00075 static void setRender(bool is_render);
00076
00077 static bool hasScreen(pgID scr_id);
00078 static pgScr* getScreen(pgID scr_id);
00079 static pgScr* newScreen(pgID scr_id);
00080 static void deleteScreen(pgID scr_id);
00081 static pgScr* getFirstScreenN();
00082 static pgScr* getLastScreenN();
00083
00084 static bool hasTexture(pgID tex_id);
00085 static pgTex* getTexture(pgID tex_id);
00086 static pgTex* newTexture(pgID tex_id, u16 width, u16 height, pgTex::TexFormat format);
00087 static pgTex* newTexture(pgID tex_id, u16 width, u16 height, pgTex::TexFormat format, const void* image, u32 image_size);
00088 static void deleteTexture(pgID tex_id);
00089 static pgTex* getFirstTextureN();
00090 static pgTex* getLastTextureN();
00091
00092 static u16 getFontIndexNum(pgID font_id);
00093 static pgID getFontID();
00094 static u16 getFontIndex();
00095 static void setFont(pgID font_id, u16 font_index);
00096 static u16 getFontSize();
00097 static u16 setFontSize(u16 font_size);
00098 static u16 calcFontDrawWidth(const char* str, ...);
00099 static u16 calcFontDrawWidth(const wchar_t* str, ...);
00100
00101 static bool hasShader(pgID shd_id);
00102 static pgShd* getShader(pgID shd_id);
00103 static pgShd* newShader(pgID shd_id, const char* vert_code, const char* frag_code, u8 uni_num, u8 att_num, u8 tex_num);
00104 static void deleteShader(pgID shd_id);
00105 static pgShd* getFirstShaderN();
00106 static pgShd* getLastShaderN();
00107
00108 static bool hasLightSet(pgID lts_id);
00109 static pgLts* getLightSet(pgID lts_id);
00110 static pgLts* newLightSet(pgID lts_id);
00111 static void deleteLightSet(pgID lts_id);
00112 static pgLts* getFirstLightSetN();
00113 static pgLts* getLastLightSetN();
00114
00115 static void deleteAllVramObjForSystem();
00116 static void renderForSystem();
00117
00118 private:
00119 static const u32 SCREEN_HASH_SIZE = 10;
00120 static const u32 TEXTURE_HASH_SIZE = 10;
00121 static const u32 SHADER_HASH_SIZE = 10;
00122 static const u32 LIGHTSET_HASH_SIZE = 10;
00123 static const u32 FONT_NAME_BUFFER_SIZE = 64;
00124
00125 pgDrawMgr();
00126 ~pgDrawMgr();
00127 void operator=(const pgDrawMgr&);
00128
00129 static pgDrawMgr* instance();
00130
00131 static void renderScreen(pgScr* scr, pgDraw** sort_list, const pgMat& view);
00132 static void sortList(pgDraw** sorted_start, pgDraw** sorted_end, pgDraw* target_list);
00133
00134 static void textureInitializer(pgID id, pgStr<char, 3> ext, const void* data, u32 data_size, void** exinfo);
00135 static void textureFinalizer(pgID id, pgStr<char, 3> ext, const void* data, u32 data_size, void* exinfo);
00136
00137 static void fontInitializer(pgID id, pgStr<char, 3> ext, const void* data, u32 data_size, void** exinfo);
00138 static void fontFinalizer(pgID id, pgStr<char, 3> ext, const void* data, u32 data_size, void* exinfo);
00139
00140 pgMap<pgID, pgScr*> m_scr_map;
00141 pgMap<pgID, pgTex*> m_tex_map;
00142 pgMap<pgID, pgShd*> m_shd_map;
00143 pgMap<pgID, pgLts*> m_lts_map;
00144 bool m_is_render;
00145 pgID m_font_id;
00146 u16 m_font_index;
00147 u16 m_font_size;
00148 void* m_font_info;
00149
00150 static pgDrawMgr* m_instance;
00151 };