diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index cd87938288..cfe143214d 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -419,6 +419,7 @@ rebuild_bitplanes() { Texture *attach[RTP_COUNT]; memset(attach, 0, sizeof(Texture *) * RTP_COUNT); _texture_contexts.clear(); + _textures.clear(); // Sort the textures list into appropriate slots. { @@ -793,6 +794,8 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, _fb_properties.setup_color_texture(tex); } + _textures.push_back(tex); + TextureContext *tc = tex->prepare_now(glgsg->get_prepared_objects(), glgsg); nassertv(tc != nullptr); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.h b/panda/src/glstuff/glGraphicsBuffer_src.h index ab07322293..f718e134f8 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.h +++ b/panda/src/glstuff/glGraphicsBuffer_src.h @@ -128,6 +128,10 @@ protected: typedef pvector TextureContexts; TextureContexts _texture_contexts; + // List of textures we need to keep a reference to. + typedef pvector Textures; + Textures _textures; + // The cube map face we are currently drawing to or have just finished // drawing to, or -1 if we are not drawing to a cube map. int _bound_tex_page;