diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-11 23:34:35 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-11 23:35:09 +0300 |
commit | 1d111cd046b051efe71c6863b1c4a65233c45ac9 (patch) | |
tree | 601e298f7f2400f25527ea8bc4497170d8bbe053 /source/blender/makesrna | |
parent | 8242a5bc853a74da1273fc7ad4b959ac716c563c (diff) |
Revert "Cleanup: remove image->bindcode, always wrap in GPUTexture."
This reverts commit 8242a5bc853a74da1273fc7ad4b959ac716c563c. This isn't
quite ready to use yet.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 26 |
2 files changed, 13 insertions, 22 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 9f6552e4587..cf486ee399f 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -298,13 +298,6 @@ static void rna_Image_resolution_set(PointerRNA *ptr, const float *values) BKE_image_release_ibuf(im, ibuf, lock); } -static int rna_Image_bindcode_get(PointerRNA *ptr) -{ - Image *ima = (Image *)ptr->data; - GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D]; - return (tex) ? GPU_texture_opengl_bindcode(tex) : 0; -} - static int rna_Image_depth_get(PointerRNA *ptr) { Image *im = (Image *)ptr->data; @@ -803,7 +796,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Image_bindcode_get", NULL, NULL); + RNA_def_property_int_sdna(prop, NULL, "bindcode"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 854036cc1dc..39164430140 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -220,30 +220,29 @@ 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) { - GPUTexture *tex = image->gputexture[TEXTARGET_TEXTURE_2D]; + ImBuf *ibuf; + unsigned int *bind = &image->bindcode[TEXTARGET_TEXTURE_2D]; int error = GL_NO_ERROR; + ImageUser iuser = {NULL}; + void *lock; - if (*tex) + if (*bind) return error; - - ImageUser iuser = {NULL}; iuser.framenr = frame; iuser.ok = true; - void *lock; - ImBuf *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) { BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); - BKE_image_release_ibuf(image, ibuf, lock); + BKE_image_release_ibuf(image, ibuf, NULL); return (int)GL_INVALID_OPERATION; } - int bindcode = 0; - GPU_create_gl_tex(&bindcode, ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, GL_TEXTURE_2D, + GPU_create_gl_tex(bind, 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); @@ -255,23 +254,22 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f if (error) { glDeleteTextures(1, (GLuint *)bind); - } - else { - image->gputexture[TEXTARGET_TEXTURE_2D] = GPU_texture_from_bindcode(GL_TEXTURE_2D, bindcode); + image->bindcode[TEXTARGET_TEXTURE_2D] = 0; } - BKE_image_release_ibuf(image, ibuf, lock); + BKE_image_release_ibuf(image, ibuf, NULL); 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 (image->gputexture[TEXTARGET_TEXTURE_2D] == NULL) + if (*bind == 0) error = rna_Image_gl_load(image, reports, frame, filter, mag); return error; |