-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrenderer_null.cpp
More file actions
134 lines (116 loc) · 3.27 KB
/
renderer_null.cpp
File metadata and controls
134 lines (116 loc) · 3.27 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "global.h"
struct RBatchNULL : public RBatch
{
/* uint maxverts, maxindis;
uint curverts, curindis;
*/
batchVertex *mv; ushort *mi;
~RBatchNULL() {delete [] mv; delete [] mi;}
void begin() {}
void end() {}
void flush() {curverts = curindis = 0;}
void next(uint nverts, uint nindis, batchVertex **vpnt, ushort **ipnt, uint *fi)
{
if(nverts > maxverts) ferr("Too many vertices to fit in the batch.");
if(nindis > maxindis) ferr("Too many indices to fit in the batch.");
if((curverts + nverts > maxverts) || (curindis + nindis > maxindis))
flush();
*vpnt = mv + curverts;
*ipnt = mi + curindis;
*fi = curverts;
curverts += nverts; curindis += nindis;
}
};
struct RVertexBufferNULL : public RVertexBuffer
{
batchVertex *mem;
~RVertexBufferNULL() {delete [] mem;}
batchVertex *lock() {return mem;}
void unlock() {}
};
struct RIndexBufferNULL : public RIndexBuffer
{
ushort *mem;
~RIndexBufferNULL() {delete [] mem;}
ushort *lock() {return mem;}
void unlock() {}
};
struct NULLRenderer : public IRenderer
{
// Initialisation
void Init() {}
void Reset() {}
// Frame begin/end
void BeginDrawing() {}
void EndDrawing() {drawframes++;}
// Textures management
texture CreateTexture(Bitmap *bm, int mipmaps) {return (texture)0;}
void FreeTexture(texture t) {}
void UpdateTexture(texture t, Bitmap *bmp) {}
// State changes
void SetTransformMatrix(Matrix *m) {}
void SetTexture(uint x, texture t) {}
void NoTexture(uint x) {}
void SetFog() {}
void DisableFog() {}
void EnableAlphaTest() {}
void DisableAlphaTest() {}
void EnableColorBlend() {}
void DisableColorBlend() {}
void SetBlendColor(int c) {}
void EnableAlphaBlend() {}
void DisableAlphaBlend() {}
void EnableScissor() {}
void DisableScissor() {}
void SetScissorRect(int x, int y, int w, int h) {}
void EnableDepth() {};
void DisableDepth() {};
// 2D Rectangles drawing
void InitRectDrawing() {}
void DrawRect(int x, int y, int w, int h, int c, float u, float v, float o, float p) {}
void DrawGradientRect(int x, int y, int w, int h, int c0, int c1, int c2, int c3) {}
void DrawFrame(int x, int y, int w, int h, int c) {}
// 3D Landscape/Heightmap drawing
void CreateMapPart(MapPart *p, int x, int y, int w, int h) {}
void FreeMapPart(MapPart *p) {}
void BeginMapDrawing() {}
void DrawPart(MapPart *p) {}
void BeginLakeDrawing() {}
// 3D Mesh drawing
void CreateMesh(Mesh *m) {}
void BeginMeshDrawing() {}
void DrawMesh(Mesh *m, int iwtcolor) {}
// Batch drawing
RBatch *CreateBatch(int mv, int mi)
{
RBatchNULL *r = new RBatchNULL;
r->maxverts = mv; r->maxindis = mi;
r->curverts = r->curindis = 0;
r->mv = new batchVertex[mv];
r->mi = new ushort[mi];
return r;
}
void BeginBatchDrawing() {}
int ConvertColor(int c) {return c;}
// Buffer drawing
RVertexBuffer *CreateVertexBuffer(int nv)
{
RVertexBufferNULL *r = new RVertexBufferNULL;
r->size = nv;
r->mem = new batchVertex[nv];
return r;
}
RIndexBuffer *CreateIndexBuffer(int ni)
{
RIndexBufferNULL *r = new RIndexBufferNULL;
r->size = ni;
r->mem = new ushort[ni];
return r;
}
void SetVertexBuffer(RVertexBuffer *_rv) {}
void SetIndexBuffer(RIndexBuffer *_ri) {}
void DrawBuffer(int first, int count) {}
// ImGui
void InitImGuiDrawing() {}
};
IRenderer *CreateNULLRenderer() {return new NULLRenderer;}