Commit: 15957a9e4d640af223b0ff0b893139d436cab7fb
Author: Antony Riakiotakis
Date:   Fri Feb 27 14:47:39 2015 +0100
Branches: master
https://developer.blender.org/rB15957a9e4d640af223b0ff0b893139d436cab7fb

Get rid of gluScaleImage in our game engine as well.

===================================================================

M       source/blender/gpu/intern/gpu_draw.c
M       source/gameengine/Ketsji/BL_Texture.cpp
M       source/gameengine/VideoTexture/Texture.cpp
M       source/gameengine/VideoTexture/Texture.h

===================================================================

diff --git a/source/blender/gpu/intern/gpu_draw.c 
b/source/blender/gpu/intern/gpu_draw.c
index aa4a84a..3ed7253 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -983,7 +983,7 @@ static bool GPU_check_scaled_image(ImBuf *ibuf, Image *ima, 
float *frect, int x,
                if (rectw + x > x_limit) rectw--;
                if (recth + y > y_limit) recth--;
 
-               /* float rectangles are already continuous in memory so we can 
use gluScaleImage */
+               /* float rectangles are already continuous in memory so we can 
use IMB_scaleImBuf */
                if (frect) {
                        ImBuf *ibuf = IMB_allocFromBuffer(NULL, frect, w, h);
                        IMB_scaleImBuf(ibuf, rectw, recth);
diff --git a/source/gameengine/Ketsji/BL_Texture.cpp 
b/source/gameengine/Ketsji/BL_Texture.cpp
index 1a78efb..58739e7 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 5eb609c..9640c55 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 1befb62..ae778ba 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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to