rs_graphics.rsh revision b7e83bda41e66c966b98935b44140692bfe0c4ca
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    rsgAllocationSyncAll(rs_allocation);
39
40extern void __attribute__((overloadable))
41    rsgUploadToTexture(rs_allocation);
42extern void __attribute__((overloadable))
43    rsgUploadToTexture(rs_allocation, uint mipLevel);
44extern void __attribute__((overloadable))
45    rsgUploadToBufferObject(rs_allocation);
46
47extern void __attribute__((overloadable))
48    rsgDrawRect(float x1, float y1, float x2, float y2, float z);
49extern void __attribute__((overloadable))
50    rsgDrawQuad(float x1, float y1, float z1,
51                float x2, float y2, float z2,
52                float x3, float y3, float z3,
53                float x4, float y4, float z4);
54extern void __attribute__((overloadable))
55    rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
56                         float x2, float y2, float z2, float u2, float v2,
57                         float x3, float y3, float z3, float u3, float v3,
58                         float x4, float y4, float z4, float u4, float v4);
59extern void __attribute__((overloadable))
60    rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
61
62extern void __attribute__((overloadable))
63    rsgDrawMesh(rs_mesh ism);
64extern void __attribute__((overloadable))
65    rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
66extern void __attribute__((overloadable))
67    rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
68
69extern void __attribute__((overloadable))
70    rsgClearColor(float, float, float, float);
71extern void __attribute__((overloadable))
72    rsgClearDepth(float);
73
74extern void __attribute__((overloadable))
75    rsgDrawText(const char *, int x, int y);
76extern void __attribute__((overloadable))
77    rsgDrawText(rs_allocation, int x, int y);
78extern void __attribute__((overloadable))
79    rsgBindFont(rs_font);
80extern void __attribute__((overloadable))
81    rsgFontColor(float, float, float, float);
82// Returns the bounding box of the text relative to (0, 0)
83// Any of left, right, top, bottom could be NULL
84extern void __attribute__((overloadable))
85    rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
86extern void __attribute__((overloadable))
87    rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
88
89extern void __attribute__((overloadable))
90    rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
91                                                float *maxX, float *maxY, float *maxZ);
92__inline__ static void __attribute__((overloadable, always_inline))
93rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
94    float x1, y1, z1, x2, y2, z2;
95    rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
96    bBoxMin->x = x1;
97    bBoxMin->y = y1;
98    bBoxMin->z = z1;
99    bBoxMax->x = x2;
100    bBoxMax->y = y2;
101    bBoxMax->z = z2;
102}
103
104///////////////////////////////////////////////////////
105// misc
106
107// Depricated
108extern void __attribute__((overloadable))
109    color(float, float, float, float);
110
111#endif
112
113