Skip to content

AddTriangle

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

AddTriangle

AddTriangle:Int32 surface:Int32, v0:Int32, v1:Int32, v2:Int32
Parameter Mode Type Default Description
surface In Int32 required Surface handle.
v0 In Int32 required Index of the first corner.
v1 In Int32 required Index of the second corner.
v2 In Int32 required Index of the third corner.

Returns: The index of the new triangle, starting at 0.

Description

Joins three vertices of a surface into a triangle and returns the index of the triangle, which counts from 0. A triangle is only drawn when seen from the side where its corners go clockwise, which is why the order matters: if your triangle does not show, swap two of its vertices, or draw both sides with the 16 flag of EntityFX. The runtime stops with an error for a vertex index that does not exist.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
PositionEntity camera, 0, 0, -5
mesh = CreateMesh()
surf = CreateSurface(mesh)
a = AddVertex(surf, -2, -1, 0)
b = AddVertex(surf, -1, 1, 0)
c = AddVertex(surf, 0, -1, 0)
d = AddVertex(surf, 0.5, -1, 0)
e = AddVertex(surf, 1.5, 1, 0)
f = AddVertex(surf, 2.5, -1, 0)
; The left triangle goes clockwise as seen from the camera and is drawn.
AddTriangle surf, a, b, c
; The right one goes the other way around and is not.
AddTriangle surf, d, f, e
EntityFX mesh, 1
EntityColor mesh, 250, 200, 60
RenderWorld
Flip
WaitKey

Media

AddTriangle

Related Commands

AddVertex, ClearSurface, TriangleVertex

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally