blob: d53bc952ded53a78999312a2d83322b45795dac8 [file] [log] [blame]
Jason Sams1b937f52010-06-09 14:26:16 -07001#ifndef __RS_GRAPHICS_RSH__
2#define __RS_GRAPHICS_RSH__
3
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -07004/**
5 * Set the color target used for all subsequent rendering calls
6 * @param colorTarget
7 * @param slot
8 */
9extern void __attribute__((overloadable))
10 rsgBindColorTarget(rs_allocation colorTarget, uint slot);
11
12/**
13 * Clear the previously set color target
14 * @param slot
15 */
16extern void __attribute__((overloadable))
17 rsgClearColorTarget(uint slot);
18
19/**
20 * Set the depth target used for all subsequent rendering calls
21 * @param depthTarget
22 */
23extern void __attribute__((overloadable))
24 rsgBindDepthTarget(rs_allocation depthTarget);
25
26/**
27 * Clear the previously set depth target
28 */
29extern void __attribute__((overloadable))
30 rsgClearDepthTarget(void);
31
32/**
33 * Clear all color and depth targets and resume rendering into
34 * the framebuffer
35 */
36extern void __attribute__((overloadable))
37 rsgClearAllRenderTargets(void);
38
39/**
40 * Force RenderScript to finish all rendering commands
41 */
42extern uint __attribute__((overloadable))
43 rsgFinish(void);
Jason Samsf2bcce72010-03-26 15:33:42 -070044
Jason Sams09aeb8a2011-01-28 15:49:07 -080045/**
46 * Bind a new ProgramFragment to the rendering context.
47 *
48 * @param pf
49 */
50extern void __attribute__((overloadable))
51 rsgBindProgramFragment(rs_program_fragment pf);
52
53/**
54 * Bind a new ProgramStore to the rendering context.
55 *
56 * @param ps
57 */
58extern void __attribute__((overloadable))
59 rsgBindProgramStore(rs_program_store ps);
60
61/**
62 * Bind a new ProgramVertex to the rendering context.
63 *
64 * @param pv
65 */
66extern void __attribute__((overloadable))
67 rsgBindProgramVertex(rs_program_vertex pv);
68
69/**
70 * Bind a new ProgramRaster to the rendering context.
71 *
72 * @param pr
73 */
74extern void __attribute__((overloadable))
75 rsgBindProgramRaster(rs_program_raster pr);
76
77/**
78 * Bind a new Sampler object to a ProgramFragment. The sampler will
79 * operate on the texture bound at the matching slot.
80 *
81 * @param slot
82 */
Jason Sams73495472010-07-29 17:31:14 -070083extern void __attribute__((overloadable))
84 rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
Jason Sams09aeb8a2011-01-28 15:49:07 -080085
86/**
87 * Bind a new Allocation object to a ProgramFragment. The
88 * Allocation must be a valid texture for the Program. The sampling
89 * of the texture will be controled by the Sampler bound at the
90 * matching slot.
91 *
92 * @param slot
93 */
Jason Sams73495472010-07-29 17:31:14 -070094extern void __attribute__((overloadable))
95 rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
Jason Sams51f36ab2010-03-18 14:36:05 -070096
Jason Sams09aeb8a2011-01-28 15:49:07 -080097
Jason Sams73495472010-07-29 17:31:14 -070098extern void __attribute__((overloadable))
99 rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *);
100extern void __attribute__((overloadable))
101 rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *);
102extern void __attribute__((overloadable))
103 rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *);
Jason Sams51f36ab2010-03-18 14:36:05 -0700104
Jason Sams6445e522010-08-04 17:50:20 -0700105extern void __attribute__((overloadable))
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700106 rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *);
107
Jason Sams09aeb8a2011-01-28 15:49:07 -0800108/**
109 * Set the constant color for a fixed function emulation program.
110 *
111 * @param pf
112 * @param r
113 * @param g
114 * @param b
115 * @param a
116 */
Alex Sakhartchouk95333f92010-08-16 17:40:10 -0700117extern void __attribute__((overloadable))
Jason Sams09aeb8a2011-01-28 15:49:07 -0800118 rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a);
Jason Sams6445e522010-08-04 17:50:20 -0700119
Jason Sams09aeb8a2011-01-28 15:49:07 -0800120/**
121 * Get the width of the current rendering surface.
122 *
123 * @return uint
124 */
Jason Sams73495472010-07-29 17:31:14 -0700125extern uint __attribute__((overloadable))
126 rsgGetWidth(void);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800127
128/**
129 * Get the height of the current rendering surface.
130 *
131 * @return uint
132 */
Jason Sams73495472010-07-29 17:31:14 -0700133extern uint __attribute__((overloadable))
134 rsgGetHeight(void);
Jason Sams51f36ab2010-03-18 14:36:05 -0700135
Jason Samsb7e83bd2010-12-15 01:41:00 -0800136
Jason Sams09aeb8a2011-01-28 15:49:07 -0800137/**
138 * Sync the contents of an allocation from its SCRIPT memory space to its HW
139 * memory spaces.
140 *
141 * @param alloc
142 */
143extern void __attribute__((overloadable))
144 rsgAllocationSyncAll(rs_allocation alloc);
145
146/**
147 * Low performance utility function for drawing a simple rectangle. Not
148 * intended for drawing large quantities of geometry.
149 *
150 * @param x1
151 * @param y1
152 * @param x2
153 * @param y2
154 * @param z
155 */
Jason Samsb7e83bd2010-12-15 01:41:00 -0800156extern void __attribute__((overloadable))
Jason Sams73495472010-07-29 17:31:14 -0700157 rsgDrawRect(float x1, float y1, float x2, float y2, float z);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800158
159/**
160 * Low performance utility function for drawing a simple quad. Not intended for
161 * drawing large quantities of geometry.
162 *
163 * @param x1
164 * @param y1
165 * @param z1
166 * @param x2
167 * @param y2
168 * @param z2
169 * @param x3
170 * @param y3
171 * @param z3
172 * @param x4
173 * @param y4
174 * @param z4
175 */
Jason Sams73495472010-07-29 17:31:14 -0700176extern void __attribute__((overloadable))
177 rsgDrawQuad(float x1, float y1, float z1,
178 float x2, float y2, float z2,
179 float x3, float y3, float z3,
180 float x4, float y4, float z4);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800181
182
183/**
184 * Low performance utility function for drawing a textured quad. Not intended
185 * for drawing large quantities of geometry.
186 *
187 * @param x1
188 * @param y1
189 * @param z1
190 * @param u1
191 * @param v1
192 * @param x2
193 * @param y2
194 * @param z2
195 * @param u2
196 * @param v2
197 * @param x3
198 * @param y3
199 * @param z3
200 * @param u3
201 * @param v3
202 * @param x4
203 * @param y4
204 * @param z4
205 * @param u4
206 * @param v4
207 */
Jason Sams73495472010-07-29 17:31:14 -0700208extern void __attribute__((overloadable))
209 rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1,
210 float x2, float y2, float z2, float u2, float v2,
211 float x3, float y3, float z3, float u3, float v3,
212 float x4, float y4, float z4, float u4, float v4);
Jason Sams09aeb8a2011-01-28 15:49:07 -0800213
214
215/**
216 * Low performance function for drawing rectangles in screenspace. This
217 * function uses the default passthough ProgramVertex. Any bound ProgramVertex
218 * is ignored. This function has considerable overhead and should not be used
219 * for drawing in shipping applications.
220 *
221 * @param x
222 * @param y
223 * @param z
224 * @param w
225 * @param h
226 */
Jason Sams73495472010-07-29 17:31:14 -0700227extern void __attribute__((overloadable))
228 rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
Jason Sams51f36ab2010-03-18 14:36:05 -0700229
Jason Sams09aeb8a2011-01-28 15:49:07 -0800230/**
231 * Draw a mesh of geometry using the current context state. The whole mesh is
232 * rendered.
233 *
234 * @param ism
235 */
Jason Sams73495472010-07-29 17:31:14 -0700236extern void __attribute__((overloadable))
237 rsgDrawMesh(rs_mesh ism);
238extern void __attribute__((overloadable))
239 rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
240extern void __attribute__((overloadable))
241 rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
Alex Sakhartchouk4e9a7a82010-07-01 16:14:06 -0700242
Jason Sams09aeb8a2011-01-28 15:49:07 -0800243/**
244 * Clears the rendering surface to the specified color.
245 *
246 * @param r
247 * @param g
248 * @param b
249 * @param a
250 */
Jason Sams73495472010-07-29 17:31:14 -0700251extern void __attribute__((overloadable))
Jason Sams09aeb8a2011-01-28 15:49:07 -0800252 rsgClearColor(float r, float g, float b, float a);
253
254/**
255 * Clears the depth suface to the specified value.
256 *
257 */
Jason Sams73495472010-07-29 17:31:14 -0700258extern void __attribute__((overloadable))
Jason Sams09aeb8a2011-01-28 15:49:07 -0800259 rsgClearDepth(float value);
Jason Sams51f36ab2010-03-18 14:36:05 -0700260
Jason Sams73495472010-07-29 17:31:14 -0700261extern void __attribute__((overloadable))
262 rsgDrawText(const char *, int x, int y);
263extern void __attribute__((overloadable))
264 rsgDrawText(rs_allocation, int x, int y);
265extern void __attribute__((overloadable))
266 rsgBindFont(rs_font);
Alex Sakhartchouk9fc9f032010-08-04 14:45:48 -0700267extern void __attribute__((overloadable))
268 rsgFontColor(float, float, float, float);
Alex Sakhartchouk09c67352010-10-05 11:33:27 -0700269// Returns the bounding box of the text relative to (0, 0)
270// Any of left, right, top, bottom could be NULL
271extern void __attribute__((overloadable))
272 rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
273extern void __attribute__((overloadable))
274 rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
Alex Sakhartchoukd3e0ad42010-06-24 17:15:34 -0700275
Alex Sakhartchoukba4aa5c2010-08-13 14:32:23 -0700276extern void __attribute__((overloadable))
277 rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
278 float *maxX, float *maxY, float *maxZ);
Jason Sams399dc9e2010-10-15 17:57:07 -0700279__inline__ static void __attribute__((overloadable, always_inline))
Alex Sakhartchoukba4aa5c2010-08-13 14:32:23 -0700280rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
281 float x1, y1, z1, x2, y2, z2;
282 rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2);
283 bBoxMin->x = x1;
284 bBoxMin->y = y1;
285 bBoxMin->z = z1;
286 bBoxMax->x = x2;
287 bBoxMax->y = y2;
288 bBoxMax->z = z2;
289}
290
Jason Sams1b937f52010-06-09 14:26:16 -0700291#endif
Jason Sams51f36ab2010-03-18 14:36:05 -0700292