diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-03-16 18:07:21 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-03-16 18:07:21 +0300 |
commit | 664c611fc8838151bc570fc39657dac9970a1c6f (patch) | |
tree | f4ece1852e71b307074a838c90f9198854c06330 /source/blender | |
parent | 6d03e9449177c7b0e9d749de8507eaaea653397b (diff) |
Get rid of gluBuild2DMipmaps on rna API.
Code here is a bit weird/simpler than GPU_draw, but we can reuse the API
here, albeit with a few restrictions (no high resolution, custom
filtering mode - which will probably get lost next time blender reloads
textures)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 357490924f2..b9a1237c1f2 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -35,6 +35,7 @@ #include <time.h> #include "DNA_packedFile_types.h" +#include "DNA_userdef_types.h" #include "BLI_utildefines.h" #include "BLI_path_util.h" @@ -57,6 +58,7 @@ #include "BIF_gl.h" #include "GPU_draw.h" +#include "GPU_debug.h" #include "DNA_image_types.h" #include "DNA_scene_types.h" @@ -232,31 +234,23 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock); + /* clean glError buffer */ + while (glGetError() != GL_NO_ERROR) {} + if (ibuf == NULL || ibuf->rect == NULL) { BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); BKE_image_release_ibuf(image, ibuf, NULL); return (int)GL_INVALID_OPERATION; } - /* could be made into a function? */ - glGenTextures(1, (GLuint *)bind); - glBindTexture(GL_TEXTURE_2D, *bind); - - if (filter != GL_NEAREST && filter != GL_LINEAR) - error = (int)gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + GPU_create_gl_tex(bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, + (filter != GL_NEAREST && filter != GL_LINEAR), false, image); - if (!error) { - /* clean glError buffer */ - while (glGetError() != GL_NO_ERROR) {} + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, image->tpageflag & IMA_CLAMP_U ? GL_CLAMP : GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, image->tpageflag & IMA_CLAMP_V ? GL_CLAMP : GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - error = (int)glGetError(); - } + error = glGetError(); if (error) { glDeleteTextures(1, (GLuint *)bind); |