Tramway SDK
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
tram::Render Namespace Reference

Namespaces

namespace  AABB
 
namespace  API
 
namespace  LightTree
 

Classes

struct  AABBTriangle
 
class  Animation
 
struct  Bone
 
struct  BucketMapping
 
struct  drawlistentry_t
 
struct  DynamicModelData
 
struct  DynamicModelVertex
 
struct  indexarray_t
 
struct  IndexRange
 
struct  Keyframe
 
struct  light_t
 
struct  LineVertex
 
class  Material
 
class  Model
 
struct  ModelAABB
 
struct  ModelData
 
struct  Pose
 
struct  RegisteredVertexDefinition
 
class  Sprite
 
struct  SpriteFrame
 
struct  SpriteVertex
 
struct  StaticModelData
 
struct  StaticModelVertex
 
struct  texturehandle_t
 
struct  Triangle
 
struct  TriangleBucket
 
struct  vertexarray_t
 
struct  VertexAttribute
 Atributes for vertex buffer vertices. More...
 
struct  VertexDefinition
 

Typedefs

typedef void * aabbleaf_t
 
typedef std::pair< name_t, uint64_t > NameCount
 
typedef vec3 color_t
 
typedef uint32_t layer_t
 
typedef uint32_t vertexformat_t
 
typedef uint32_t materialtype_t
 

Enumerations

enum  MaterialProperty {
  PROPERTY_METAL , PROPERTY_METAL_THIN , PROPERTY_SLIME , PROPERTY_TILE ,
  PROPERTY_GRATE , PROPERTY_WOOD , PROPERTY_COMPUTER , PROPERTY_GLASS ,
  PROPERTY_SNOW , PROPERTY_GRASS , PROPERTY_CONCRETE , PROPERTY_FLESH
}
 
enum  TextureType { TEXTURE_NONE , TEXTURE_SAME , TEXTURE_SOURCE }
 
enum  VertexFormats : vertexformat_t {
  VERTEX_STATIC , VERTEX_DYNAMIC , VERTEX_SPRITE , VERTEX_LINE ,
  VERTEX_LAST
}
 
enum  MaterialTypes : materialtype_t {
  MATERIAL_TEXTURE , MATERIAL_TEXTURE_ALPHA , MATERIAL_LIGHTMAP , MATERIAL_MSDF ,
  MATERIAL_GLYPH , MATERIAL_WATER , MATERIAL_FLAT_COLOR , MATERIAL_LAST
}
 
enum  MaterialFilter { FILTER_NEAREST , FILTER_LINEAR }
 
enum  renderflags : uint32_t {
  FLAG_NO_RENDER = 0 , FLAG_RENDER = 1 , FLAG_DRAW_INDEXED = 4 , FLAG_REVERSE_SORT = 8 ,
  FLAG_TRANSPARENT = 16 , FLAG_NO_DEPTH_TEST = 32 , FLAG_NO_DIRECTIONAL = 64 , FLAG_DRAW_LINES = 128 ,
  FLAG_DISABLE_LIGHTING = 256
}
 Flags for DrawListObjects. More...
 
enum  ColorMode { COLORMODE_R , COLORMODE_RG , COLORMODE_RGB , COLORMODE_RGBA }
 Texture color mode. More...
 
enum  TextureFilter { TEXTUREFILTER_NEAREST , TEXTUREFILTER_LINEAR , TEXTUREFILTER_LINEAR_MIPMAPPED }
 Texture filters. More...
 

Functions

Hashmap< Animation * > animation_list ("model name list", 500)
 
uint8_t * MakeNewErrorTexture (vec3 color1, vec3 color2)
 Generates a new error texture. More...
 
StaticModelDataMakeNewErrorModel ()
 Generates a new error model. More...
 
void Init ()
 Initializes the rendering system. More...
 
void Render ()
 Renders a single frame. More...
 
void SetSunDirection (color_t direction, layer_t layer)
 Sets the sun direction. More...
 
void SetSunColor (color_t color, layer_t layer)
 Sets the sun color. More...
 
void SetAmbientColor (color_t color, layer_t layer)
 Sets the ambient color. More...
 
void SetScreenSize (float width, float height)
 
void SetViewFov (float fov, layer_t layer)
 
float GetViewFov (layer_t layer)
 
void SetOrthoRatio (float ratio, layer_t layer)
 
void SetViewDistance (float dist, layer_t layer)
 
float GetViewDistance (layer_t layer)
 
void SetViewPosition (vec3 position, layer_t layer)
 Sets the view position. More...
 
void SetViewRotation (quat rotation, layer_t layer)
 Sets the view rotation. More...
 
vec3 GetViewPosition (layer_t layer)
 Returns the view position for a given layer. More...
 
quat GetViewRotation (layer_t layer)
 Returns the view rotation for a given layer. More...
 
void AddLine (vec3 from, vec3 to, vec3 color)
 
void AddLineMarker (vec3 location, vec3 color)
 
void AddLineAABB (vec3 min, vec3 max, vec3 center, quat rotation, vec3 color)
 
void AddSphere (vec3 pos, float radius, color_t color)
 
void AddCylinder (vec3 pos, float height, float radius, color_t color)
 
void AddCube (vec3 pos, float height, float radius, color_t color)
 
void Project (const vec3 &point, vec3 &result, layer_t layer)
 
vec3 ProjectInverse (vec3 point, layer_t layer)
 
vertexformat_t RegisterVertexFormat (const char *name)
 
materialtype_t RegisterMaterialType (const char *name)
 
vertexformat_t FindVertexFormat (const char *name)
 
materialtype_t FindMaterialType (const char *name)
 
const char * GetVertexFormatName (vertexformat_t type)
 
const char * GetMaterialTypeName (materialtype_t type)
 
const color_t COLOR_WHITE (1.0f, 1.0f, 1.0f)
 
const color_t COLOR_RED (1.0f, 0.0f, 0.0f)
 
const color_t COLOR_GREEN (0.0f, 1.0f, 0.0f)
 
const color_t COLOR_BLUE (0.0f, 0.0f, 1.0f)
 
const color_t COLOR_YELLOW (1.0f, 1.0f, 0.0f)
 
const color_t COLOR_PINK (1.0f, 0.0f, 1.0f)
 
const color_t COLOR_CYAN (0.0f, 1.0f, 1.0f)
 
const color_t COLOR_BLACK (0.0f, 0.0f, 0.0f)
 
const color_t COLOR_GRAY (0.3f, 0.3f, 0.3f)
 
void RegisterVertexDefinition (vertexformat_t format, VertexDefinition definition)
 Registers a VertexDefinition for a specified vertex format. More...
 
VertexDefinition GetVertexDefinition (vertexformat_t format)
 Returns a previously registered VertexDefinition. More...
 

Variables

StackPool< uint8_t > animation_pool ("animation keyframe pool", 1024 *1024)
 
const size_t BONE_COUNT = 30
 
struct {
   vec3   tram::Render::view_position = {0.0f, 0.0f, 0.0f}
 
   quat   tram::Render::view_rotation = {1.0f, 0.0f, 0.0f, 0.0f}
 
   float   tram::Render::view_fov = 60.0f
 
   float   tram::Render::near_plane = 0.01f
 
   float   tram::Render::far_plane = 250.0f
 
   float   tram::Render::ortho_ratio = 1.0f
 
   vec3   tram::Render::sun_direction = {0.0f, 1.0f, 0.0f}
 
   vec3   tram::Render::sun_color = {1.0f, 1.0f, 1.0f}
 
   vec3   tram::Render::ambient_color = {0.0f, 0.0f, 0.0f}
 
   mat4   tram::Render::projection = mat4(1.0f)
 
   mat4   tram::Render::view = mat4(1.0f)
 
view_properties [7]
 
bool THIRD_PERSON = false
 
bool DRAW_RENDER_DEBUG = false
 
vertexarray_t colorlines_vertex_array = {.generic = 0}
 
drawlistentry_t colorlines_entry
 
std::vector< LineVertexcolorlines
 

Typedef Documentation

◆ aabbleaf_t

typedef void* tram::Render::aabbleaf_t

◆ color_t

◆ layer_t

typedef uint32_t tram::Render::layer_t

◆ materialtype_t

typedef uint32_t tram::Render::materialtype_t

◆ NameCount

typedef std::pair<name_t, uint64_t> tram::Render::NameCount

◆ vertexformat_t

typedef uint32_t tram::Render::vertexformat_t

Enumeration Type Documentation

◆ ColorMode

Texture color mode.

Enumerator
COLORMODE_R 
COLORMODE_RG 
COLORMODE_RGB 
COLORMODE_RGBA 

◆ MaterialFilter

Enumerator
FILTER_NEAREST 
FILTER_LINEAR 

◆ MaterialProperty

Enumerator
PROPERTY_METAL 
PROPERTY_METAL_THIN 
PROPERTY_SLIME 
PROPERTY_TILE 
PROPERTY_GRATE 
PROPERTY_WOOD 
PROPERTY_COMPUTER 
PROPERTY_GLASS 
PROPERTY_SNOW 
PROPERTY_GRASS 
PROPERTY_CONCRETE 
PROPERTY_FLESH 

◆ MaterialTypes

Enumerator
MATERIAL_TEXTURE 
MATERIAL_TEXTURE_ALPHA 
MATERIAL_LIGHTMAP 
MATERIAL_MSDF 
MATERIAL_GLYPH 
MATERIAL_WATER 
MATERIAL_FLAT_COLOR 
MATERIAL_LAST 

◆ renderflags

enum tram::Render::renderflags : uint32_t

Flags for DrawListObjects.

Enumerator
FLAG_NO_RENDER 
FLAG_RENDER 
FLAG_DRAW_INDEXED 
FLAG_REVERSE_SORT 
FLAG_TRANSPARENT 
FLAG_NO_DEPTH_TEST 
FLAG_NO_DIRECTIONAL 
FLAG_DRAW_LINES 
FLAG_DISABLE_LIGHTING 

◆ TextureFilter

Texture filters.

Enumerator
TEXTUREFILTER_NEAREST 
TEXTUREFILTER_LINEAR 
TEXTUREFILTER_LINEAR_MIPMAPPED 

◆ TextureType

Enumerator
TEXTURE_NONE 
TEXTURE_SAME 
TEXTURE_SOURCE 

◆ VertexFormats

Enumerator
VERTEX_STATIC 
VERTEX_DYNAMIC 
VERTEX_SPRITE 
VERTEX_LINE 
VERTEX_LAST 

Function Documentation

◆ AddCube()

void tram::Render::AddCube ( vec3  pos,
float  height,
float  radius,
color_t  color 
)

◆ AddCylinder()

void tram::Render::AddCylinder ( vec3  pos,
float  height,
float  radius,
color_t  color 
)

◆ AddLine()

void tram::Render::AddLine ( vec3  from,
vec3  to,
vec3  color 
)

◆ AddLineAABB()

void tram::Render::AddLineAABB ( vec3  min,
vec3  max,
vec3  center,
quat  rotation,
vec3  color 
)

◆ AddLineMarker()

void tram::Render::AddLineMarker ( vec3  location,
vec3  color 
)

◆ AddSphere()

void tram::Render::AddSphere ( vec3  pos,
float  radius,
color_t  color 
)

◆ animation_list()

Hashmap< Animation * > tram::Render::animation_list ( "model name list"  ,
500   
)

◆ COLOR_BLACK()

const color_t tram::Render::COLOR_BLACK ( 0.  0f,
0.  0f,
0.  0f 
)

◆ COLOR_BLUE()

const color_t tram::Render::COLOR_BLUE ( 0.  0f,
0.  0f,
1.  0f 
)

◆ COLOR_CYAN()

const color_t tram::Render::COLOR_CYAN ( 0.  0f,
1.  0f,
1.  0f 
)

◆ COLOR_GRAY()

const color_t tram::Render::COLOR_GRAY ( 0.  3f,
0.  3f,
0.  3f 
)

◆ COLOR_GREEN()

const color_t tram::Render::COLOR_GREEN ( 0.  0f,
1.  0f,
0.  0f 
)

◆ COLOR_PINK()

const color_t tram::Render::COLOR_PINK ( 1.  0f,
0.  0f,
1.  0f 
)

◆ COLOR_RED()

const color_t tram::Render::COLOR_RED ( 1.  0f,
0.  0f,
0.  0f 
)

◆ COLOR_WHITE()

const color_t tram::Render::COLOR_WHITE ( 1.  0f,
1.  0f,
1.  0f 
)

◆ COLOR_YELLOW()

const color_t tram::Render::COLOR_YELLOW ( 1.  0f,
1.  0f,
0.  0f 
)

◆ FindMaterialType()

materialtype_t tram::Render::FindMaterialType ( const char *  name)

◆ FindVertexFormat()

vertexformat_t tram::Render::FindVertexFormat ( const char *  name)

◆ GetMaterialTypeName()

const char * tram::Render::GetMaterialTypeName ( materialtype_t  type)

◆ GetVertexDefinition()

VertexDefinition tram::Render::GetVertexDefinition ( vertexformat_t  format)

Returns a previously registered VertexDefinition.

◆ GetVertexFormatName()

const char * tram::Render::GetVertexFormatName ( vertexformat_t  type)

◆ GetViewDistance()

float tram::Render::GetViewDistance ( layer_t  layer)

◆ GetViewFov()

float tram::Render::GetViewFov ( layer_t  layer)

◆ GetViewPosition()

vec3 tram::Render::GetViewPosition ( layer_t  layer)

Returns the view position for a given layer.

◆ GetViewRotation()

quat tram::Render::GetViewRotation ( layer_t  layer)

Returns the view rotation for a given layer.

◆ Init()

void tram::Render::Init ( )

Initializes the rendering system.

Note
Core and UI systems need to be initialized before initializing the render system.

◆ MakeNewErrorModel()

StaticModelData * tram::Render::MakeNewErrorModel ( )

Generates a new error model.

◆ MakeNewErrorTexture()

uint8_t * tram::Render::MakeNewErrorTexture ( vec3  color1,
vec3  color2 
)

Generates a new error texture.

Returns
Buffer to a 3 channel, 64x64 texture.

◆ Project()

void tram::Render::Project ( const vec3 point,
vec3 result,
layer_t  layer 
)

◆ ProjectInverse()

vec3 tram::Render::ProjectInverse ( vec3  point,
layer_t  layer 
)

◆ RegisterMaterialType()

materialtype_t tram::Render::RegisterMaterialType ( const char *  name)

◆ RegisterVertexDefinition()

void tram::Render::RegisterVertexDefinition ( vertexformat_t  format,
VertexDefinition  definition 
)

Registers a VertexDefinition for a specified vertex format.

Note
For the VertexDefinition's 'attributes' only the pointer will be copied, the underlying memory will not be copied – make sure that it doesn't point to stack memory, or other memory that could be overwritten.

◆ RegisterVertexFormat()

vertexformat_t tram::Render::RegisterVertexFormat ( const char *  name)

◆ Render()

void tram::Render::Render ( )

Renders a single frame.

◆ SetAmbientColor()

void tram::Render::SetAmbientColor ( color_t  color,
layer_t  layer 
)

Sets the ambient color.

Parameters
colorAmbient color.
layerRendering layer to which the ambient color will be applied.

◆ SetOrthoRatio()

void tram::Render::SetOrthoRatio ( float  ratio,
layer_t  layer 
)

◆ SetScreenSize()

void tram::Render::SetScreenSize ( float  width,
float  height 
)

◆ SetSunColor()

void tram::Render::SetSunColor ( color_t  color,
layer_t  layer 
)

Sets the sun color.

Parameters
colorColor of the sun.
layerRendering layer to which the sun color will be applied.

◆ SetSunDirection()

void tram::Render::SetSunDirection ( color_t  direction,
layer_t  layer 
)

Sets the sun direction.

Parameters
directionNormal vector pointing towards the sun.
layerRendering layer to which the sun direction will be applied.

◆ SetViewDistance()

void tram::Render::SetViewDistance ( float  dist,
layer_t  layer 
)

◆ SetViewFov()

void tram::Render::SetViewFov ( float  fov,
layer_t  layer 
)

◆ SetViewPosition()

void tram::Render::SetViewPosition ( vec3  position,
layer_t  layer 
)

Sets the view position.

Parameters
positionView position.
layerRendering layer to which the view position will be applied.

◆ SetViewRotation()

void tram::Render::SetViewRotation ( quat  rotation,
layer_t  layer 
)

Sets the view rotation.

Parameters
rotationView rotation.
layerRendering layer to which the view rotation will be applied.

Variable Documentation

◆ ambient_color

vec3 tram::Render::ambient_color = {0.0f, 0.0f, 0.0f}

◆ animation_pool

StackPool< uint8_t > tram::Render::animation_pool("animation keyframe pool", 1024 *1024) ( "animation keyframe pool"  ,
1024 *  1024 
)

◆ BONE_COUNT

const size_t tram::Render::BONE_COUNT = 30

◆ colorlines

std::vector<LineVertex> tram::Render::colorlines

◆ colorlines_entry

drawlistentry_t tram::Render::colorlines_entry

◆ colorlines_vertex_array

vertexarray_t tram::Render::colorlines_vertex_array = {.generic = 0}

◆ DRAW_RENDER_DEBUG

bool tram::Render::DRAW_RENDER_DEBUG = false

◆ far_plane

float tram::Render::far_plane = 250.0f

◆ near_plane

float tram::Render::near_plane = 0.01f

◆ ortho_ratio

float tram::Render::ortho_ratio = 1.0f

◆ projection

mat4 tram::Render::projection = mat4(1.0f)

◆ sun_color

vec3 tram::Render::sun_color = {1.0f, 1.0f, 1.0f}

◆ sun_direction

vec3 tram::Render::sun_direction = {0.0f, 1.0f, 0.0f}

◆ THIRD_PERSON

bool tram::Render::THIRD_PERSON = false

◆ view

mat4 tram::Render::view = mat4(1.0f)

◆ view_fov

float tram::Render::view_fov = 60.0f

◆ view_position

vec3 tram::Render::view_position = {0.0f, 0.0f, 0.0f}

◆ 

struct { ... } tram::Render::view_properties[7]

◆ view_rotation

quat tram::Render::view_rotation = {1.0f, 0.0f, 0.0f, 0.0f}