rs_graphics.rsh revision 9966e2130c731cb372e2f53c041142a4f9a6a0fe
1#ifndef __RS_GRAPHICS_RSH__
2#define __RS_GRAPHICS_RSH__
3
4// Bind a ProgramFragment to the RS context.
5extern void __attribute__((overloadable))
6    rsgBindProgramFragment(rs_program_fragment);
7extern void __attribute__((overloadable))
8    rsgBindProgramStore(rs_program_store);
9extern void __attribute__((overloadable))
10    rsgBindProgramVertex(rs_program_vertex);
11extern void __attribute__((overloadable))
12    rsgBindProgramRaster(rs_program_raster);
13
14extern void __attribute__((overloadable))
15    rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
16extern void __attribute__((overloadable))
17    rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
18
19extern void __attribute__((overloadable))
20    rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *);
21extern void __attribute__((overloadable))
22    rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *);
23extern void __attribute__((overloadable))
24    rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *);
25
26extern void __attribute__((overloadable))
27    rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *);
28
29extern void __attribute__((overloadable))
30    rsgProgramFragmentConstantColor(rs_program_fragment, float, float, float, float);
31
32extern uint __attribute__((overloadable))
33    rsgGetWidth(void);
34extern uint __attribute__((overloadable))
35    rsgGetHeight(void);
36
37extern void __attribute__((overloadable))
38    rsgUploadToTexture(rs_allocation);
39extern void __attribute__((overloadable))
40    rsgUploadToTexture(rs_allocation, uint mipLevel);
41extern void __attribute__((overloadable))
42    rsgUploadToBufferObject(rs_allocation);
43
44extern void __attribute__((overloadable))
45    rsgDrawRect(float x1, float y1, float x2, float y2, float z);
46extern void __attribute__((overloadable))
47    rsgDrawQuad(float x1, float y1, float z1,
48                float x2, float y2, float z2,
49                float x3, float y3, float z3,
50                float x4, float y4, float z4);
51extern void __attribute__((overloadable))
52    rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
53                         float x2, float y2, float z2, float u2, float v2,
54                         float x3, float y3, float z3, float u3, float v3,
55                         float x4, float y4, float z4, float u4, float v4);
56extern void __attribute__((overloadable))
57    rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
58
59extern void __attribute__((overloadable))
60    rsgDrawMesh(rs_mesh ism);
61extern void __attribute__((overloadable))
62    rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
63extern void __attribute__((overloadable))
64    rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
65
66extern void __attribute__((overloadable))
67    rsgClearColor(float, float, float, float);
68extern void __attribute__((overloadable))
69    rsgClearDepth(float);
70
71extern void __attribute__((overloadable))
72    rsgDrawText(const char *, int x, int y);
73extern void __attribute__((overloadable))
74    rsgDrawText(rs_allocation, int x, int y);
75extern void __attribute__((overloadable))
76    rsgBindFont(rs_font);
77extern void __attribute__((overloadable))
78    rsgFontColor(float, float, float, float);
79// Returns the bounding box of the text relative to (0, 0)
80// Any of left, right, top, bottom could be NULL
81extern void __attribute__((overloadable))
82    rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
83extern void __attribute__((overloadable))
84    rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
85
86extern void __attribute__((overloadable))
87    rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
88                                                float *maxX, float *maxY, float *maxZ);
89__inline__ static void __attribute__((overloadable, always_inline))
90rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
91    float x1, y1, z1, x2, y2, z2;
92    rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
93    bBoxMin->x = x1;
94    bBoxMin->y = y1;
95    bBoxMin->z = z1;
96    bBoxMax->x = x2;
97    bBoxMax->y = y2;
98    bBoxMax->z = z2;
99}
100
101///////////////////////////////////////////////////////
102// misc
103
104// Depricated
105extern void __attribute__((overloadable))
106    color(float, float, float, float);
107
108#endif
109
110