Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2014-05-26 13:38:12 +0400
committerInes Almeida <britalmeida@gmail.com>2015-02-21 15:16:19 +0300
commitcf4646b95f7dac74fb67300a2df43bc973e7709d (patch)
treea8668ba87ebf164e80ea75a0a5ba743b585a4fe2 /source
parentc391a678309c356fe983c42d4bf70f8686a99f30 (diff)
commiting patch to fix T30173
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp12
-rw-r--r--source/gameengine/VideoTexture/Texture.h4
2 files changed, 16 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;
}
diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h
index c85b1228864..1befb620447 100644
--- a/source/gameengine/VideoTexture/Texture.h
+++ b/source/gameengine/VideoTexture/Texture.h
@@ -43,6 +43,8 @@
#include "Exception.h"
+struct ImBuf;
+
// type Texture declaration
struct Texture
{
@@ -58,6 +60,8 @@ struct Texture
// original texture saved
bool m_orgSaved;
+ // kernel image buffer, to make sure the image is loaded before we swap the bindcode
+ struct ImBuf *m_imgBuf;
// texture image for game materials
Image * m_imgTexture;
// texture for blender materials