Skip to content

CreateTexture

Claude edited this page Oct 27, 2026 · 15 revisions
Blitz3D

CreateTexture

CreateTexture:Int32 width:Int32, height:Int32, flags:Int32=0, frames:Int32=1
Parameter Type Default Description
width Int32 required Width in pixels.
height Int32 required Height in pixels.
flags Int32 0 Sum of the flags above. Defaults to 1.
frames Int32 1 Number of animation frames. Defaults to 1.

Returns: A texture handle.

Description

Makes an empty texture of the given size and returns its handle. Fill it by drawing on its buffer: call SetBuffer with TextureBuffer and use the normal 2D commands, then switch back to the back buffer and put the texture on something with EntityTexture or a brush.

The flags are added together, so 1 + 2 is a color texture that also has an alpha channel:

Flag Meaning
1 Color, the default.
2 Alpha. Dark texels are see-through, bright texels are solid.
4 Masked. Texels that are exactly black are not drawn.
8 Mipmapped. Distant surfaces use smaller, blurrier copies, which are made again from the picture after you draw on the texture.
16 Clamp U. Coordinates outside 0 to 1 repeat the edge texel instead of tiling.
32 Clamp V. The same for the vertical direction.
64 Spherical environment map.
128 Cubic environment map.
256 Keep the texture in video memory.
512 Use a high color format even in low color modes.
1024 Point sampling: no smoothing between texels.
65536 Use the second set of texture coordinates of the mesh, see TextureCoords.

The texture is created at the size you ask for, so TextureWidth and TextureHeight return exactly what you passed. Power-of-two sizes are the safest choice for other Blitz3D implementations.

Differences

  • Only flags 2, 4, 8, 16, 32 and 65536 change how the texture looks. Video memory (256), high color (512) and point sampling (1024) are accepted and stored, but the texture is always drawn with linear filtering. A sphere map (64) takes its coordinates from the normal of the surface in the view, and ScaleTexture, PositionTexture and RotateTexture do not change them. A cube map (128) has six faces of the size you give, chosen with SetCubeFace and shown as SetCubeMode says; it does not have mip maps. A texture with both flags is drawn as a plain one. Without flag 8 it has no mip maps.
  • The alpha (2) flag is only applied to pictures that LoadTexture or LoadAnimTexture read from a file. A texture made with CreateTexture and drawn on stays opaque everywhere, also where you drew black, unless it is masked (4): the masked flag does cut out black there.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
CameraClsColor camera, 70, 100, 160
light = CreateLight()
RotateEntity light, 40, 30, 0
cube = CreateCube()
PositionEntity cube, 0, 0, 4.2
TurnEntity cube, 25, 35, 0

tex = CreateTexture(128, 128)
SetBuffer TextureBuffer(tex)
ClsColor 240, 240, 240
Cls
Color 30, 90, 200
For y = 0 To 7
	For x = 0 To 7
		If (x + y) Mod 2 = 0 Then Rect x * 16, y * 16, 16, 16, 1
	Next
Next
Color 220, 40, 40
Oval 32, 32, 64, 64, 1

SetBuffer BackBuffer()
EntityTexture cube, tex
RenderWorld
Flip
WaitKey

Media

CreateTexture

Related Commands

ClearTextureFilters, CreateSampler 〔BlitzLLVM〕, FreeTexture, LoadAnimTexture, LoadTexture, PositionTexture, RotateTexture, ScaleTexture

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

Clone this wiki locally