Skip to content

SetCameraProjectionMatrix

Narta Xaymar Dirks edited this page Nov 23, 2026 · 5 revisions

SetCameraProjectionMatrix

SetCameraProjectionMatrix:Void camera:Int32, matrix:FloatMatrix4x4
Parameter Mode Type Default Description
camera In Int32 required Camera handle.
matrix In FloatMatrix4x4 required The projection matrix.

Description

Gives a camera a projection matrix of its own. It replaces CameraZoom, CameraRange and CameraProjMode until ResetCameraProjectionMatrix is called; they can still be changed meanwhile and are used again after the reset. This is a BlitzLLVM extension.

The matrix uses the usual convention: the camera looks down +Z, X is to the right and Y up, and the depth goes from 0 at the near plane to 1 at the far plane. m[column][row] is one number. For a perspective matrix the fourth row is 0, 0, 1, 0, for an orthographic one 0, 0, 0, 1. BlitzLLVM turns it into what the GPU needs itself, so the same matrix works on every renderer.

What it is good for:

  • A near and far plane that CameraRange can't give, or a view that is not the same on both sides.
  • Pictures bigger than the screen: render the view in tiles, each with a matrix that shows one part of it, into a texture (SetCameraBuffer), and put the tiles together.
  • Mirrors and portals, with a matrix whose near plane is the mirror.

The engine still needs a near and a far plane for fog, soft sprite edges and culling, and reads them out of the matrix: they are exact for a usual perspective or orthographic matrix and close for others. A camera with a matrix of its own draws even with CameraProjMode camera, 0. CameraPick and CameraProject use the matrix too.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
cube = CreateCube()
PositionEntity cube, 0, 0, 5
; The same picture as CameraZoom 1 and CameraRange 1, 1000, written out.
Local near# = 1, far# = 1000
Local m:FloatMatrix4x4
m[0][0] = 1
m[1][1] = 320.0 / 240.0
m[2][2] = far / (far - near)
m[2][3] = 1
m[3][2] = -far * near / (far - near)
SetCameraProjectionMatrix camera, m
RenderWorld
Flip

Related Commands

CameraClsColor, CameraClsMode, GetCameraProjectionMatrix, GetCameraViewMatrix, ResetCameraProjectionMatrix, ResetCameraViewMatrix, SetCameraBuffer, SetCameraViewMatrix

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally