diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-02-27 16:47:39 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-02-27 16:47:39 +0300 |
commit | 15957a9e4d640af223b0ff0b893139d436cab7fb (patch) | |
tree | 4fb2bdfa63a09b7d2d4cf807a044c160f3e90a75 /source/gameengine/VideoTexture | |
parent | 55e7d726c4bbe3a27a0ad7ccd0d88de19e8e10bf (diff) |
Get rid of gluScaleImage in our game engine as well.
Diffstat (limited to 'source/gameengine/VideoTexture')
-rw-r--r-- | source/gameengine/VideoTexture/Texture.cpp | 26 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/Texture.h | 4 |
2 files changed, 11 insertions, 19 deletions
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 5eb609c0823..9640c5544da 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -57,6 +57,9 @@ #include <memory.h> #include "glew-mx.h" +extern "C" { + #include "IMB_imbuf.h" +} // macro for exception handling and logging #define CATCH_EXCP catch (Exception & exp) \ @@ -163,8 +166,7 @@ static PyObject *Texture_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self->m_imgTexture = NULL; self->m_matTexture = NULL; self->m_mipmap = false; - self->m_scaledImg = NULL; - self->m_scaledImgSize = 0; + self->m_scaledImBuf = NULL; self->m_source = NULL; self->m_lastClock = 0.0; // return allocated object @@ -186,7 +188,7 @@ static void Texture_dealloc(Texture *self) PyObject *ret = Texture_close(self); Py_DECREF(ret); // release scaled image buffer - delete [] self->m_scaledImg; + IMB_freeImBuf(self->m_scaledImBuf); // release object Py_TYPE((PyObject *)self)->tp_free((PyObject *)self); } @@ -370,20 +372,12 @@ static PyObject *Texture_refresh(Texture *self, PyObject *args) // scale texture if needed if (size[0] != orgSize[0] || size[1] != orgSize[1]) { - // if scaled image buffer is smaller than needed - if (self->m_scaledImgSize < (unsigned int)(size[0] * size[1])) - { - // new size - self->m_scaledImgSize = size[0] * size[1]; - // allocate scaling image - delete [] self->m_scaledImg; - self->m_scaledImg = new unsigned int[self->m_scaledImgSize]; - } - // scale texture - gluScaleImage(GL_RGBA, orgSize[0], orgSize[1], GL_UNSIGNED_BYTE, texture, - size[0], size[1], GL_UNSIGNED_BYTE, self->m_scaledImg); + IMB_freeImBuf(self->m_scaledImBuf); + self->m_scaledImBuf = IMB_allocFromBuffer(texture, NULL, orgSize[0], orgSize[1]); + IMB_scaleImBuf(self->m_scaledImBuf, size[0], size[1]); + // use scaled image instead original - texture = self->m_scaledImg; + texture = self->m_scaledImBuf->rect; } // load texture for rendering loadTexture(self->m_actTex, texture, size, self->m_mipmap); diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index 1befb620447..ae778bae704 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -71,9 +71,7 @@ struct Texture bool m_mipmap; // scaled image buffer - unsigned int * m_scaledImg; - // scaled image buffer size - unsigned int m_scaledImgSize; + ImBuf * m_scaledImBuf; // last refresh double m_lastClock; |