forked from bartvdbraak/blender
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)
This commit is contained in:
parent
6d03e94491
commit
664c611fc8
@ -35,6 +35,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "DNA_packedFile_types.h"
|
#include "DNA_packedFile_types.h"
|
||||||
|
#include "DNA_userdef_types.h"
|
||||||
|
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
@ -57,6 +58,7 @@
|
|||||||
|
|
||||||
#include "BIF_gl.h"
|
#include "BIF_gl.h"
|
||||||
#include "GPU_draw.h"
|
#include "GPU_draw.h"
|
||||||
|
#include "GPU_debug.h"
|
||||||
|
|
||||||
#include "DNA_image_types.h"
|
#include "DNA_image_types.h"
|
||||||
#include "DNA_scene_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);
|
ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
|
||||||
|
|
||||||
|
/* clean glError buffer */
|
||||||
|
while (glGetError() != GL_NO_ERROR) {}
|
||||||
|
|
||||||
if (ibuf == NULL || ibuf->rect == NULL) {
|
if (ibuf == NULL || ibuf->rect == NULL) {
|
||||||
BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
|
BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
|
||||||
BKE_image_release_ibuf(image, ibuf, NULL);
|
BKE_image_release_ibuf(image, ibuf, NULL);
|
||||||
return (int)GL_INVALID_OPERATION;
|
return (int)GL_INVALID_OPERATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* could be made into a function? */
|
GPU_create_gl_tex(bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y,
|
||||||
glGenTextures(1, (GLuint *)bind);
|
(filter != GL_NEAREST && filter != GL_LINEAR), false, image);
|
||||||
glBindTexture(GL_TEXTURE_2D, *bind);
|
|
||||||
|
|
||||||
if (filter != GL_NEAREST && filter != GL_LINEAR)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter);
|
||||||
error = (int)gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
if (!error) {
|
error = glGetError();
|
||||||
/* clean glError buffer */
|
|
||||||
while (glGetError() != GL_NO_ERROR) {}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
glDeleteTextures(1, (GLuint *)bind);
|
glDeleteTextures(1, (GLuint *)bind);
|
||||||
|
Loading…
Reference in New Issue
Block a user