rs_graphics.rsh revision 7d9c5ffccb7a5e682860f752403e5a03aed587be
1#ifndef __RS_GRAPHICS_RSH__ 2#define __RS_GRAPHICS_RSH__ 3 4/** 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); 44 45/** 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 */ 83extern void __attribute__((overloadable)) 84 rsgBindSampler(rs_program_fragment, uint slot, rs_sampler); 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 */ 94extern void __attribute__((overloadable)) 95 rsgBindTexture(rs_program_fragment, uint slot, rs_allocation); 96 97 98extern 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 *); 104 105extern void __attribute__((overloadable)) 106 rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *); 107 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 */ 117extern void __attribute__((overloadable)) 118 rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a); 119 120/** 121 * Get the width of the current rendering surface. 122 * 123 * @return uint 124 */ 125extern uint __attribute__((overloadable)) 126 rsgGetWidth(void); 127 128/** 129 * Get the height of the current rendering surface. 130 * 131 * @return uint 132 */ 133extern uint __attribute__((overloadable)) 134 rsgGetHeight(void); 135 136 137/** 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 */ 156extern void __attribute__((overloadable)) 157 rsgDrawRect(float x1, float y1, float x2, float y2, float z); 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 */ 176extern 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); 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 */ 208extern 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); 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 */ 227extern void __attribute__((overloadable)) 228 rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h); 229 230/** 231 * Draw a mesh of geometry using the current context state. The whole mesh is 232 * rendered. 233 * 234 * @param ism 235 */ 236extern 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); 242 243/** 244 * Clears the rendering surface to the specified color. 245 * 246 * @param r 247 * @param g 248 * @param b 249 * @param a 250 */ 251extern void __attribute__((overloadable)) 252 rsgClearColor(float r, float g, float b, float a); 253 254/** 255 * Clears the depth suface to the specified value. 256 * 257 */ 258extern void __attribute__((overloadable)) 259 rsgClearDepth(float value); 260 261extern 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); 267extern void __attribute__((overloadable)) 268 rsgFontColor(float, float, float, float); 269// 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); 275 276extern void __attribute__((overloadable)) 277 rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ, 278 float *maxX, float *maxY, float *maxZ); 279__inline__ static void __attribute__((overloadable, always_inline)) 280rsgMeshComputeBoundingBox(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 291#endif 292 293