00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef RENDERATTRIBREGISTRY_H
00016 #define RENDERATTRIBREGISTRY_H
00017
00018 #include "pandabase.h"
00019 #include "typeHandle.h"
00020 #include "vector_int.h"
00021 #include "pointerTo.h"
00022 #include "bitMask.h"
00023
00024 class RenderAttrib;
00025 class DeletedBufferChain;
00026
00027
00028
00029
00030
00031
00032
00033
00034 class EXPCL_PANDA_PGRAPH RenderAttribRegistry {
00035 private:
00036 RenderAttribRegistry();
00037 ~RenderAttribRegistry();
00038
00039 public:
00040 typedef CPT(RenderAttrib) MakeDefaultFunc();
00041
00042
00043
00044
00045
00046
00047
00048
00049 typedef BitMask32 SlotMask;
00050
00051 int register_slot(TypeHandle type_handle, int sort,
00052 MakeDefaultFunc *make_default_func);
00053
00054 PUBLISHED:
00055 INLINE int get_slot(TypeHandle type_handle) const;
00056 INLINE int get_max_slots() const;
00057
00058 INLINE int get_num_slots() const;
00059 INLINE TypeHandle get_slot_type(int slot) const;
00060 INLINE int get_slot_sort(int slot) const;
00061 void set_slot_sort(int slot, int sort);
00062 CPT(RenderAttrib) get_slot_default(int slot) const;
00063
00064 INLINE int get_num_sorted_slots() const;
00065 INLINE int get_sorted_slot(int n) const;
00066
00067 INLINE DeletedBufferChain *get_array_chain() const;
00068
00069 INLINE static RenderAttribRegistry *get_global_ptr();
00070
00071 public:
00072 INLINE static RenderAttribRegistry *quick_get_global_ptr();
00073
00074 private:
00075 static void init_global_ptr();
00076
00077 private:
00078 int _max_slots;
00079
00080 class SortSlots {
00081 public:
00082 INLINE SortSlots(RenderAttribRegistry *reg);
00083 INLINE bool operator () (int a, int b) const;
00084 RenderAttribRegistry *_reg;
00085 };
00086
00087 class RegistryNode {
00088 public:
00089 TypeHandle _type;
00090 int _sort;
00091 MakeDefaultFunc *_make_default_func;
00092 };
00093 typedef pvector<RegistryNode> Registry;
00094 Registry _registry;
00095
00096 vector_int _slots_by_type;
00097 vector_int _sorted_slots;
00098
00099 DeletedBufferChain *_array_chain;
00100
00101 static RenderAttribRegistry *_global_ptr;
00102 };
00103
00104 #include "renderAttribRegistry.I"
00105
00106 #endif
00107