rs_graphics.rsh revision 09aeb8ac1b0b976c2de40dd00da0c6841e4e882a
1#ifndef __RS_GRAPHICS_RSH__ 2#define __RS_GRAPHICS_RSH__ 3 4 5/** 6 * Bind a new ProgramFragment to the rendering context. 7 * 8 * @param pf 9 */ 10extern void __attribute__((overloadable)) 11 rsgBindProgramFragment(rs_program_fragment pf); 12 13/** 14 * Bind a new ProgramStore to the rendering context. 15 * 16 * @param ps 17 */ 18extern void __attribute__((overloadable)) 19 rsgBindProgramStore(rs_program_store ps); 20 21/** 22 * Bind a new ProgramVertex to the rendering context. 23 * 24 * @param pv 25 */ 26extern void __attribute__((overloadable)) 27 rsgBindProgramVertex(rs_program_vertex pv); 28 29/** 30 * Bind a new ProgramRaster to the rendering context. 31 * 32 * @param pr 33 */ 34extern void __attribute__((overloadable)) 35 rsgBindProgramRaster(rs_program_raster pr); 36 37/** 38 * Bind a new Sampler object to a ProgramFragment. The sampler will 39 * operate on the texture bound at the matching slot. 40 * 41 * @param slot 42 */ 43extern void __attribute__((overloadable)) 44 rsgBindSampler(rs_program_fragment, uint slot, rs_sampler); 45 46/** 47 * Bind a new Allocation object to a ProgramFragment. The 48 * Allocation must be a valid texture for the Program. The sampling 49 * of the texture will be controled by the Sampler bound at the 50 * matching slot. 51 * 52 * @param slot 53 */ 54extern void __attribute__((overloadable)) 55 rsgBindTexture(rs_program_fragment, uint slot, rs_allocation); 56 57 58extern void __attribute__((overloadable)) 59 rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *); 60extern void __attribute__((overloadable)) 61 rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *); 62extern void __attribute__((overloadable)) 63 rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *); 64 65extern void __attribute__((overloadable)) 66 rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *); 67 68/** 69 * Set the constant color for a fixed function emulation program. 70 * 71 * @param pf 72 * @param r 73 * @param g 74 * @param b 75 * @param a 76 */ 77extern void __attribute__((overloadable)) 78 rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a); 79 80/** 81 * Get the width of the current rendering surface. 82 * 83 * @return uint 84 */ 85extern uint __attribute__((overloadable)) 86 rsgGetWidth(void); 87 88/** 89 * Get the height of the current rendering surface. 90 * 91 * @return uint 92 */ 93extern uint __attribute__((overloadable)) 94 rsgGetHeight(void); 95 96 97/** 98 * Sync the contents of an allocation from its SCRIPT memory space to its HW 99 * memory spaces. 100 * 101 * @param alloc 102 */ 103extern void __attribute__((overloadable)) 104 rsgAllocationSyncAll(rs_allocation alloc); 105 106/** 107 * Low performance utility function for drawing a simple rectangle. Not 108 * intended for drawing large quantities of geometry. 109 * 110 * @param x1 111 * @param y1 112 * @param x2 113 * @param y2 114 * @param z 115 */ 116extern void __attribute__((overloadable)) 117 rsgDrawRect(float x1, float y1, float x2, float y2, float z); 118 119/** 120 * Low performance utility function for drawing a simple quad. Not intended for 121 * drawing large quantities of geometry. 122 * 123 * @param x1 124 * @param y1 125 * @param z1 126 * @param x2 127 * @param y2 128 * @param z2 129 * @param x3 130 * @param y3 131 * @param z3 132 * @param x4 133 * @param y4 134 * @param z4 135 */ 136extern void __attribute__((overloadable)) 137 rsgDrawQuad(float x1, float y1, float z1, 138 float x2, float y2, float z2, 139 float x3, float y3, float z3, 140 float x4, float y4, float z4); 141 142 143/** 144 * Low performance utility function for drawing a textured quad. Not intended 145 * for drawing large quantities of geometry. 146 * 147 * @param x1 148 * @param y1 149 * @param z1 150 * @param u1 151 * @param v1 152 * @param x2 153 * @param y2 154 * @param z2 155 * @param u2 156 * @param v2 157 * @param x3 158 * @param y3 159 * @param z3 160 * @param u3 161 * @param v3 162 * @param x4 163 * @param y4 164 * @param z4 165 * @param u4 166 * @param v4 167 */ 168extern void __attribute__((overloadable)) 169 rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1, 170 float x2, float y2, float z2, float u2, float v2, 171 float x3, float y3, float z3, float u3, float v3, 172 float x4, float y4, float z4, float u4, float v4); 173 174 175/** 176 * Low performance function for drawing rectangles in screenspace. This 177 * function uses the default passthough ProgramVertex. Any bound ProgramVertex 178 * is ignored. This function has considerable overhead and should not be used 179 * for drawing in shipping applications. 180 * 181 * @param x 182 * @param y 183 * @param z 184 * @param w 185 * @param h 186 */ 187extern void __attribute__((overloadable)) 188 rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h); 189 190/** 191 * Draw a mesh of geometry using the current context state. The whole mesh is 192 * rendered. 193 * 194 * @param ism 195 */ 196extern void __attribute__((overloadable)) 197 rsgDrawMesh(rs_mesh ism); 198extern void __attribute__((overloadable)) 199 rsgDrawMesh(rs_mesh ism, uint primitiveIndex); 200extern void __attribute__((overloadable)) 201 rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len); 202 203/** 204 * Clears the rendering surface to the specified color. 205 * 206 * @param r 207 * @param g 208 * @param b 209 * @param a 210 */ 211extern void __attribute__((overloadable)) 212 rsgClearColor(float r, float g, float b, float a); 213 214/** 215 * Clears the depth suface to the specified value. 216 * 217 */ 218extern void __attribute__((overloadable)) 219 rsgClearDepth(float value); 220 221extern void __attribute__((overloadable)) 222 rsgDrawText(const char *, int x, int y); 223extern void __attribute__((overloadable)) 224 rsgDrawText(rs_allocation, int x, int y); 225extern void __attribute__((overloadable)) 226 rsgBindFont(rs_font); 227extern void __attribute__((overloadable)) 228 rsgFontColor(float, float, float, float); 229// Returns the bounding box of the text relative to (0, 0) 230// Any of left, right, top, bottom could be NULL 231extern void __attribute__((overloadable)) 232 rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom); 233extern void __attribute__((overloadable)) 234 rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom); 235 236extern void __attribute__((overloadable)) 237 rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ, 238 float *maxX, float *maxY, float *maxZ); 239__inline__ static void __attribute__((overloadable, always_inline)) 240rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) { 241 float x1, y1, z1, x2, y2, z2; 242 rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2); 243 bBoxMin->x = x1; 244 bBoxMin->y = y1; 245 bBoxMin->z = z1; 246 bBoxMax->x = x2; 247 bBoxMax->y = y2; 248 bBoxMax->z = z2; 249} 250 251 252/** 253 * @hide 254 * Deprecated, do not use. 255 * 256 */ 257extern void __attribute__((overloadable)) color(float, float, float, float); 258 259#endif 260 261