diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2012-05-24 00:19:40 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2012-05-24 00:19:40 +0400 |
commit | 5d82173a780735a0bb1d3d54e2ffae1ddb6644aa (patch) | |
tree | e927c4270f62963d5cb3928cc6b0f6e4ff7ba5cc /source | |
parent | 3136e8dce80bb3538290ed0aa0b778b7eeabbd20 (diff) |
Image.gl_touch - routine to prevent the image to be cleared by blender cache garbage collection system
* if the image is not loaded (bindcode == 0) load the image
This needs to be called often. If the image is 'cleaned' by Blender, it will not help to load it after.
[ gl_load returns the errors: GL_STACK_OVERFLOW(1283) or GL_STACK_UNDERFLOW (1284) ]
Thanks Campbell for the suggestion on how to handle this (BKE_image_tag_time)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_image_api.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 3d937fc561d..cf19002f44e 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -224,6 +224,19 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int return error; } +static int rna_Image_gl_touch(Image *image, ReportList *reports, int filter, int mag) +{ + unsigned int *bind = &image->bindcode; + int error = GL_NO_ERROR; + + BKE_image_tag_time(image); + + if (*bind == 0) + error = rna_Image_gl_load(image, reports, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR); + + return error; +} + static void rna_Image_gl_free(Image *image) { GPU_free_image(image); @@ -274,6 +287,17 @@ void RNA_api_image(StructRNA *srna) parm = RNA_def_int(func, "height", 0, 1, 10000, "", "Height", 1, 10000); RNA_def_property_flag(parm, PROP_REQUIRED); + func = RNA_def_function(srna, "gl_touch", "rna_Image_gl_touch"); + RNA_def_function_ui_description(func, "Delay the image from being cleaned from the cache due inactivity"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_int(func, "filter", GL_LINEAR_MIPMAP_NEAREST, -INT_MAX, INT_MAX, "Filter", + "The texture minifying function to use if the image wan't loaded", -INT_MAX, INT_MAX); + RNA_def_int(func, "mag", GL_LINEAR, -INT_MAX, INT_MAX, "Magnification", + "The texture magnification function to use if the image wan't loaded", -INT_MAX, INT_MAX); + /* return value */ + parm = RNA_def_int(func, "error", 0, -INT_MAX, INT_MAX, "Error", "OpenGL error value", -INT_MAX, INT_MAX); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "gl_load", "rna_Image_gl_load"); RNA_def_function_ui_description(func, "Load the image into OpenGL graphics memory"); RNA_def_function_flag(func, FUNC_USE_REPORTS); |