Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 1 | #ifndef __RS_GRAPHICS_RSH__ |
| 2 | #define __RS_GRAPHICS_RSH__ |
| 3 | |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame^] | 4 | /** |
| 5 | * Set the color target used for all subsequent rendering calls |
| 6 | * @param colorTarget |
| 7 | * @param slot |
| 8 | */ |
| 9 | extern void __attribute__((overloadable)) |
| 10 | rsgBindColorTarget(rs_allocation colorTarget, uint slot); |
| 11 | |
| 12 | /** |
| 13 | * Clear the previously set color target |
| 14 | * @param slot |
| 15 | */ |
| 16 | extern void __attribute__((overloadable)) |
| 17 | rsgClearColorTarget(uint slot); |
| 18 | |
| 19 | /** |
| 20 | * Set the depth target used for all subsequent rendering calls |
| 21 | * @param depthTarget |
| 22 | */ |
| 23 | extern void __attribute__((overloadable)) |
| 24 | rsgBindDepthTarget(rs_allocation depthTarget); |
| 25 | |
| 26 | /** |
| 27 | * Clear the previously set depth target |
| 28 | */ |
| 29 | extern void __attribute__((overloadable)) |
| 30 | rsgClearDepthTarget(void); |
| 31 | |
| 32 | /** |
| 33 | * Clear all color and depth targets and resume rendering into |
| 34 | * the framebuffer |
| 35 | */ |
| 36 | extern void __attribute__((overloadable)) |
| 37 | rsgClearAllRenderTargets(void); |
| 38 | |
| 39 | /** |
| 40 | * Force RenderScript to finish all rendering commands |
| 41 | */ |
| 42 | extern uint __attribute__((overloadable)) |
| 43 | rsgFinish(void); |
Jason Sams | f2bcce7 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 44 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 45 | /** |
| 46 | * Bind a new ProgramFragment to the rendering context. |
| 47 | * |
| 48 | * @param pf |
| 49 | */ |
| 50 | extern 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 | */ |
| 58 | extern 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 | */ |
| 66 | extern 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 | */ |
| 74 | extern 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 Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 83 | extern void __attribute__((overloadable)) |
| 84 | rsgBindSampler(rs_program_fragment, uint slot, rs_sampler); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 85 | |
| 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 Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 94 | extern void __attribute__((overloadable)) |
| 95 | rsgBindTexture(rs_program_fragment, uint slot, rs_allocation); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 96 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 97 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 98 | extern void __attribute__((overloadable)) |
| 99 | rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *); |
| 100 | extern void __attribute__((overloadable)) |
| 101 | rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *); |
| 102 | extern void __attribute__((overloadable)) |
| 103 | rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 104 | |
Jason Sams | 6445e52 | 2010-08-04 17:50:20 -0700 | [diff] [blame] | 105 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 95333f9 | 2010-08-16 17:40:10 -0700 | [diff] [blame] | 106 | rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *); |
| 107 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 108 | /** |
| 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 Sakhartchouk | 95333f9 | 2010-08-16 17:40:10 -0700 | [diff] [blame] | 117 | extern void __attribute__((overloadable)) |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 118 | rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a); |
Jason Sams | 6445e52 | 2010-08-04 17:50:20 -0700 | [diff] [blame] | 119 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 120 | /** |
| 121 | * Get the width of the current rendering surface. |
| 122 | * |
| 123 | * @return uint |
| 124 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 125 | extern uint __attribute__((overloadable)) |
| 126 | rsgGetWidth(void); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * Get the height of the current rendering surface. |
| 130 | * |
| 131 | * @return uint |
| 132 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 133 | extern uint __attribute__((overloadable)) |
| 134 | rsgGetHeight(void); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 135 | |
Jason Sams | b7e83bd | 2010-12-15 01:41:00 -0800 | [diff] [blame] | 136 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 137 | /** |
| 138 | * Sync the contents of an allocation from its SCRIPT memory space to its HW |
| 139 | * memory spaces. |
| 140 | * |
| 141 | * @param alloc |
| 142 | */ |
| 143 | extern 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 Sams | b7e83bd | 2010-12-15 01:41:00 -0800 | [diff] [blame] | 156 | extern void __attribute__((overloadable)) |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 157 | rsgDrawRect(float x1, float y1, float x2, float y2, float z); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 158 | |
| 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 Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 176 | extern 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 Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 181 | |
| 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 Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 208 | extern 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 Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 213 | |
| 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 Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 227 | extern void __attribute__((overloadable)) |
| 228 | rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 229 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 230 | /** |
| 231 | * Draw a mesh of geometry using the current context state. The whole mesh is |
| 232 | * rendered. |
| 233 | * |
| 234 | * @param ism |
| 235 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 236 | extern void __attribute__((overloadable)) |
| 237 | rsgDrawMesh(rs_mesh ism); |
| 238 | extern void __attribute__((overloadable)) |
| 239 | rsgDrawMesh(rs_mesh ism, uint primitiveIndex); |
| 240 | extern void __attribute__((overloadable)) |
| 241 | rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len); |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 242 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 243 | /** |
| 244 | * Clears the rendering surface to the specified color. |
| 245 | * |
| 246 | * @param r |
| 247 | * @param g |
| 248 | * @param b |
| 249 | * @param a |
| 250 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 251 | extern void __attribute__((overloadable)) |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 252 | rsgClearColor(float r, float g, float b, float a); |
| 253 | |
| 254 | /** |
| 255 | * Clears the depth suface to the specified value. |
| 256 | * |
| 257 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 258 | extern void __attribute__((overloadable)) |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 259 | rsgClearDepth(float value); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 260 | |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 261 | extern void __attribute__((overloadable)) |
| 262 | rsgDrawText(const char *, int x, int y); |
| 263 | extern void __attribute__((overloadable)) |
| 264 | rsgDrawText(rs_allocation, int x, int y); |
| 265 | extern void __attribute__((overloadable)) |
| 266 | rsgBindFont(rs_font); |
Alex Sakhartchouk | 9fc9f03 | 2010-08-04 14:45:48 -0700 | [diff] [blame] | 267 | extern void __attribute__((overloadable)) |
| 268 | rsgFontColor(float, float, float, float); |
Alex Sakhartchouk | 09c6735 | 2010-10-05 11:33:27 -0700 | [diff] [blame] | 269 | // Returns the bounding box of the text relative to (0, 0) |
| 270 | // Any of left, right, top, bottom could be NULL |
| 271 | extern void __attribute__((overloadable)) |
| 272 | rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom); |
| 273 | extern void __attribute__((overloadable)) |
| 274 | rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom); |
Alex Sakhartchouk | d3e0ad4 | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 275 | |
Alex Sakhartchouk | ba4aa5c | 2010-08-13 14:32:23 -0700 | [diff] [blame] | 276 | extern void __attribute__((overloadable)) |
| 277 | rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ, |
| 278 | float *maxX, float *maxY, float *maxZ); |
Jason Sams | 399dc9e | 2010-10-15 17:57:07 -0700 | [diff] [blame] | 279 | __inline__ static void __attribute__((overloadable, always_inline)) |
Alex Sakhartchouk | ba4aa5c | 2010-08-13 14:32:23 -0700 | [diff] [blame] | 280 | rsgMeshComputeBoundingBox(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 Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 291 | #endif |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 292 | |