Tiny3D
Loading...
Searching...
No Matches
t3d.h File Reference
#include <t3d/t3dmath.h>
#include <libdragon.h>
Include dependency graph for t3d.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  __attribute__
 
struct  T3DViewport
 
struct  T3DInitParams
 

Macros

#define T3D_VERTEX_CACHE_SIZE   70
 

Enumerations

enum  T3DCmd {
  T3D_CMD_TRI_DRAW = 0x0 , T3D_CMD_SCREEN_SIZE = 0x1 , T3D_CMD_MATRIX_STACK = 0x2 , T3D_CMD_SET_WORD = 0x3 ,
  T3D_CMD_VERT_LOAD = 0x4 , T3D_CMD_LIGHT_SET = 0x5 , T3D_CMD_DRAWFLAGS = 0x6 , T3D_CMD_PROJ_SET = 0x7 ,
  T3D_CMD_FOG_RANGE = 0x8 , T3D_CMD_FOG_STATE = 0x9 , T3D_CMD_TRI_SYNC = 0xA , T3D_CMD_TRI_STRIP = 0xB ,
  T3D_CMD_TRI_SEQ = 0xC
}
 
enum  T3DDrawFlags {
  T3D_FLAG_DEPTH = 1 << 0 , T3D_FLAG_TEXTURED = 1 << 1 , T3D_FLAG_SHADED = 1 << 2 , T3D_FLAG_CULL_FRONT = 1 << 3 ,
  T3D_FLAG_CULL_BACK = 1 << 4 , T3D_FLAG_NO_LIGHT = 1 << 16
}
 
enum  T3DSegment {
  T3D_SEGMENT_1 = 1 , T3D_SEGMENT_2 = 2 , T3D_SEGMENT_3 = 3 , T3D_SEGMENT_4 = 4 ,
  T3D_SEGMENT_5 = 5 , T3D_SEGMENT_6 = 6 , T3D_SEGMENT_SKELETON = 7
}
 
enum  T3DVertexFX {
  T3D_VERTEX_FX_NONE = 0 , T3D_VERTEX_FX_SPHERICAL_UV = 1 , T3D_VERTEX_FX_CELSHADE_COLOR = 2 , T3D_VERTEX_FX_CELSHADE_ALPHA = 3 ,
  T3D_VERTEX_FX_OUTLINE = 4 , T3D_VERTEX_FX_UV_OFFSET = 5
}
 

Functions

void t3d_init (T3DInitParams params)
 Initializes the tiny3d library.
 
void t3d_destroy (void)
 Destroys the tiny3d library.
 
void t3d_frame_start (void)
 Starts a new frame, this will setup some default states.
 
void t3d_screen_clear_color (color_t color)
 Clears the entire screen with a given color.
 
void t3d_screen_clear_depth ()
 Clears the entire depth buffer with a fixed value (0xFFFC)
 
static T3DViewport t3d_viewport_create ()
 
static T3DViewport t3d_viewport_create_buffered (uint16_t count)
 
static void t3d_viewport_destroy (T3DViewport *viewport)
 
void t3d_viewport_attach (T3DViewport *viewport)
 
T3DViewportt3d_viewport_get ()
 
static void t3d_viewport_set_area (T3DViewport *viewport, int32_t x, int32_t y, int32_t width, int32_t height)
 
void t3d_viewport_set_perspective (T3DViewport *viewport, float fov, float aspectRatio, float near, float far)
 
void t3d_viewport_set_projection (T3DViewport *viewport, float fov, float near, float far)
 
void t3d_viewport_set_ortho (T3DViewport *viewport, float left, float right, float bottom, float top, float near, float far)
 
static void t3d_viewport_set_w_normalize (T3DViewport *viewport, float near, float far)
 
void t3d_viewport_look_at (T3DViewport *viewport, const T3DVec3 *eye, const T3DVec3 *target, const T3DVec3 *up)
 
void t3d_viewport_set_view_matrix (T3DViewport *viewport, const T3DMat4 *mat)
 
void t3d_viewport_set_projection_matrix (T3DViewport *viewport, const T3DMat4 *mat)
 
void t3d_viewport_calc_viewspace_pos (T3DViewport *viewport, T3DVec3 *out, const T3DVec3 *pos)
 
void t3d_tri_draw (uint32_t v0, uint32_t v1, uint32_t v2)
 Draws a single triangle, referencing loaded vertices.
 
void t3d_tri_draw_unindexed (uint32_t baseIndex, uint32_t triCount)
 
void t3d_quad_draw_unindexed (uint32_t baseIndex, uint32_t quadCount)
 
void t3d_tri_draw_strip (int16_t *indexBuff, int count)
 
void t3d_tri_draw_strip_and_sync (int16_t *indexBuff, int count)
 
static void t3d_tri_sync ()
 
void t3d_matrix_set (const T3DMat4FP *mat, bool doMultiply)
 
void t3d_matrix_push (const T3DMat4FP *mat)
 
void t3d_matrix_pop (int count)
 
void t3d_matrix_push_pos (int count)
 
void t3d_matrix_set_proj (const T3DMat4FP *mat)
 
void t3d_vert_load (const T3DVertPacked *vertices, uint32_t offset, uint32_t count)
 
void t3d_light_set_ambient (const uint8_t *color)
 
void t3d_light_set_directional (int index, const uint8_t *color, const T3DVec3 *dir)
 
void t3d_light_set_point (int index, const uint8_t *color, const T3DVec3 *pos, float size, bool ignoreNormals)
 
void t3d_light_set_count (int count)
 
void t3d_light_set_exposure (float exposure)
 
void t3d_fog_set_range (float near, float far)
 
static void t3d_fog_set_enabled (bool isEnabled)
 
uint16_t t3d_vert_pack_normal (const T3DVec3 *normal)
 
void t3d_state_set_drawflags (enum T3DDrawFlags drawFlags)
 
void t3d_state_set_depth_offset (int16_t offset)
 
void t3d_state_set_alpha_to_tile (bool enable)
 
void t3d_state_set_vertex_fx (enum T3DVertexFX func, int16_t arg0, int16_t arg1)
 
void t3d_state_set_vertex_fx_scale (uint16_t scale)
 
void t3d_segment_set (uint8_t segmentId, void *address)
 
static void * t3d_segment_placeholder (uint8_t segmentId)
 
static void * t3d_segment_address (uint8_t segmentId, void *ptr)
 
void t3d_indexbuffer_convert (int16_t indices[], int count)
 
static int16_t * t3d_vertbuffer_get_pos (T3DVertPacked vert[], int idx)
 
static int16_t * t3d_vertbuffer_get_uv (T3DVertPacked vert[], int idx)
 
static uint32_t * t3d_vertbuffer_get_color (T3DVertPacked vert[], int idx)
 
static uint8_t * t3d_vertbuffer_get_rgba (T3DVertPacked vert[], int idx)
 
static uint16_t * t3d_vertbuffer_get_norm (T3DVertPacked vert[], int idx)
 

Variables

uint32_t T3D_RSP_ID
 

Detailed Description

Function Documentation

◆ t3d_fog_set_enabled()

static void t3d_fog_set_enabled ( bool isEnabled)
inlinestatic

Enables or disables fog, this can be set independently from the range.

Parameters
isEnabled

◆ t3d_fog_set_range()

void t3d_fog_set_range ( float near,
float far )

Sets the range of the fog. To disable fog, use 't3d_fog_disable' or set 'near' and 'far' to 0. Note: in order for fog itself to work, make sure to setup the needed RSPQ commands.

Parameters
nearstart of the fog effect
farend of the fog effect

◆ t3d_indexbuffer_convert()

void t3d_indexbuffer_convert ( int16_t indices[],
int count )

Converts an index buffer for triangle strips from indices to encoded DMEM pointers. This is necessary in order for 't3d_tri_draw_strip' to work. Internally this data will be DMA'd by the ucode later on.

Format: The input data is expected to be an array of local indices (0-69) as s16 values. The first 3 values define the initial triangle. Every index afterwards will extend the strip by one triangle (winding order flipped). Degenerate triangles are NOT supported, since it is always more efficient to use a restart flag. To start a new strip, set the MSB of the next index, so: 'idx | (1<<15)' meaning the flagged value and the 2 following values will form a new triangle, re-starting the strip. Since restarting does not need a special index value, non-stripped indices (triangle lists) can be encoded too without overhead.

Examples: (original triangles -> expected input of this function) [4,5,6] [0,1,2] [7,8,9] -> [4,5,6,(0x8000|0),1,2,(0x8000|7),8,9] [0,1,2] [3,0,2] [0,3,4] [5,0,4] -> [1,2,0,3,0,4,5]

Parameters
indicesindex buffer of local indices, will be modified in-place
countindex count

◆ t3d_init()

void t3d_init ( T3DInitParams params)

Initializes the tiny3d library.

Parameters
paramssettings to configure the library

◆ t3d_light_set_ambient()

void t3d_light_set_ambient ( const uint8_t * color)

Sets the global ambient light color. This color is always active and applied to all objects. To disable the ambient light, set the color to black.

Parameters
colorcolor in RGBA8 format

◆ t3d_light_set_count()

void t3d_light_set_count ( int count)

Sets the amount of active lights (excl. ambient light). Note that the ambient light does not count towards this limit and is always applied.

Parameters
countamount of lights (0-6)

◆ t3d_light_set_directional()

void t3d_light_set_directional ( int index,
const uint8_t * color,
const T3DVec3 * dir )

Sets a directional light. You can set up to 7 directional lights, the amount can be set with 't3d_light_set_count'. Note that directional and point lights share the same space.

Parameters
indexindex (0-6)
colorcolor in RGBA8 format
dirdirection vector

◆ t3d_light_set_exposure()

void t3d_light_set_exposure ( float exposure)

Sets the final color exposure. This will be applied to the combined light + vertex color as a simple scaling factor. Any value above 1.0 after scaling will be clamped. This setting can be used to implement a simple form of HDR.

Note that negative values are allowed and will invert the color to some extend.

Parameters
exposurefactor, 1.0 by default

◆ t3d_light_set_point()

void t3d_light_set_point ( int index,
const uint8_t * color,
const T3DVec3 * pos,
float size,
bool ignoreNormals )

Sets a point light. You can set up to 7 point lights, the amount can be set with 't3d_light_set_count'. Note that point and directional lights share the same space.

The position is expected to be in world-space, and will be transformed internally. Before calling this function, make sure to have a viewport attached.

The size argument is roughly the maximum radius in world-space the light will cover. Note that due to precision limitations and the fact lighting happens per vertex, the size is not exact.

Parameters
indexindex (0-6)
colorcolor in RGBA8 format
posposition in world-space
sizedistance, in world-space
ignoreNormalsif true, the light will only check the distance, not the angle (useful for cutouts)

◆ t3d_matrix_pop()

void t3d_matrix_pop ( int count)

Pops the current matrix from the stack.

Parameters
counthow many matrices to pop

◆ t3d_matrix_push()

void t3d_matrix_push ( const T3DMat4FP * mat)

Multiplies a matrix with the current stack position, then pushes it onto the stack.

Parameters
mataddress to load matrix from

◆ t3d_matrix_push_pos()

void t3d_matrix_push_pos ( int count)

Moves the stack pos. without changing a matrix or causing re-calculations. This should only be used in preparation for 't3d_matrix_set' calls.

E.g. instead of multiple push/pop combis, use:

  • 't3d_matrix_push_pos(1)' once
  • then multiple 't3d_matrix_set'
  • finish with 't3d_matrix_pop'

This is the most efficient way to set multiple matrices at the same level.

Parameters
countrelative change (matrix count), should usually be 1

◆ t3d_matrix_set()

void t3d_matrix_set ( const T3DMat4FP * mat,
bool doMultiply )

Directly loads a matrix, overwriting the current stack position.

With 'doMultiply' set to false, this lets you completely replace the current matrix. With 'doMultiply' set to true, it serves as a faster version of a pop+push combination.

Parameters
mataddress to load matrix from
doMultiplyif true, the matrix will be multiplied with the previous stack entry

◆ t3d_matrix_set_proj()

void t3d_matrix_set_proj ( const T3DMat4FP * mat)

Sets the projection matrix, this is stored outside of the matrix stack.

Parameters
mataddress to load matrix from

◆ t3d_quad_draw_unindexed()

void t3d_quad_draw_unindexed ( uint32_t baseIndex,
uint32_t quadCount )

Draws multiple quads, assuming sequential indices. For example with baseIndex=4 and quadCount=2, we would get -> 4,5,6 7,6,5, 8,9,10, 11,10,9 This is effectively performing an un-indexed draw of quads, but without the overhead of loading an index-buffer. This method is faster than going through 't3d_tri_draw_strip'.

Parameters
baseIndexfirst index
triCountamount of quads to draw

◆ t3d_segment_address()

static void * t3d_segment_address ( uint8_t segmentId,
void * ptr )
inlinestatic

Converts an address into a segmented one. If used in a vertex/matrix load, it will cause the segment table to be used and the address in there to be added on top. To set entries in the segment table use 't3d_segment_set'.

Parameters
segmentIdid (1-7)
ptrpointer, can be NULL for absolute addressing
Returns
segmented address

◆ t3d_segment_placeholder()

static void * t3d_segment_placeholder ( uint8_t segmentId)
inlinestatic

Creates a dummy address to be used for vertex/matrix loads. This will cause the address in the segment table to be used instead. If you need relative addressing instead, use 't3d_segment_address'

Parameters
segmentIdid (1-7)
Returns
segmented address

◆ t3d_segment_set()

void t3d_segment_set ( uint8_t segmentId,
void * address )

Sets a new address in the segment table. This acts as a base-address for addresses in matrices/vertices with a matching segment index. Segment 0 is reserved and always has a zero value.

Parameters
segmentIdid (1-7)
addressbase RDRAM address

◆ t3d_state_set_alpha_to_tile()

void t3d_state_set_alpha_to_tile ( bool enable)

Enables or disables the alpha-to-tile feature. This will cause the 3 MSBs of the input vertex alpha to be stored as the base tile. Which is later used during triangle draws to define what TEX0 is (by default TILE0). This feature is completely free and adds no extra time.

This can be useful if you can preload a tile-set into TMEM containing multiple textures. By setting up distinct tiles you can still take advantage of repeating UVs. Each triangle can then select its own tile without a costly texture or state switches inbetween.

NOTE: since a triangle can only have one tile, it is expected that all vertices have the same tile set. Otherwise it is considered undefined behavior. Furthermore, When loading vertices it is expected that both vertices in the interleaved struct must contain the same tile value.

Parameters
enabletrue to enable for future vertex loads, false to disable.

◆ t3d_state_set_depth_offset()

void t3d_state_set_depth_offset ( int16_t offset)

Offsets the final screen-space depth by a fixed amount. This can be used as an alternative to decals by drawing normally with an offset instead. E.g.: t3d_state_set_depth_offset(-0x40);

Parameters
offsetrelative offset, negative value to pull depth closer. Pass '0' to reset.

◆ t3d_state_set_drawflags()

void t3d_state_set_drawflags ( enum T3DDrawFlags drawFlags)

Sets various draw flags, this will affect how triangles are drawn.

Parameters
drawFlags

◆ t3d_state_set_vertex_fx()

void t3d_state_set_vertex_fx ( enum T3DVertexFX func,
int16_t arg0,
int16_t arg1 )

Sets a function for vertex effects. To disable it, set the function to 'T3D_VERTEX_FX_NONE'. The arg0/arg1 values are stored ín DMEM and are used by the ucode.

The meaning of those arguments depends on the type:

  • T3D_VERTEX_FX_NONE : (no arguments)
  • T3D_VERTEX_FX_SPHERICAL_UV : texture width/height
  • T3D_VERTEX_FX_CELSHADE_COLOR: (no arguments)
  • T3D_VERTEX_FX_CELSHADE_ALPHA: (no arguments)
  • T3D_VERTEX_FX_OUTLINE : pixel size X/Y
  • T3D_VERTEX_FX_UV_OFFSET : UV offset, same 10.5 format as vertex
Parameters
funcvertex effect function
arg0first argument
arg1second argument

◆ t3d_state_set_vertex_fx_scale()

void t3d_state_set_vertex_fx_scale ( uint16_t scale)

Overrides the scale factor for some vertex effects. This is currently only used by the 'T3D_VERTEX_FX_SPHERICAL_UV' function to create an offset based on screen-space position. This is automatically calculated by the ucode when setting the screen-size. However if you see distortions near the edge of the screen, you can set this manually.

Parameters
scalescale factor

◆ t3d_tri_draw()

void t3d_tri_draw ( uint32_t v0,
uint32_t v1,
uint32_t v2 )

Draws a single triangle, referencing loaded vertices.

Parameters
v0vertex index 0
v1vertex index 1
v2vertex index 2

◆ t3d_tri_draw_strip()

void t3d_tri_draw_strip ( int16_t * indexBuff,
int count )

Draws a strip of triangles by loading an index buffer. Note that this data must be in an internal format, so use 't3d_indexbuffer_convert' to convert it first. The docs of 't3d_indexbuffer_convert' also describe the format of the input data.

The data behind 'indexBuff' will be DMA'd by the ucode, so it must be aligned to 8 bytes, and persist in memory until the triangles are drawn. The target location of the DMA in DMEM is shared with the vertex cache, aligned to the end. Make sure that there is enough space left to load the indices to not corrupt the vertices. E.g. if you loaded 68 vertices, you have 2 slots free or 36*2 bytes, meaning you can load 36 indices. Note that due to alignment reasons, a safety margin of 4 indices should be added if the free vertex count is odd.

The built-in model format will use this function internally, if you plan on manually using it for model data, check out 'tools/gltf_importer/src/optimizer/meshOptimizer.cpp' for an algorithm to do so.

Parameters
indexBuffindex buffer to load
countamount of indices to load

◆ t3d_tri_draw_strip_and_sync()

void t3d_tri_draw_strip_and_sync ( int16_t * indexBuff,
int count )

Combined t3d_tri_draw_strip + t3d_tri_sync. See individual functions for more details.

Parameters
indexBuffindex buffer to load
countamount of indices to load

◆ t3d_tri_draw_unindexed()

void t3d_tri_draw_unindexed ( uint32_t baseIndex,
uint32_t triCount )

Draws multiple triangles, assuming sequential indices. For example with baseIndex=4 and triCount=2, we would get -> 4,5,6 7,8,9 This is effectively performing an un-indexed draw of triangles, but without the overhead of loading an index-buffer. This method is faster than going through 't3d_tri_draw_strip'.

Parameters
baseIndexfirst index
triCountamount of triangles to draw

◆ t3d_tri_sync()

static void t3d_tri_sync ( )
inlinestatic

Syncs pending triangles. This needs to be called after triangles where drawn and a different overlay which also generates RDP commands will be used. (e.g. RDPQ)

◆ t3d_vert_load()

void t3d_vert_load ( const T3DVertPacked * vertices,
uint32_t offset,
uint32_t count )

Loads a vertex buffer with a given size, this can then be used to draw triangles.

Parameters
verticesvertex buffer
offsetoffset in the target buffer (0-68)
counthow many vertices to load (1-70)

◆ t3d_vert_pack_normal()

uint16_t t3d_vert_pack_normal ( const T3DVec3 * normal)

Packs a floating-point normal into the internal 5.6.5 format.

Parameters
normalnormal vector
Returns
packed normal

◆ t3d_vertbuffer_get_color()

static uint32_t * t3d_vertbuffer_get_color ( T3DVertPacked vert[],
int idx )
inlinestatic

Returns the pointer to the color (as a u32) of a vertex in a buffer

Parameters
vertvertex buffer
idxvertex index

◆ t3d_vertbuffer_get_norm()

static uint16_t * t3d_vertbuffer_get_norm ( T3DVertPacked vert[],
int idx )
inlinestatic

Returns the pointer to the packed normal of a vertex in a buffer

Parameters
vertvertex buffer
idxvertex index

◆ t3d_vertbuffer_get_pos()

static int16_t * t3d_vertbuffer_get_pos ( T3DVertPacked vert[],
int idx )
inlinestatic

Returns the pointer to a position of a vertex in a buffer

Parameters
vertvertex buffer
idxvertex index

◆ t3d_vertbuffer_get_rgba()

static uint8_t * t3d_vertbuffer_get_rgba ( T3DVertPacked vert[],
int idx )
inlinestatic

Returns the pointer to the color (as a u8[4]) of a vertex in a buffer

Parameters
vertvertex buffer
idxvertex index

◆ t3d_vertbuffer_get_uv()

static int16_t * t3d_vertbuffer_get_uv ( T3DVertPacked vert[],
int idx )
inlinestatic

Returns the pointer to the UV of a vertex in a buffer

Parameters
vertvertex buffer
idxvertex index

◆ t3d_viewport_attach()

void t3d_viewport_attach ( T3DViewport * viewport)

Uses the given viewport for further rendering and applies its settings. This will set the visible screen-rect, and apply the camera and projection matrix.

Note that you may have to re-apply directional lights if you are using multiple viewports, as they are depend on the view matrix.

Parameters
viewportviewport, pointer must be valid until the next t3d_viewport_attach call

◆ t3d_viewport_calc_viewspace_pos()

void t3d_viewport_calc_viewspace_pos ( T3DViewport * viewport,
T3DVec3 * out,
const T3DVec3 * pos )

Calculates the view-space position of a given world-space position. This will also handle offset viewports (e.g. for splitscreens)

Parameters
viewportviewport to calculate for
outoutput screen-space vector
posinput world-space position

◆ t3d_viewport_create()

static T3DViewport t3d_viewport_create ( )
inlinestatic

Creates a viewport struct, this only creates a struct and doesn't change any setting. Most likely you want to update the camera and projection matrix over time, in which case you should use 't3d_viewport_create_buffered' instead.

Once done, free the viewports internal data via 't3d_viewport_destroy'. (Note that for compatibility reasons, this is not strictly necessary unless buffered)

Returns
struct with the documented default values

◆ t3d_viewport_create_buffered()

static T3DViewport t3d_viewport_create_buffered ( uint16_t count)
inlinestatic

Same as 't3d_viewport_create' but buffered. This will allow you to change matrices over time without running into race-conditions with the RSP.

Once done, free the viewports internal data via 't3d_viewport_destroy'.

Parameters
countamount of buffered matrices (usually amount of framebuffers)
Returns
struct with the documented default values

◆ t3d_viewport_destroy()

static void t3d_viewport_destroy ( T3DViewport * viewport)
inlinestatic

Destroys a viewport and frees allocated internal data.

Note that since you still hold the struct itself, any further use of it is undefined behavior. To create a new viewport overwrite the struct with a new one from 't3d_viewport_create' instead.

Parameters
viewportviewport to destroy

◆ t3d_viewport_get()

T3DViewport * t3d_viewport_get ( )

Returns the currently attached viewport.

Returns
viewport or NULL if none is attached

◆ t3d_viewport_look_at()

void t3d_viewport_look_at ( T3DViewport * viewport,
const T3DVec3 * eye,
const T3DVec3 * target,
const T3DVec3 * up )

Sets a new camera position and direction for the given viewport. The view matrix gets auto. applied at the next t3d_viewport_attach call.

Parameters
eyecamera position
targetcamera target/look-at
upcamera up vector, expected to be {0,1,0} by default

◆ t3d_viewport_set_area()

static void t3d_viewport_set_area ( T3DViewport * viewport,
int32_t x,
int32_t y,
int32_t width,
int32_t height )
inlinestatic

Convenience function to set the area of a viewport.

Parameters
viewport
xposition (0 by default)
y
widthsize (display width by default)
height

◆ t3d_viewport_set_ortho()

void t3d_viewport_set_ortho ( T3DViewport * viewport,
float left,
float right,
float bottom,
float top,
float near,
float far )

Sets an orthographic projection matrix for the given viewport. The matrix gets auto. applied at the next t3d_viewport_attach call.

Parameters
viewport
left
right
bottom
top
nearnear plane distance
farfar plane distance (should be >=40 to avoid depth-precision issues)

◆ t3d_viewport_set_perspective()

void t3d_viewport_set_perspective ( T3DViewport * viewport,
float fov,
float aspectRatio,
float near,
float far )

Updates the projection matrix of the given viewport using a perspective projection. The proj. matrix gets auto. applied at the next t3d_viewport_attach call.

Parameters
viewport
fovfov in radians
aspectRatioaspect ratio (= width / height)
nearnear plane distance
farfar plane distance (should be >=40 to avoid depth-precision issues)

◆ t3d_viewport_set_projection()

void t3d_viewport_set_projection ( T3DViewport * viewport,
float fov,
float near,
float far )

Updates the projection matrix of the given viewport. The proj. matrix gets auto. applied at the next t3d_viewport_attach call.

NOTE: if you need a custom aspect ratio, use 't3d_viewport_set_perspective' instead.

Parameters
viewport
fovfov in radians
nearnear plane distance
farfar plane distance (should be >=40 to avoid depth-precision issues)

◆ t3d_viewport_set_projection_matrix()

void t3d_viewport_set_projection_matrix ( T3DViewport * viewport,
const T3DMat4 * mat )

Sets a new projection matrix for the given viewport. If you have a perspective or orthographic projection prefer using 't3d_viewport_set_projection' or 't3d_viewport_set_ortho'.

Parameters
viewportviewport to set for
matnew projection matrix

◆ t3d_viewport_set_view_matrix()

void t3d_viewport_set_view_matrix ( T3DViewport * viewport,
const T3DMat4 * mat )

Sets a new view (aka camera) matrix for the given viewport. If you have a look-at based camera prefer using 't3d_viewport_look_at'.

Parameters
viewportviewport to set for
matnew view matrix

◆ t3d_viewport_set_w_normalize()

static void t3d_viewport_set_w_normalize ( T3DViewport * viewport,
float near,
float far )
inlinestatic

Sets the normalization factor for W in the ucode. NOTE: this gets called automatically by t3d_viewport_set_projection. You only need to call this if you want to provide your own projection matrix.

Parameters
viewport
near
far