CreateTexture ( width,height[,flags][,frames] )
Parameters:
| width - width of texture height - height of texture flags (optional) - texture flag 1: Color 2: Alpha 4: Masked 8: Mipmapped 16: Clamp U 32: Clamp V 64: Spherical reflection map frames (optional) - no of frames texture will have |
Description:
| Creates a texture and returns its handle. Width and height are the size of the texture. Note that the actual texture size may be different from the width and height requested, as different types of 3D hardware support different sizes of texture. The optional flags parameter allows you to apply certain effects to the texture. Flags can be added to combine two or more effects, eg. 3 (1+2) = texture with color and alpha maps. Here
are quick descriptions of the flags: Once you have created a texture, use SetBuffer TextureBuffer to draw to it. However, to display 2D graphics on a texture, it is usually quicker to draw to an image and then copy it to the texturebuffer, and to display 3D graphics on a texture, your only option is to copy from the backbuffer to the texturebuffer. See also: LoadTexture, LoadAnimTexture. |
| ; CreateTexture Example ; --------------------- Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() RotateEntity light,90,0,0 cube=CreateCube() PositionEntity cube,0,0,5 ; Create texture of size 256x256 tex=CreateTexture(256,256) ; Set buffer - texture buffer SetBuffer TextureBuffer(tex) ; Clear texture buffer with background white color ClsColor 255,255,255 Cls ; Draw text on texture font=LoadFont("arial",24) SetFont font Color 0,0,0 Text 0,0,"This texture" Text 0,40,"was created using" : Color 0,0,255 Text 0,80,"CreateTexture()" : Color 0,0,0 Text 0,120,"and drawn to using" : Color 0,0,255 Text 0,160,"SetBuffer TextureBuffer()" ; Texture cube with texture EntityTexture cube,tex ; Set buffer - backbuffer SetBuffer BackBuffer() While Not KeyDown( 1 ) pitch#=0 yaw#=0 roll#=0 If KeyDown( 208 )=True Then pitch#=-1 If KeyDown( 200 )=True Then pitch#=1 If KeyDown( 203 )=True Then yaw#=-1 If KeyDown( 205 )=True Then yaw#=1 If KeyDown( 45 )=True Then roll#=-1 If KeyDown( 44 )=True Then roll#=1 TurnEntity cube,pitch#,yaw#,roll# RenderWorld Flip Wend End |