18 AtomicAdjust::Pointer GraphicsStateGuardianBase::_gsg_list;
19 UpdateSeq GraphicsStateGuardianBase::_generated_shader_seq;
20 TypeHandle GraphicsStateGuardianBase::_type_handle;
33 if (gsg_list ==
nullptr) {
38 return gsg_list->_default_gsg;
48 if (gsg_list ==
nullptr) {
55 if (find(gsg_list->_gsgs.begin(), gsg_list->_gsgs.end(), default_gsg) == gsg_list->_gsgs.end()) {
57 nassert_raise(
"GSG not found or already destructed");
61 gsg_list->_default_gsg = default_gsg;
67 size_t GraphicsStateGuardianBase::
70 if (gsg_list ==
nullptr) {
75 return gsg_list->_gsgs.size();
85 nassertr(gsg_list !=
nullptr,
nullptr);
88 nassertr(n < gsg_list->_gsgs.size(),
nullptr);
89 return gsg_list->_gsgs[n];
99 if (gsg_list ==
nullptr) {
100 gsg_list =
new GSGList;
101 gsg_list->_default_gsg =
nullptr;
103 GSGList *orig_gsg_list = (GSGList *)
106 if (orig_gsg_list !=
nullptr) {
109 gsg_list = orig_gsg_list;
115 if (find(gsg_list->_gsgs.begin(), gsg_list->_gsgs.end(), gsg) != gsg_list->_gsgs.end()) {
120 gsg_list->_gsgs.push_back(gsg);
122 if (gsg_list->_default_gsg ==
nullptr) {
123 gsg_list->_default_gsg = gsg;
133 if (gsg_list ==
nullptr) {
140 GSGList::GSGs::iterator gi;
141 gi = find(gsg_list->_gsgs.begin(), gsg_list->_gsgs.end(), gsg);
142 if (gi == gsg_list->_gsgs.end()) {
147 gsg_list->_gsgs.erase(gi);
149 if (gsg_list->_default_gsg == gsg) {
150 if (!gsg_list->_gsgs.empty()) {
151 gsg_list->_default_gsg = *gsg_list->_gsgs.begin();
153 gsg_list->_default_gsg =
nullptr;
static Pointer get_ptr(const Pointer &var)
Atomically retrieves the snapshot value of the indicated variable.
get_gsg
Returns the nth GSG in the universe.
static void remove_gsg(GraphicsStateGuardianBase *gsg)
Called by a GSG destructor to remove a GSG from the available list.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
static GraphicsStateGuardianBase * get_default_gsg()
Returns a pointer to the "default" GSG.
static void set_default_gsg(GraphicsStateGuardianBase *default_gsg)
Specifies a particular GSG to use as the "default" GSG.
static void add_gsg(GraphicsStateGuardianBase *gsg)
Called by a GSG after it has been initialized, to add a new GSG to the available list.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
static Pointer compare_and_exchange_ptr(Pointer &mem, Pointer old_value, Pointer new_value)
Atomic compare and exchange.