- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSWcore.h
More file actions
Latest commit
131 lines (104 loc) · 3.72 KB
/
Copy pathSWcore.h
File metadata and controls
131 lines (104 loc) · 3.72 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
#ifndefSW_CORE_H
#defineSW_CORE_H
#include"SWtypes.h"
typedefenumSWenum {
/* primitive types */
SW_LINES,
SW_LINE_STRIP,
SW_CURVES,
SW_CURVE_STRIP,
SW_TRIANGLES,
SW_TRIANGLE_STRIP,
/* data types */
SW_UNSIGNED_BYTE,
SW_UNSIGNED_SHORT,
SW_UNSIGNED_INT,
/* unifom types */
SW_INT,
SW_FLOAT,
SW_VEC2,
SW_VEC3,
SW_VEC4,
SW_MAT3,
SW_MAT4,
/* framebuffer types */
SW_BGRA8888,
SW_FRGBA,
/* texture types */
SW_RGB,
SW_RGBA,
SW_BGRA,
SW_COMPRESSED,
/* args for swEnable */
SW_DEPTH_TEST,
SW_DEPTH_WRITE,
SW_BLEND,
SW_PERSPECTIVE_CORRECTION,
SW_FAST_PERSPECTIVE_CORRECTION,
/* buffer types */
SW_ARRAY_BUFFER,
SW_INDEX_BUFFER,
SW_MAX_VERTEX_UNIFORM_VECTORS,
SW_CURVE_TOLERANCE,
SW_TEXTURE0=0,
SW_PHYSICAL_MEMORY,
SW_CPU_VENDOR,
SW_CPU_MODEL,
SW_NUM_CPUS,
} SWenum;
#defineSW_TILE_SIZE 8
#defineSW_INV_TILE_SIZE (((SWfloat)1) / SW_TILE_SIZE)
#defineSW_INV_TILE_STEP (((SWfloat)1) / (SW_TILE_SIZE - 1));
typedefstructSWcontextSWcontext;
/* Context operations */
structSWcontext*swCreateContext(SWintw, SWinth);
voidswMakeCurrent(structSWcontext*ctx);
voidswDeleteContext(structSWcontext*ctx);
/* Vertex buffer operations */
SWintswCreateBuffer();
voidswDeleteBuffer(SWintbuf);
voidswBindBuffer(SWenumtype, SWintbuf);
voidswBufferData(SWenumtype, SWuintsize, constvoid*data);
voidswBufferSubData(SWenumtype, SWuintoffset, SWuintsize, constvoid*data);
voidswGetBufferSubData(SWenumtype, SWuintoffset, SWuintsize, void*data);
/* Framebuffer operations */
SWintswCreateFramebuffer(SWenumtype, SWintw, SWinth, SWintwith_depth);
voidswDeleteFramebuffer(SWinti);
voidswBindFramebuffer(SWinti);
SWintswGetCurFramebuffer();
constvoid*swGetPixelDataRef(SWinti);
constvoid*swGetDepthDataRef(SWinti);
voidswBlitPixels(SWintx, SWinty, SWintpitch, SWenumtype, SWenummode, SWintw,
SWinth, constvoid*pixels, SWfloatscale);
voidswBlitTexture(SWintx, SWinty, SWfloatscale);
/* Texture operations */
SWintswCreateTexture();
voidswDeleteTexture(SWinttex);
voidswActiveTexture(SWintslot);
voidswBindTexture(SWinttex);
voidswTexImage2D(SWenummode, SWenumtype, SWintw, SWinth, constvoid*pixels);
voidswTexImage2DMove_malloced(SWenummode, SWenumtype, SWintw, SWinth, void*pixels);
voidswTexImage2DConst(SWenummode, SWenumtype, SWintw, SWinth, void*pixels);
voidswTexture(SWintslot, constSWfloat*uv, SWfloat*col);
/* SWtexture.h should be included for these */
#defineswTexture_RGB888(slot, uv, col) \
{ \
extern SWcontext *sw_cur_context; \
swTex_RGB888_GetColorFloat_RGBA(&sw_cur_context->textures[slot], uv[0], uv[1], \
col); \
}
/* Program operations */
SWintswCreateProgram();
voidswInitProgram(vtx_shader_procv_proc, frag_shader_procf_proc, SWintv_out_floats);
voidswDeleteProgram(SWintprogram);
voidswUseProgram(SWintprogram);
voidswEnable(SWenumfunc);
voidswDisable(SWenumfunc);
SWintswIsEnabled(SWenumfunc);
voidswClearColor(SWfloatr, SWfloatg, SWfloatb, SWfloata);
voidswClearDepth(SWfloatval);
SWintswGetInteger(SWenumwhat);
SWfloatswGetFloat(SWenumwhat);
constchar*swGetString(SWenumwhat);
voidswSetFloat(SWenumwhat, SWfloatval);
#endif/* SW_CORE_H */