-
Notifications
You must be signed in to change notification settings - Fork 26
/
render.h
63 lines (50 loc) · 1.61 KB
/
render.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <stdint.h>
#include <assert.h>
#include <algorithm> // std::min/max
#include "terrain.h"
#include "world.h"
struct AnsiCell
{
// R G B A
uint8_t fg, bk, gl, spare; // for post pass
};
struct MatCell
{
uint8_t fg[3]; // foreground color
uint8_t gl; // glyph code
uint8_t bg[3]; // background color
uint8_t flags;
// transparency mask :
// 0x1 - fg
// 0x2 - gl
// 0x4 - bg
// blend modes 3x3 bits:
// 0x03 2-bits fg blend mode (0:replace, 1:multiply, 2:screen, 3:transparent)
// 0x04 glyph write mask (0:replace, 1:keep)
// 0x18 2-bits bg blend mode (0:replace, 1:multiply, 2:screen, 3:transparent)
// 3 bits left!
};
struct Material
{
MatCell shade[4][16];
};
struct Renderer;
Renderer* CreateRenderer(uint64_t stamp);
void DeleteRenderer(Renderer* r);
// return null-terminated array of item pointers that are reachable by player
/*
Item** Render(Renderer* r, uint64_t stamp, Terrain* t, World* w, float water, // scene
float zoom, float yaw, const float pos[3], const float lt[4], // view
int width, int height, AnsiCell* ptr, // target
Sprite* sprite, int anim, int frame, float dir, // player
const int scene_shift[2]); // special fx
*/
void Render(Renderer* r, uint64_t stamp, Terrain* t, World* w, float water, // scene
float zoom, float yaw, const float pos[3], const float lt[4], // view
int width, int height, AnsiCell* ptr, // target
Inst* player, // player
const int scene_shift[2]); // special fx
void ProjectCoords(Renderer* r, const float pos[3], int view[3]); // like a sprite!
Item** GetNearbyItems(Renderer* r);
Inst** GetNearbyCharacters(Renderer* r);