Skip to content

CreateSurface

Narta Xaymar Dirks edited this page Oct 28, 2026 · 5 revisions
Blitz3D

CreateSurface

CreateSurface:Int32 mesh:Int32, brush:Int32=0
Parameter Mode Type Default Description
mesh In Int32 required Mesh handle.
brush In Int32 0 Brush that paints the new surface, or 0 for none. Defaults to 0.

Returns: The handle of the new surface.

Description

Adds an empty surface to a mesh and returns its handle. A mesh is a list of surfaces, and every surface is one batch of triangles that shares a material: color, texture and so on. Use one surface per material and put all triangles with that material into it, since each surface costs a draw call. Fill the surface with AddVertex and AddTriangle. A brush paints the surface right away, see PaintSurface.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
PositionEntity camera, 0, 0, -5
light = CreateLight()
RotateEntity light, 20, 20, 0
mesh = CreateMesh()
; Two surfaces in one mesh, each painted with its own brush.
red = CreateBrush(255, 80, 80)
blue = CreateBrush(80, 120, 255)
left = CreateSurface(mesh, red)
right = CreateSurface(mesh, blue)
For i = 0 To 1
	If i = 0 Then s = left Else s = right
	x = i * 2.2 - 2.0
	a = AddVertex(s, x, -1, 0)
	b = AddVertex(s, x, 1, 0)
	c = AddVertex(s, x + 1.8, 1, 0)
	d = AddVertex(s, x + 1.8, -1, 0)
	AddTriangle s, a, b, c
	AddTriangle s, a, c, d
Next
UpdateNormals mesh
RenderWorld
Flip
WaitKey

Media

CreateSurface

Related Commands

ClearSurface, FindSurface, GetSurface, PaintSurface

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally