, 1.0, 1.0), flipFaces=False)[source]

Create a box mesh.

Create a box mesh by specifying its size in three dimensions (x, y, z), or a single value (float) to create a cube. The resulting box will be centered about the origin. Texture coordinates and normals are automatically generated for each face.

Setting flipFaces=True will make faces and normals point inwards, this allows boxes to be viewed and lit correctly from the inside.

  • size (tuple or float) – Dimensions of the mesh. If a single value is specified, the box will be a cube. Provide a tuple of floats to specify the width, length, and height of the box (eg. size=(0.2, 1.3, 2.1)).

  • flipFaces (bool, optional) – If True, normals and face windings will be set to point inward towards the center of the box. Texture coordinates will remain the same. Default is False.


Vertex attribute arrays (position, texture coordinates, and normals) and triangle indices.

Return type:



Create a box mesh and draw it:

vertices, textureCoords, normals, faces = gltools.createBox()

vertexVBO = gltools.createVBO(vertices)
texCoordVBO = gltools.createVBO(textureCoords)
normalsVBO = gltools.createVBO(normals)
indexBuffer = gltools.createVBO(

vao = gltools.createVAO({0: vertexVBO, 8: texCoordVBO, 2: normalsVBO},

# in the rendering loop
gltools.drawVAO(vao, GL.GL_TRIANGLES)

Back to top