[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49322] branches/soc-2012-swiss_cheese/ source: Use glGenerateMipmaps() when supported rather than gluBuild2DMipmaps().
Mitchell Stokes
mogurijin at gmail.com
Sat Jul 28 06:11:50 CEST 2012
Revision: 49322
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49322
Author: moguri
Date: 2012-07-28 04:11:44 +0000 (Sat, 28 Jul 2012)
Log Message:
-----------
Use glGenerateMipmaps() when supported rather than gluBuild2DMipmaps(). This helps speed up texture loads on supported hardware. The GLES code is also using glGenerateMipmaps(), so we might want to do a bit more combining at some point (for GenerateMipmapRGBA()). However, for the time being I'm keeping it separate to make merging easier.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c 2012-07-28 04:03:31 UTC (rev 49321)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_draw.c 2012-07-28 04:11:44 UTC (rev 49322)
@@ -496,10 +496,19 @@
#ifndef GLES
static void GenerateMipmapRGBA(int high_bit, int w, int h, void * data)
{
+ if (GLEW_EXT_framebuffer_object) {
+ /* use hardware accelerated mipmap generation */
if (high_bit)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, w, h, 0, GL_RGBA, GL_FLOAT, data);
+ else
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ glGenerateMipmap(GL_TEXTURE_2D);
+ } else {
+ if (high_bit)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, w, h, GL_RGBA, GL_FLOAT, data);
else
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ }
}
#else
static void GenerateMipmapRGBA(int high_bit, int w, int h, void * data)
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp 2012-07-28 04:03:31 UTC (rev 49321)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp 2012-07-28 04:11:44 UTC (rev 49322)
@@ -180,7 +180,12 @@
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, x, y, GL_RGBA, GL_UNSIGNED_BYTE, pix );
+ if (GLEW_EXT_framebuffer_object) {
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix );
+ glGenerateMipmap(GL_TEXTURE_2D);
+ } else {
+ gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, x, y, GL_RGBA, GL_UNSIGNED_BYTE, pix );
+ }
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -227,7 +232,12 @@
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 );
+ if (GLEW_EXT_framebuffer_object) {
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, newPixels );
+ glGenerateMipmap(GL_TEXTURE_2D);
+ } else {
+ gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, nx, ny, GL_RGBA, GL_UNSIGNED_BYTE, newPixels );
+ }
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
More information about the Bf-blender-cvs
mailing list