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
|
#pragma once
#include "gl_batch.h"
#include "../util/matrix.h"
// magic number sue me. yes this float is representable exactly.
const F32 SCREEN_INVALID_POS = -2137000.f;
struct VERTEX3D {
VEC3 pos;
VEC2 uv;
CLR clr;
U8 sampler;
};
using GL_BATCH3D = GL_BATCH<VERTEX3D>;
struct GL_3D : GL_SHADER_PROGRAM {
F32 aspect;
MAT4 projmat;
VEC2 winsize;
};
// shader init -----------------------------------------------------------
extern GL_3D* gl_3d_init( GL_DATA* gl, VEC2 screensize, const char* shadername );
// sets up projection matrix and sends it to the gpu ------------------------------------------------------------
extern void gl_3d_projection_setup( GL_SHADER_PROGRAM* gl3d, VEC3 pos, F32 fov_deg, F32 yaw, F32 pitch, F32 near, F32 far, VEC2 winsize );
extern void gl_3d_batch_setup( GL_BATCH3D* batch );
// takes a triangle fan not set of triangles
extern void gl_3d_polygon(
GL_SHADER_PROGRAM* gl3d,
VERTEX3D* vertices,
U32 vertices_count,
GL_TEX2D* tex
);
// calculates triangle set from triangle fan before sending to batch
extern void gl_3d_polygon_fan(
GL_BATCH3D* batch,
VERTEX3D* vertices,
U32 vertices_count,
GL_TEX2D* tex
);
// draws a set of triangles
extern void gl_3d_polygon(
GL_BATCH3D* batch,
VERTEX3D* vertices,
U32 vertices_count,
GL_TEX2D* tex
);
extern void gl_3d_plane(
GL_SHADER_PROGRAM* gl3d,
VEC3 pos,
VEC2 size,
VEC2 rot,
GL_TEX2D* tex,
CLR col = CLR::WHITE()
);
extern void gl_3d_plane(
GL_BATCH3D* batch,
VEC3 pos,
VEC2 size,
VEC2 rot,
GL_TEX2D* tex,
CLR col = CLR::WHITE()
);
|