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
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-02-27 16:47:39 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-02-27 16:47:39 +0300
commit15957a9e4d640af223b0ff0b893139d436cab7fb (patch)
tree4fb2bdfa63a09b7d2d4cf807a044c160f3e90a75 /source/gameengine
parent55e7d726c4bbe3a27a0ad7ccd0d88de19e8e10bf (diff)
Get rid of gluScaleImage in our game engine as well.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/BL_Texture.cpp12
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp26
-rw-r--r--source/gameengine/VideoTexture/Texture.h4
3 files changed, 17 insertions, 25 deletions
diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp
index 1a78efb3c18..58739e7ef81 100644
--- a/source/gameengine/Ketsji/BL_Texture.cpp
+++ b/source/gameengine/Ketsji/BL_Texture.cpp
@@ -239,26 +239,26 @@ void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap)
int nx= power_of_2_min_i(x);
int ny= power_of_2_min_i(y);
- unsigned int *newPixels = (unsigned int *)malloc(nx*ny*sizeof(unsigned int));
-
- gluScaleImage(GL_RGBA, x, y, GL_UNSIGNED_BYTE, pix, nx,ny, GL_UNSIGNED_BYTE, newPixels);
+ ImBuf *ibuf = IMB_allocFromBuffer(pix, NULL, x, y);
+ IMB_scaleImBuf(ibuf, nx, ny);
+
glBindTexture(GL_TEXTURE_2D, mTexture );
if ( mipmap ) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, nx, ny, GL_RGBA, GL_UNSIGNED_BYTE, newPixels );
+ gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, nx, ny, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect );
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, newPixels );
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect );
}
if (GLEW_EXT_texture_filter_anisotropic)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- free(newPixels);
+ IMB_freeImBuf(ibuf);
}
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;