[Bf-python] Image loading in GL memory
Willian Padovani Germano
wgermano at ig.com.br
Mon Sep 13 14:22:55 CEST 2004
Campbell Barton wrote:
> If they are not loaded in the texture view (Alt+Z)
> then the bindcode returned is 0-
Ah ok, thanks. I took a look at the red book and Blender sources.
Seems what is needed is the texels pointer: image->ibuf->rect, which can
then be passed to the glTexImage2D function, for example. My concern
was how to manage this storage (free it) and in drawmesh.c there's this
function: void free_all_realtime_images(void), that can be the simplest
solution to what is needed.
So that's it (names can be changed, of course):
1) add image.getTexelsPtr() method in Blender.Image's BPy_Image object
-- Python supports pointer types, so we can wrap / unwrap the pointer
without casting it to a long int or something.
2) add Blender.Image.FreeAllTextures() function, a wrapper or clone for
free_all_realtime_images(). If this doesn't crash Blender because we
deleted its textures (aka if Blender already has code to see that and
regenerate them), it's all done. Otherwise we will have to generate
Blender's own realtime images again inside this function or use some
other method, maybe leaving cleanup for the script itself.
What do you think?
BTW (unrelated to adding the new functionality), just a foolish
suggestion: did you consider a 3d thumbnailer in the 3d view? Like a
fancy "rack" of embedded 3d screens for the thumbnails, with buttons for
previous/next page and for selecting? It should already be possible to
do this with bpython -- and is possible with the game engine, though
maybe we need to add a function to Blender.Window to set draw mode for
individual 3d views.
--
Willian
More information about the Bf-python
mailing list