- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSWcontext.h
More file actions
Latest commit
95 lines (76 loc) · 3.63 KB
/
Copy pathSWcontext.h
File metadata and controls
95 lines (76 loc) · 3.63 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
#ifndefSW_CONTEXT_H
#defineSW_CONTEXT_H
#include"SWbuffer.h"
#include"SWcore.h"
#include"SWcpu.h"
#include"SWframebuffer.h"
#include"SWprogram.h"
#include"SWtexture.h"
/* render flags */
#defineDEPTH_TEST_ENABLED (1 << 0)
#defineDEPTH_WRITE_ENABLED (1 << 1)
#defineBLEND_ENABLED (1 << 2)
#definePERSPECTIVE_CORRECTION_ENABLED (1 << 3)
#defineFAST_PERSPECTIVE_CORRECTION (1 << 4)
#defineDEFAULT_RENDER_FLAGS \
(DEPTH_TEST_ENABLED | DEPTH_WRITE_ENABLED | PERSPECTIVE_CORRECTION_ENABLED)
#defineSW_UNIFORM_BUF_SIZE 2048
structSWcontext {
SWubyteuniform_buf[SW_UNIFORM_BUF_SIZE];
SWprogramprograms[32];
SWintnum_programs, cur_program;
SWtexturetextures[256];
SWintnum_textures, binded_textures[8], active_tex_slot;
SWbufferbuffers[256];
SWintnum_buffers, binded_buffers[2];
SWframebufferframebuffers[8];
SWintnum_framebuffers, cur_framebuffer;
SWuintrender_flags;
SWfloatcurve_tolerance;
SWcpu_infocpu_info;
};
voidswCtxInit(SWcontext*ctx, SWintw, SWinth);
voidswCtxDestroy(SWcontext*ctx);
/* Vertex buffer operations */
SWintswCtxCreateBuffer(SWcontext*ctx);
voidswCtxDeleteBuffer(SWcontext*ctx, SWintbuf);
voidswCtxBindBuffer(SWcontext*ctx, SWenumtype, SWintbuf);
voidswCtxBufferData(SWcontext*ctx, SWenumtype, SWuintsize, constvoid*data);
voidswCtxBufferSubData(SWcontext*ctx, SWenumtype, SWuintoffset, SWuintsize,
constvoid*data);
voidswCtxGetBufferSubData(SWcontext*ctx, SWenumtype, SWuintoffset, SWuintsize,
void*data);
/* Framebuffer operations */
SWintswCtxCreateFramebuffer(SWcontext*ctx, SWenumtype, SWintw, SWinth,
SWintwith_depth);
voidswCtxDeleteFramebuffer(SWcontext*ctx, SWinti);
voidswCtxBindFramebuffer(SWcontext*ctx, SWinti);
SWintswCtxGetCurFramebuffer(SWcontext*ctx);
constvoid*swCtxGetPixelDataRef(SWcontext*ctx, SWinti);
constvoid*swCtxGetDepthDataRef(SWcontext*ctx, SWinti);
voidswCtxBlitPixels(SWcontext*ctx, SWintx, SWinty, SWintpitch, SWenumtype,
SWenummode, SWintw, SWinth, constvoid*pixels, SWfloatscale);
voidswCtxBlitTexture(SWcontext*ctx, SWintx, SWinty, SWfloatscale);
/* Texture operations */
SWintswCtxCreateTexture(SWcontext*ctx);
voidswCtxDeleteTexture(SWcontext*ctx, SWinttex);
voidswCtxActiveTexture(SWcontext*ctx, SWintslot);
voidswCtxBindTexture(SWcontext*ctx, SWinttex);
voidswCtxTexImage2D(SWcontext*ctx, SWenummode, SWenumtype, SWintw, SWinth,
constvoid*pixels);
voidswCtxTexImage2DMove_malloced(SWcontext*ctx, SWenummode, SWenumtype, SWintw,
SWinth, void*pixels);
voidswCtxTexImage2DConst(SWcontext*ctx, SWenummode, SWenumtype, SWintw, SWinth,
void*pixels);
/* Program operations */
SWintswCtxCreateProgram(SWcontext*ctx);
voidswCtxInitProgram(SWcontext*ctx, vtx_shader_procv_proc, frag_shader_procf_proc,
SWintv_out_floats);
voidswCtxDeleteProgram(SWcontext*ctx, SWintprogram);
voidswCtxUseProgram(SWcontext*ctx, SWintprogram);
voidswCtxRegisterUniform(SWcontext*ctx, SWintindex, SWenumtype);
voidswCtxRegisterUniformv(SWcontext*ctx, SWintindex, SWenumtype, SWintnum);
voidswCtxSetUniform(SWcontext*ctx, SWintindex, SWenumtype, constvoid*data);
voidswCtxSetUniformv(SWcontext*ctx, SWintindex, SWenumtype, SWintnum,
constvoid*data);
#endif/* SW_CONTEXT_H */