Tramway SDK v0.1.1
api.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_RENDER_API_H
4#define TRAM_SDK_RENDER_API_H
5
6#include <render/render.h>
7#include <render/renderer.h>
8
15namespace tram::Render::API {
16
17// meta functions
18void Init();
19void RenderFrame();
20
21void SetScreenSize(float width, float height);
22void SetScreenClear(vec3 clear_color, bool clear);
23
25
26void SetViewMatrix(const mat4& matrix, layer_t layer);
27void SetProjectionMatrix(const mat4& matrix, layer_t layer);
28
29void GetScreen(char* buffer, int w, int h);
30
31void RegisterShader(vertexformat_t format, materialtype_t type, const char* vertex_shader, const char* fragment_shader);
32
33// drawlist functions
34drawlistentry_t InsertDrawListEntry();
35void RemoveDrawListEntry(drawlistentry_t entry);
36
37uint32_t GetFlags(drawlistentry_t entry);
38void SetFlags(drawlistentry_t entry, uint32_t flags);
39void SetLayer(drawlistentry_t entry, layer_t layer);
40void SetPose(drawlistentry_t entry, Pose* pose);
41void SetLightmap(drawlistentry_t entry, texturehandle_t lightmap);
42void SetEnvironmentMap(drawlistentry_t entry, texturehandle_t environmentmap);
43void SetSphericalHarmonic(drawlistentry_t entry, sphericalharmonic_t harmonic);
44void SetLights(drawlistentry_t entry, light_t* lights);
45void SetMatrix(drawlistentry_t entry, const mat4& matrix);
46void SetFadeDistance(drawlistentry_t entry, float near, float far);
47
48void SetDrawListVertexArray(drawlistentry_t entry, vertexarray_t vertex_array_handle);
49void SetDrawListIndexArray(drawlistentry_t entry, indexarray_t index_array_handle);
50void SetDrawListIndexRange(drawlistentry_t entry, uint32_t index_offset, uint32_t index_length);
51void SetDrawListSpriteArray(drawlistentry_t entry, spritearray_t sprite_array_handle);
52
53bool SetDrawListShader(drawlistentry_t entry, vertexformat_t vertex_format, materialtype_t material_type);
54
55void SetDrawListMaterials(drawlistentry_t entry, size_t material_count, material_t* materials);
56
57void SetDrawListColors(drawlistentry_t entry, size_t count, vec4* color);
58
59void SetDrawListTextureOffsets(drawlistentry_t entry, size_t count, vec4* offset);
60void SetDrawListAABB(drawlistentry_t entry, vec3 min, vec3 max);
61
62// vertex buffer functions
63void CreateIndexedVertexArray(VertexDefinition vertex_format, vertexarray_t& vertex_array, indexarray_t& index_array, size_t vertex_size, void* vertex_data, size_t index_size, void* index_data);
64void CreateVertexArray(VertexDefinition vertex_format, vertexarray_t& vertex_array);
65void UpdateVertexArray(vertexarray_t& vertex_buffer, size_t data_size, void* data);
66// TODO: add deletion functions
67
68// texture functions
69texturehandle_t CreateTexture(ColorMode color_mode, TextureFilter texture_filter, uint32_t width, uint32_t height, void* data);
70// TODO: add deletion function
71// TODO: add update functions (filter?)
72
73// sprite functions
74spritearray_t CreateSpriteArray();
75void UpdateSpriteArray(spritearray_t array, size_t data_size, void* data);
76
77
78// light functions
79light_t MakeLight();
80void DeleteLight(light_t light);
81void SetLightParameters(light_t light, vec3 location, vec3 color, float distance, vec3 direction, float exponent);
82// TODO: decompose big function?
83
84// material functions
85material_t MakeMaterial();
86void DeleteMaterial(material_t material);
87void SetMaterialTexture(material_t material, texturehandle_t texture);
88void SetMaterialColor(material_t material, vec4 color);
89void SetMaterialSpecularWeight(material_t material, float weight);
90void SetMaterialSpecularExponent(material_t material, float exponent);
91void SetMaterialSpecularTransparency(material_t material, float transparency);
92void SetMaterialReflectivity(material_t material, float reflectivity);
93
101
103uint32_t GetMaxIndexRangeLength();
104void SetDevice(void*);
105
106bool IsDebugMode();
107void SetDebugMode(bool);
108
109}
110
111#endif // TRAM_SDK_RENDER_API_H
Rendering backend API.
uint32_t GetFlags(drawlistentry_t entry)
Definition: renderer.cpp:242
void SetDrawListMaterials(drawlistentry_t entry, size_t material_count, material_t *materials)
Definition: drawlist.cpp:112
void SetMaterialSpecularTransparency(material_t material, float transparency)
Definition: material.cpp:37
void RenderFrame()
Definition: renderer.cpp:62
void SetFlags(drawlistentry_t entry, uint32_t flags)
Definition: renderer.cpp:246
void SetSphericalHarmonic(drawlistentry_t entry, sphericalharmonic_t harmonic)
Definition: drawlist.cpp:48
ContextType GetContext()
Definition: renderer.cpp:803
uint32_t GetMaxIndexRangeLength()
Definition: renderer.cpp:807
drawlistentry_t InsertDrawListEntry()
Definition: renderer.cpp:234
void UpdateVertexArray(vertexarray_t &vertex_buffer, size_t data_size, void *data)
Definition: renderer.cpp:690
void SetViewMatrix(const mat4 &matrix, layer_t layer)
Definition: renderer.cpp:732
void DeleteMaterial(material_t material)
Definition: material.cpp:17
void SetMaterialSpecularWeight(material_t material, float weight)
Definition: material.cpp:29
void UpdateSpriteArray(spritearray_t array, size_t data_size, void *data)
Definition: sprite.cpp:15
void Init()
Definition: renderer.cpp:768
bool SetDrawListShader(drawlistentry_t entry, vertexformat_t vertex_format, materialtype_t material_type)
Definition: renderer.cpp:302
void SetLightmap(drawlistentry_t entry, texturehandle_t lightmap)
Definition: renderer.cpp:258
void SetDrawListIndexArray(drawlistentry_t entry, indexarray_t index_array_handle)
Definition: renderer.cpp:293
void SetScreenSize(float width, float height)
Definition: renderer.cpp:50
void SetScreenClear(vec3 clear_color, bool clear)
Definition: renderer.cpp:54
void SetDrawListVertexArray(drawlistentry_t entry, vertexarray_t vertex_array_handle)
Definition: renderer.cpp:286
void RemoveDrawListEntry(drawlistentry_t entry)
Definition: renderer.cpp:238
ContextType
Definition: api.h:94
@ CONTEXT_WEBGL
Definition: api.h:96
@ CONTEXT_NONE
Definition: api.h:99
@ CONTEXT_DIRECT3D
Definition: api.h:97
@ CONTEXT_OPENGL
Definition: api.h:95
@ CONTEXT_SOFTWARE
Definition: api.h:98
void SetEnvironmentMap(drawlistentry_t entry, texturehandle_t environmentmap)
Definition: drawlist.cpp:44
void SetMaterialColor(material_t material, vec4 color)
Definition: material.cpp:25
void SetPose(drawlistentry_t entry, Pose *pose)
Definition: renderer.cpp:254
void RegisterShader(vertexformat_t format, materialtype_t type, const char *vertex_shader, const char *fragment_shader)
Definition: shader.cpp:343
void SetFadeDistance(drawlistentry_t entry, float near, float far)
Definition: drawlist.cpp:80
void SetDrawListAABB(drawlistentry_t entry, vec3 min, vec3 max)
Definition: drawlist.cpp:52
void SetMaterialSpecularExponent(material_t material, float exponent)
Definition: material.cpp:33
texturehandle_t CreateTexture(ColorMode color_mode, TextureFilter texture_filter, uint32_t width, uint32_t height, void *data)
Definition: renderer.cpp:346
void GetScreen(char *buffer, int w, int h)
Definition: renderer.cpp:744
void CreateVertexArray(VertexDefinition vertex_format, vertexarray_t &vertex_array)
Definition: renderer.cpp:655
void SetMaterialReflectivity(material_t material, float reflectivity)
Definition: material.cpp:41
void SetDebugMode(bool)
Definition: renderer.cpp:521
void SetLightParameters(light_t light, vec3 location, vec3 color, float distance, vec3 direction, float exponent)
Definition: renderer.cpp:329
light_t MakeLight()
Definition: renderer.cpp:310
void SetProjectionMatrix(const mat4 &matrix, layer_t layer)
Definition: renderer.cpp:737
void SetMaterialTexture(material_t material, texturehandle_t texture)
Definition: material.cpp:21
void SetDrawListSpriteArray(drawlistentry_t entry, spritearray_t sprite_array_handle)
Definition: drawlist.cpp:93
bool IsDebugMode()
Definition: renderer.cpp:517
void SetLightingParameters(vec3 sun_direction, vec3 sun_color, vec3 ambient_color, layer_t layer)
Definition: renderer.cpp:44
void SetDrawListTextureOffsets(drawlistentry_t entry, size_t count, vec4 *offset)
Definition: drawlist.cpp:63
void SetDrawListColors(drawlistentry_t entry, size_t count, vec4 *color)
Definition: renderer.cpp:262
void SetDrawListIndexRange(drawlistentry_t entry, uint32_t index_offset, uint32_t index_length)
Definition: renderer.cpp:297
void SetLights(drawlistentry_t entry, light_t *lights)
Definition: renderer.cpp:272
void DeleteLight(light_t light)
Definition: renderer.cpp:320
void SetMatrix(drawlistentry_t entry, const mat4 &matrix)
Definition: renderer.cpp:278
void CreateIndexedVertexArray(VertexDefinition vertex_format, vertexarray_t &vertex_array, indexarray_t &index_array, size_t vertex_size, void *vertex_data, size_t index_size, void *index_data)
Definition: renderer.cpp:608
void SetDevice(void *)
Definition: renderer.cpp:811
spritearray_t CreateSpriteArray()
Definition: sprite.cpp:8
void SetLayer(drawlistentry_t entry, layer_t layer)
Definition: renderer.cpp:250
material_t MakeMaterial()
Definition: material.cpp:13
vec3 ambient_color
Definition: render.cpp:40
uint32_t vertexformat_t
Definition: render.h:19
vec3 sun_color
Definition: render.cpp:39
uint32_t layer_t
Definition: render.h:17
uint32_t materialtype_t
Definition: render.h:20
ColorMode
Texture color mode.
Definition: renderer.h:27
TextureFilter
Texture filters.
Definition: renderer.h:35
vec3 sun_direction
Definition: render.cpp:38
SphericalHarmonic sphericalharmonic_t
Definition: render.h:96
char buffer[500]
Definition: logging.cpp:60
glm::vec4 vec4
Definition: math.h:15
glm::vec3 vec3
Definition: math.h:11
glm::mat4 mat4
Definition: math.h:14