Skip to content
Permalink
Browse files

gobj: use range for where possible in PreparedGraphicsObjects

This makes the code easier to read and maintain.
  • Loading branch information
rdb committed Nov 9, 2019
1 parent 9201d75 commit f1b235e06594f4c0a2c028adfe2ef2241e4091e0
Showing with 13 additions and 38 deletions.
  1. +13 −38 panda/src/gobj/preparedGraphicsObjects.cxx
@@ -274,11 +274,7 @@ release_all_textures() {

int num_textures = (int)_prepared_textures.size() + (int)_enqueued_textures.size();

Textures::iterator tci;
for (tci = _prepared_textures.begin();
tci != _prepared_textures.end();
++tci) {
TextureContext *tc = (*tci);
for (TextureContext *tc : _prepared_textures) {
tc->get_texture()->clear_prepared(tc->get_view(), this);
tc->_object = nullptr;

@@ -599,11 +595,7 @@ release_all_geoms() {

int num_geoms = (int)_prepared_geoms.size() + (int)_enqueued_geoms.size();

Geoms::iterator gci;
for (gci = _prepared_geoms.begin();
gci != _prepared_geoms.end();
++gci) {
GeomContext *gc = (*gci);
for (GeomContext *gc : _prepared_geoms) {
gc->_geom->clear_prepared(this);
gc->_geom = nullptr;

@@ -774,11 +766,7 @@ release_all_shaders() {

int num_shaders = (int)_prepared_shaders.size() + (int)_enqueued_shaders.size();

Shaders::iterator sci;
for (sci = _prepared_shaders.begin();
sci != _prepared_shaders.end();
++sci) {
ShaderContext *sc = (*sci);
for (ShaderContext *sc : _prepared_shaders) {
sc->_shader->clear_prepared(this);
sc->_shader = nullptr;

@@ -952,11 +940,8 @@ release_all_vertex_buffers() {

int num_vertex_buffers = (int)_prepared_vertex_buffers.size() + (int)_enqueued_vertex_buffers.size();

Buffers::iterator vbci;
for (vbci = _prepared_vertex_buffers.begin();
vbci != _prepared_vertex_buffers.end();
++vbci) {
VertexBufferContext *vbc = (VertexBufferContext *)(*vbci);
for (BufferContext *bc : _prepared_vertex_buffers) {
VertexBufferContext *vbc = (VertexBufferContext *)bc;
vbc->get_data()->clear_prepared(this);
vbc->_object = nullptr;

@@ -973,9 +958,8 @@ release_all_vertex_buffers() {
++bci) {
BufferList &buffer_list = (*bci).second;
nassertr(!buffer_list.empty(), num_vertex_buffers);
BufferList::iterator li;
for (li = buffer_list.begin(); li != buffer_list.end(); ++li) {
VertexBufferContext *vbc = (VertexBufferContext *)(*li);
for (BufferContext *bc : buffer_list) {
VertexBufferContext *vbc = (VertexBufferContext *)bc;
_released_vertex_buffers.push_back(vbc);
}
}
@@ -1150,11 +1134,8 @@ release_all_index_buffers() {

int num_index_buffers = (int)_prepared_index_buffers.size() + (int)_enqueued_index_buffers.size();

Buffers::iterator ibci;
for (ibci = _prepared_index_buffers.begin();
ibci != _prepared_index_buffers.end();
++ibci) {
IndexBufferContext *ibc = (IndexBufferContext *)(*ibci);
for (BufferContext *bc : _prepared_index_buffers) {
IndexBufferContext *ibc = (IndexBufferContext *)bc;
ibc->get_data()->clear_prepared(this);
ibc->_object = nullptr;

@@ -1171,10 +1152,9 @@ release_all_index_buffers() {
++bci) {
BufferList &buffer_list = (*bci).second;
nassertr(!buffer_list.empty(), num_index_buffers);
BufferList::iterator li;
for (li = buffer_list.begin(); li != buffer_list.end(); ++li) {
IndexBufferContext *vbc = (IndexBufferContext *)(*li);
_released_index_buffers.push_back(vbc);
for (BufferContext *bc : buffer_list) {
IndexBufferContext *ibc = (IndexBufferContext *)bc;
_released_index_buffers.push_back(ibc);
}
}
_index_buffer_cache.clear();
@@ -1337,12 +1317,7 @@ release_all_shader_buffers() {

int num_shader_buffers = (int)_prepared_shader_buffers.size() + (int)_enqueued_shader_buffers.size();

Buffers::iterator bci;
for (bci = _prepared_shader_buffers.begin();
bci != _prepared_shader_buffers.end();
++bci) {

BufferContext *bc = (BufferContext *)(*bci);
for (BufferContext *bc : _prepared_shader_buffers) {
((ShaderBuffer *)bc->_object)->clear_prepared(this);
bc->_object = nullptr;
_released_shader_buffers.push_back(bc);

0 comments on commit f1b235e

Please sign in to comment.
You can’t perform that action at this time.