Tramway SDK
render.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_RENDER_H
5#define TRAM_SDK_RENDER_H
6
7#include <vector>
8
9#include <render/animation.h>
10
11struct IDirect3DVertexBuffer9;
12struct IDirect3DIndexBuffer9;
13struct IDirect3DTexture9;
14
15namespace tram::Render {
16
17typedef vec3 color_t;
18typedef uint32_t layer_t;
19
20typedef uint32_t vertexformat_t;
21typedef uint32_t materialtype_t;
22
23void Init();
24void Render();
25
26void Project(const vec3& point, vec3& result, layer_t layer = 0);
27vec3 ProjectInverse(vec3 point, layer_t layer = 0);
28
29void SetSunDirection(vec3 direction, layer_t layer = 0);
30void SetSunColor(color_t color, layer_t layer = 0);
31void SetAmbientColor(color_t color, layer_t layer = 0);
32
33void SetScreenSize(float width, float height);
34
35void SetOrthoRatio(float ratio, layer_t layer = 0);
36
37void SetViewFov(float fov, layer_t layer = 0);
38float GetViewFov(layer_t layer = 0);
39
40void SetViewDistance(float dist, layer_t layer = 0);
41float GetViewDistance(layer_t layer = 0);
42
43void SetViewPosition(vec3 position, layer_t layer = 0);
44void SetViewRotation(quat rotation, layer_t layer = 0);
45
48
49void AddLine(vec3 from, vec3 to, color_t color);
50void AddLineMarker(vec3 location, color_t color);
51void AddLineAABB(vec3 min, vec3 max, vec3 center, quat rotation, vec3 color);
52void AddSphere(vec3 pos, float radius, color_t color);
53void AddCylinder(vec3 pos, float height, float radius, color_t color);
54void AddCube(vec3 pos, float height, float radius, color_t color);
55
56const color_t COLOR_WHITE (1.0f, 1.0f, 1.0f);
57const color_t COLOR_RED (1.0f, 0.0f, 0.0f);
58const color_t COLOR_GREEN (0.0f, 1.0f, 0.0f);
59const color_t COLOR_BLUE (0.0f, 0.0f, 1.0f);
60const color_t COLOR_YELLOW (1.0f, 1.0f, 0.0f);
61const color_t COLOR_PINK (1.0f, 0.0f, 1.0f);
62const color_t COLOR_CYAN (0.0f, 1.0f, 1.0f);
63const color_t COLOR_BLACK (0.0f, 0.0f, 0.0f);
64const color_t COLOR_GRAY (0.3f, 0.3f, 0.3f);
65
72};
73
83};
84
88};
89
90vertexformat_t RegisterVertexFormat(const char* name);
91materialtype_t RegisterMaterialType(const char* name);
92
93vertexformat_t FindVertexFormat(const char* name);
94materialtype_t FindMaterialType(const char* name);
95
96const char* GetVertexFormatName(vertexformat_t type);
97const char* GetMaterialTypeName(materialtype_t type);
98
99namespace API { struct SWVertexArray; }
100
102 union {
103 struct {
106 };
107 struct {
108 IDirect3DVertexBuffer9* d3d_vertex_buffer;
109 uint32_t d3d_metadata;
110 };
112 void* generic;
113 };
114};
115
116namespace API { struct SWIndexArray; }
117
119 union {
121 IDirect3DIndexBuffer9* d3d_index_buffer;
123 void* generic;
124 };
125};
126
127namespace API { struct GLDrawListEntry; }
128namespace API { struct D3DDrawListEntry; }
129namespace API { struct SWDrawListEntry; }
130
132 union {
136 void* generic;
137 };
138};
139
140namespace API { struct SWTexture; }
141
143 union {
145 IDirect3DTexture9* d3d_texture_handle;
147 void* generic;
148 };
149};
150
151namespace API { struct GLLight; }
152namespace API { struct D3DLight; }
153namespace API { struct SWLight; }
154
155struct light_t {
156 union {
160 void* generic;
161 };
162};
163
164}
165
166#endif // TRAM_SDK_RENDER_H
Definition: gui.h:9
const char * GetMaterialTypeName(materialtype_t type)
Definition: render.cpp:370
float GetViewDistance(layer_t layer)
Definition: render.cpp:196
const color_t COLOR_BLACK(0.0f, 0.0f, 0.0f)
void SetViewFov(float fov, layer_t layer)
Definition: render.cpp:178
MaterialTypes
Definition: render.h:74
@ MATERIAL_LIGHTMAP
Definition: render.h:77
@ MATERIAL_TEXTURE_ALPHA
Definition: render.h:76
@ MATERIAL_LAST
Definition: render.h:82
@ MATERIAL_GLYPH
Definition: render.h:79
@ MATERIAL_FLAT_COLOR
Definition: render.h:81
@ MATERIAL_WATER
Definition: render.h:80
@ MATERIAL_MSDF
Definition: render.h:78
@ MATERIAL_TEXTURE
Definition: render.h:75
vec3 color_t
Definition: render.h:17
vertexformat_t FindVertexFormat(const char *name)
Definition: render.cpp:348
const color_t COLOR_GRAY(0.3f, 0.3f, 0.3f)
const color_t COLOR_RED(1.0f, 0.0f, 0.0f)
void Init()
Initializes the rendering system.
Definition: render.cpp:94
const color_t COLOR_GREEN(0.0f, 1.0f, 0.0f)
uint32_t vertexformat_t
Definition: render.h:20
vertexformat_t RegisterVertexFormat(const char *name)
Definition: render.cpp:332
void AddCylinder(vec3 pos, float height, float radius, color_t color)
Definition: render.cpp:287
const color_t COLOR_YELLOW(1.0f, 1.0f, 0.0f)
void SetSunDirection(color_t direction, layer_t layer)
Sets the sun direction.
Definition: render.cpp:146
VertexFormats
Definition: render.h:66
@ VERTEX_SPRITE
Definition: render.h:69
@ VERTEX_DYNAMIC
Definition: render.h:68
@ VERTEX_STATIC
Definition: render.h:67
@ VERTEX_LAST
Definition: render.h:71
@ VERTEX_LINE
Definition: render.h:70
void Render()
Renders a single frame.
Definition: render.cpp:126
quat GetViewRotation(layer_t layer)
Returns the view rotation for a given layer.
Definition: render.cpp:224
void Project(const vec3 &point, vec3 &result, layer_t layer)
Definition: render.cpp:295
void SetViewDistance(float dist, layer_t layer)
Definition: render.cpp:192
void AddCube(vec3 pos, float height, float radius, color_t color)
Definition: render.cpp:291
void SetViewRotation(quat rotation, layer_t layer)
Sets the view rotation.
Definition: render.cpp:213
void SetViewPosition(vec3 position, layer_t layer)
Sets the view position.
Definition: render.cpp:205
materialtype_t RegisterMaterialType(const char *name)
Definition: render.cpp:340
void SetSunColor(color_t color, layer_t layer)
Sets the sun color.
Definition: render.cpp:154
float GetViewFov(layer_t layer)
Definition: render.cpp:183
uint32_t layer_t
Definition: render.h:18
materialtype_t FindMaterialType(const char *name)
Definition: render.cpp:356
uint32_t materialtype_t
Definition: render.h:21
const color_t COLOR_CYAN(0.0f, 1.0f, 1.0f)
const color_t COLOR_PINK(1.0f, 0.0f, 1.0f)
void AddLineAABB(vec3 min, vec3 max, vec3 center, quat rotation, vec3 color)
Definition: render.cpp:239
void SetOrthoRatio(float ratio, layer_t layer)
Definition: render.cpp:187
MaterialFilter
Definition: render.h:85
@ FILTER_NEAREST
Definition: render.h:86
@ FILTER_LINEAR
Definition: render.h:87
void AddLine(vec3 from, vec3 to, vec3 color)
Definition: render.cpp:228
void SetScreenSize(float width, float height)
Definition: render.cpp:167
const color_t COLOR_BLUE(0.0f, 0.0f, 1.0f)
const char * GetVertexFormatName(vertexformat_t type)
Definition: render.cpp:364
const color_t COLOR_WHITE(1.0f, 1.0f, 1.0f)
void AddSphere(vec3 pos, float radius, color_t color)
Definition: render.cpp:279
void SetAmbientColor(color_t color, layer_t layer)
Sets the ambient color.
Definition: render.cpp:162
vec3 GetViewPosition(layer_t layer)
Returns the view position for a given layer.
Definition: render.cpp:219
void AddLineMarker(vec3 location, vec3 color)
Definition: render.cpp:233
vec3 ProjectInverse(vec3 point, layer_t layer)
Definition: render.cpp:303
glm::vec3 vec3
Definition: math.h:12
glm::quat quat
Definition: math.h:13
Definition: direct3d.h:11
Definition: direct3d.h:40
Definition: renderer.h:31
Definition: renderer.h:21
Definition: software.h:66
Definition: software.h:58
Definition: software.h:12
Definition: software.h:25
Definition: software.h:50
Definition: render.h:131
API::GLDrawListEntry * gl
Definition: render.h:133
API::SWDrawListEntry * sw
Definition: render.h:135
API::D3DDrawListEntry * d3d
Definition: render.h:134
Definition: render.h:118
IDirect3DIndexBuffer9 * d3d_index_buffer
Definition: render.h:121
API::SWIndexArray * sw_index_array
Definition: render.h:122
uint32_t gl_index_buffer
Definition: render.h:120
Definition: render.h:155
API::GLLight * gl
Definition: render.h:157
API::D3DLight * d3d
Definition: render.h:158
API::SWLight * sw
Definition: render.h:159
Definition: render.h:142
uint32_t gl_texture_handle
Definition: render.h:144
IDirect3DTexture9 * d3d_texture_handle
Definition: render.h:145
API::SWTexture * sw_texture
Definition: render.h:146
Definition: render.h:101
API::SWVertexArray * sw_vertex_array
Definition: render.h:111
IDirect3DVertexBuffer9 * d3d_vertex_buffer
Definition: render.h:108
uint32_t gl_vertex_array
Definition: render.h:104
uint32_t gl_vertex_buffer
Definition: render.h:105
uint32_t d3d_metadata
Definition: render.h:109