+// dynamic texture code [11/22/2007 Black]
+void R_MarkDirtyTexture(rtexture_t *rt) {
+ gltexture_t *glt = (gltexture_t*) rt;
+ if( !glt ) {
+ return;
+ }
+
+ // dont do anything if the texture is already dirty (and make sure this *is* a dynamic texture after all!)
+ if( !glt->dirtytexnum && glt->flags & GLTEXF_DYNAMIC ) {
+ glt->dirtytexnum = glt->texnum;
+ // mark it as dirty, so R_RealGetTexture gets called
+ glt->texnum = -1;
+ }
+}
+
+void R_MakeTextureDynamic(rtexture_t *rt, updatecallback_t updatecallback, void *data) {
+ gltexture_t *glt = (gltexture_t*) rt;
+ if( !glt ) {
+ return;
+ }
+
+ glt->flags |= GLTEXF_DYNAMIC;
+ glt->updatecallback = updatecallback;
+ glt->updatacallback_data = data;
+ glt->dirtytexnum = 0;
+}
+
+static void R_UpdateDynamicTexture(gltexture_t *glt) {
+ glt->texnum = glt->dirtytexnum;
+ // reset dirtytexnum again (not dirty anymore)
+ glt->dirtytexnum = 0;
+ // TODO: now assert that t->texnum != 0 ?
+ if( glt->updatecallback ) {
+ glt->updatecallback( (rtexture_t*) glt, glt->updatacallback_data );
+ }
+}
+