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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-06-11 23:30:59 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-06-12 00:24:04 +0300
commit1dc93f90a003e0b8fa723994101a93dd1a41e0fa (patch)
tree843069e944ab2f2e36c534fa0ce0a2d5d0cf8d22 /source/blender/makesrna/intern/rna_image_api.c
parent1d111cd046b051efe71c6863b1c4a65233c45ac9 (diff)
Cleanup: remove image->bindcode, always wrap in GPUTexture.
This simplifies code, and will hopefully make UDIM usage of GPUTexture a little easier.
Diffstat (limited to 'source/blender/makesrna/intern/rna_image_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 39164430140..d839995d15e 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -220,29 +220,30 @@ static void rna_Image_scale(Image *image, ReportList *reports, int width, int he
static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int filter, int mag)
{
- ImBuf *ibuf;
- unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D];
+ GPUTexture *tex = image->gputexture[TEXTARGET_TEXTURE_2D];
int error = GL_NO_ERROR;
- ImageUser iuser = {NULL};
- void *lock;
- if (*bind)
+ if (tex)
return error;
+
+ ImageUser iuser = {NULL};
iuser.framenr = frame;
iuser.ok = true;
- ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
+ void *lock;
+ ImBuf *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);
+ BKE_image_release_ibuf(image, ibuf, lock);
return (int)GL_INVALID_OPERATION;
}
- GPU_create_gl_tex(bind, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
+ unsigned int bindcode = 0;
+ GPU_create_gl_tex(&bindcode, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D,
(filter != GL_NEAREST && filter != GL_LINEAR), false, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter);
@@ -253,23 +254,24 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f
error = glGetError();
if (error) {
- glDeleteTextures(1, (GLuint *)bind);
- image->bindcode[TEXTARGET_TEXTURE_2D] = 0;
+ glDeleteTextures(1, (GLuint *)&bindcode);
+ }
+ else {
+ image->gputexture[TEXTARGET_TEXTURE_2D] = GPU_texture_from_bindcode(GL_TEXTURE_2D, bindcode);
}
- BKE_image_release_ibuf(image, ibuf, NULL);
+ BKE_image_release_ibuf(image, ibuf, lock);
return error;
}
static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame, int filter, int mag)
{
- unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D];
int error = GL_NO_ERROR;
BKE_image_tag_time(image);
- if (*bind == 0)
+ if (image->gputexture[TEXTARGET_TEXTURE_2D] == NULL)
error = rna_Image_gl_load(image, reports, frame, filter, mag);
return error;