purpose: Create a texture for display on the screen with mglBltTexture image can either be grayscale nxm, color nxmx3 or color+alpha nxmx4
usage: texture = mglCreateTexture(image,axis)
argument | value |
---|---|
image | nxm matrix of grayscale values from 0 to 255, or nxmx3 matrix of RGB values or nxmx4 of RGBA values |
axis | 'xy' rows are x and columns are y dimension (default–matlab oriented matrix, i.e. will give you the same results as using imagesc), 'yx' rows are y and columns are x dimension |
OUTPUT: texture | a texture structure that can be drawn to the screen using mglBltTexture |
mglOpen; mglClearScreen mglScreenCoordinates texture = mglCreateTexture(round(rand(100,100)*255)); mglBltTexture(texture,[0 0]); mglFlush;
When you are done using a texture, you may want to free its memory using mglDeleteTexture.
purpose: Draw a texture to the screen in desired position.
usage: mglBltTexture(texture,position,<hAlignment>,<vAlignment>,<rotation>)
argument | value |
---|---|
texture | A texture structure created by mglCreateTexture or mglText. |
position | Either a 2-vector [xpos ypos] or 4-vector [xpos ypos width height]. units are degrees. |
hAlignment | -1 = left, 0 = center, 1 = right (defaults to center) |
vAlignment | -1 = top, 0 = center, 1 = bottom (defaults to center) |
rotation | rotation in degrees, defaults to 0 |
To display several textures at once, texture can be an array of n textures, position is nx2, or nx4 and hAlignment, vAlignment and rotation are either a single value or an array of n.
multiple textures:
mglOpen; mglVisualAngleCoordinates(57,[16 12]); image = rand(200,200)*255; imageTex = mglCreateTexture(image); mglBltTexture([imageTex imageTex],[-3 0;3 0],0,0,[-15 15]); mglFlush;
single textures
mglOpen; mglVisualAngleCoordinates(57,[16 12]); image = rand(200,200)*255; imageTex = mglCreateTexture(image); mglBltTexture(imageTex,[0 0]); mglFlush;
purpose: Deletes a texture. This will free up memory for textures that will not be drawn again. Note that when you call mglClose texture memory is freed up. You only need to call this if you are running out of memory and have textures that you do not need to use anymore.
usage: mglDeleteTexture(tex)
argument | value |
---|---|
tex | The texture created by mglCreateTexture that you want to delete |
mglOpen; mglClearScreen mglScreenCoordinates texture = mglCreateTexture(round(rand(100,100)*255)); mglBltTexture(texture,[0 0]); mglFlush; mglDeleteTexture(texture);