OpenGLContext.scenegraph.imagetexture
ImageTexture and MMImageTexture nodes using PIL
Classes
Mix-in for rendering static image textures
components
exposedField SFInt32 components 0
magFilter
field SFInt32 magFilter GL_NEAREST (9728)
minFilter
field SFInt32 minFilter GL_NEAREST (9728)
createTexture(
self
,
image
,
mode
= None
)
Create a new texture-holding object
Uses the TextureCache to try to minimise the
number of textures created
forTexture(
cls
,
tex
,
mode
)
Create a fake image texture node for the given on-card texture object
render(
self
,
visible
= 1
,
lit
= 1
,
mode
= None
)
Called by Shape before rendering associated geometry
- visible
- whether a visible rendering pass, if not, no normals, colours, or textures
- lit
- whether lighting is enabled, if not, no normals
returns whether this is a transparent texture
0 if non-transparent, but a valid texture
1 if transparent
None if not yet a valid texture
renderPost(
self
,
mode
= None
)
Called after rendering geometry to disable the texture
Note: this does *not* disable the blend mode we established, it
is left to the mode's post-rendering code to do this! As a result,
if you use this code outside of a scenegraph you will need to add
a call to reestablish the blending parameters you desire.
A texture loaded from an image file
image
exposedField PILImage image None
url
exposedField MFString url []
loadBackground(
self
,
url
,
contexts
= ()
)
Load an image from the given url in the background
- url
- SF or MFString URL to load relative to the node's root's baseURL
On success:
Sets the resulting PIL image to the
client's image property (triggering an un-caching
and re-compile if there was a previous image).
if contexts, iterate through the list calling
context.triggerRedraw(1)
setImage(
self
,
image
,
contexts
= ()
)
Set PIL image as our new image
- image
- open( ) PIL file with info and info['filename' defined
class ImageURLField(
MFString
):
class MMImageTexture(
ImageTexture
):
Mip-mapped version of ImageTexture
Only significant differences are the use of
the MMTexture class instead of Texture and the
default for minFilter being GL_LINEAR_MIPMAP_NEAREST
(which allows you to actually see the effects of
mip-mapping).
minFilter
field SFInt32 minFilter GL_LINEAR_MIPMAP_NEA