This repository has been archived by the owner on Mar 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrender.h
103 lines (85 loc) · 2.6 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Fade To Black engine rewrite
* Copyright (C) 2006-2012 Gregory Montoir ([email protected])
*/
#ifndef RENDER_H__
#define RENDER_H__
#include "util.h"
enum {
kFlatColorRed = 512,
kFlatColorGreen,
kFlatColorYellow,
kFlatColorBlue,
kFlatColorShadow,
kFlatColorLight,
kFlatColorLight9
};
enum {
kProjGame = 0,
kProjMenu,
kProjInstall,
kProj2D
};
struct Texture;
struct RenderParams {
bool fog;
bool gouraud; // enable lighting
const char *textureFilter;
const char *textureScaler;
};
struct Render {
uint8_t _clut[256 * 3];
int _w, _h;
float _aspectRatio;
float _fov;
uint8_t *_screenshotBuf;
struct {
bool rgbTex;
Texture *tex;
int x, y, w, h;
int displayWidth, displayHeight;
int r, g, b;
} _overlay;
struct {
bool changed;
int wScale, hScale;
int x, y, w, h;
} _viewport;
bool _paletteGreyScale;
int _paletteRgbScale;
bool _fog;
bool _lighting;
bool _drawObjectIgnoreDepth;
int _framesCount;
int _framesPerSec;
Render(const RenderParams *params);
~Render();
void flushCachedTextures();
void toggleFog() { _fog = !_fog; }
void toggleGouraudShading() { _lighting = !_lighting; }
void setCameraPos(int x, int y, int z, int shift = 0);
void setCameraPitch(int a);
bool hasTexture(int16_t key);
void prepareTextureLut(const uint8_t *data, int w, int h, const uint8_t *clut, int16_t texKey);
void prepareTextureRgb(const uint8_t *data, int w, int h, int16_t texKey);
void releaseTexture(int16_t texKey);
void drawPolygonFlat(const Vertex *vertices, int verticesCount, int color);
void drawPolygonTexture(const Vertex *vertices, int verticesCount, int primitive, const uint8_t *texData, int texW, int texH, int16_t texKey);
void drawParticle(const Vertex *pos, int color);
void drawSprite(int x, int y, const uint8_t *texData, int texW, int texH, int primitive, int16_t texKey, uint8_t transparentScale = 255);
void drawRectangle(int x, int y, int w, int h, int color);
void setIgnoreDepth(bool ignoreDepth);
void beginObjectDraw(int x, int y, int z, int ry, int shift = 0);
void endObjectDraw();
void setOverlayBlendColor(int r, int g, int b);
void resizeOverlay(int w, int h, bool rgb = false, int displayWidth = 0, int displayHeight = 0);
void copyToOverlay(int x, int y, int w, int h, const uint8_t *data, bool rgb = false, const uint8_t *clut = 0);
void setPaletteScale(bool greyScale, int rgbScale);
void setPalette(const uint8_t *pal, int offset, int count);
void clearScreen();
void setupProjection(int mode);
void drawOverlay();
void resizeScreen(int w, int h, float *p, int fov);
const uint8_t *captureScreen(int *w, int *h);
};
#endif // RENDER_H__