[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46953] trunk/blender/source/blender/ makesrna/intern/rna_image_api.c: Image. gl_touch - routine to prevent the image to be cleared by blender cache garbage collection system

Dalai Felinto dfelinto at gmail.com
Wed May 23 22:19:41 CEST 2012


Revision: 46953
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46953
Author:   dfelinto
Date:     2012-05-23 20:19:40 +0000 (Wed, 23 May 2012)
Log Message:
-----------
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)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_image_api.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_image_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image_api.c	2012-05-23 20:03:16 UTC (rev 46952)
+++ trunk/blender/source/blender/makesrna/intern/rna_image_api.c	2012-05-23 20:19:40 UTC (rev 46953)
@@ -224,6 +224,19 @@
 	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 @@
 	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);




More information about the Bf-blender-cvs mailing list