diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2014-05-26 13:38:12 +0400 |
---|---|---|
committer | Ines Almeida <britalmeida@gmail.com> | 2015-02-21 15:16:19 +0300 |
commit | cf4646b95f7dac74fb67300a2df43bc973e7709d (patch) | |
tree | a8668ba87ebf164e80ea75a0a5ba743b585a4fe2 /source/gameengine/VideoTexture/Texture.cpp | |
parent | c391a678309c356fe983c42d4bf70f8686a99f30 (diff) |
commiting patch to fix T30173
Diffstat (limited to 'source/gameengine/VideoTexture/Texture.cpp')
-rw-r--r-- | source/gameengine/VideoTexture/Texture.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 74f36207774..5eb609c0823 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -41,6 +41,7 @@ #include "DNA_meshdata_types.h" #include "DNA_image_types.h" #include "IMB_imbuf_types.h" +#include "BKE_image.h" #include "MEM_guardedalloc.h" @@ -158,6 +159,7 @@ static PyObject *Texture_new(PyTypeObject *type, PyObject *args, PyObject *kwds) // initialize object structure self->m_actTex = 0; self->m_orgSaved = false; + self->m_imgBuf = NULL; self->m_imgTexture = NULL; self->m_matTexture = NULL; self->m_mipmap = false; @@ -282,7 +284,11 @@ PyObject *Texture_close(Texture * self) if (self->m_useMatTexture) self->m_matTexture->swapTexture(self->m_orgTex); else + { self->m_imgTexture->bindcode = self->m_orgTex; + BKE_image_release_ibuf(self->m_imgTexture, self->m_imgBuf, NULL); + self->m_imgBuf = NULL; + } // drop actual texture if (self->m_actTex != 0) { @@ -331,6 +337,12 @@ static PyObject *Texture_refresh(Texture *self, PyObject *args) self->m_orgTex = self->m_matTexture->swapTexture(self->m_actTex); else { + // Swapping will work only if the GPU has already loaded the image. + // If not, it will delete and overwrite our texture on next render. + // To avoid that, we acquire the image buffer now. + // WARNING: GPU has a ImageUser to pass, we don't. Using NULL + // works on image file, not necessarily on other type of image. + self->m_imgBuf = BKE_image_acquire_ibuf(self->m_imgTexture, NULL, NULL); self->m_orgTex = self->m_imgTexture->bindcode; self->m_imgTexture->bindcode = self->m_actTex; } |