Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /** @file rs_graphics.rsh |
| 18 | * \brief Renderscript graphics API |
| 19 | * |
| 20 | * A set of graphics functions used by Renderscript. |
| 21 | * |
| 22 | */ |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 23 | #ifndef __RS_GRAPHICS_RSH__ |
| 24 | #define __RS_GRAPHICS_RSH__ |
| 25 | |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 26 | // These are API 15 once it get official |
| 27 | typedef enum { |
| 28 | RS_DEPTH_FUNC_ALWAYS, |
| 29 | RS_DEPTH_FUNC_LESS, |
| 30 | RS_DEPTH_FUNC_LEQUAL, |
| 31 | RS_DEPTH_FUNC_GREATER, |
| 32 | RS_DEPTH_FUNC_GEQUAL, |
| 33 | RS_DEPTH_FUNC_EQUAL, |
| 34 | RS_DEPTH_FUNC_NOTEQUAL |
| 35 | } rs_depth_func; |
| 36 | |
| 37 | typedef enum { |
| 38 | RS_BLEND_SRC_ZERO, // 0 |
| 39 | RS_BLEND_SRC_ONE, // 1 |
| 40 | RS_BLEND_SRC_DST_COLOR, // 2 |
| 41 | RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3 |
| 42 | RS_BLEND_SRC_SRC_ALPHA, // 4 |
| 43 | RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5 |
| 44 | RS_BLEND_SRC_DST_ALPHA, // 6 |
| 45 | RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7 |
| 46 | RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8 |
| 47 | } rs_blend_src_func; |
| 48 | |
| 49 | typedef enum { |
| 50 | RS_BLEND_DST_ZERO, // 0 |
| 51 | RS_BLEND_DST_ONE, // 1 |
| 52 | RS_BLEND_DST_SRC_COLOR, // 2 |
| 53 | RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3 |
| 54 | RS_BLEND_DST_SRC_ALPHA, // 4 |
| 55 | RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5 |
| 56 | RS_BLEND_DST_DST_ALPHA, // 6 |
| 57 | RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7 |
| 58 | } rs_blend_dst_func; |
| 59 | |
| 60 | typedef enum { |
| 61 | RS_CULL_BACK, |
| 62 | RS_CULL_FRONT, |
| 63 | RS_CULL_NONE |
| 64 | } rs_cull_mode; |
| 65 | |
| 66 | typedef enum { |
| 67 | RS_SAMPLER_NEAREST, |
| 68 | RS_SAMPLER_LINEAR, |
| 69 | RS_SAMPLER_LINEAR_MIP_LINEAR, |
| 70 | RS_SAMPLER_WRAP, |
| 71 | RS_SAMPLER_CLAMP, |
| 72 | RS_SAMPLER_LINEAR_MIP_NEAREST, |
| 73 | } rs_sampler_value; |
| 74 | |
Alex Sakhartchouk | 4325387 | 2011-09-28 15:23:18 -0700 | [diff] [blame] | 75 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 76 | /** |
| 77 | * Set the color target used for all subsequent rendering calls |
| 78 | * @param colorTarget |
| 79 | * @param slot |
| 80 | */ |
| 81 | extern void __attribute__((overloadable)) |
| 82 | rsgBindColorTarget(rs_allocation colorTarget, uint slot); |
| 83 | |
| 84 | /** |
| 85 | * Clear the previously set color target |
| 86 | * @param slot |
| 87 | */ |
| 88 | extern void __attribute__((overloadable)) |
| 89 | rsgClearColorTarget(uint slot); |
| 90 | |
| 91 | /** |
| 92 | * Set the depth target used for all subsequent rendering calls |
| 93 | * @param depthTarget |
| 94 | */ |
| 95 | extern void __attribute__((overloadable)) |
| 96 | rsgBindDepthTarget(rs_allocation depthTarget); |
| 97 | |
| 98 | /** |
| 99 | * Clear the previously set depth target |
| 100 | */ |
| 101 | extern void __attribute__((overloadable)) |
| 102 | rsgClearDepthTarget(void); |
| 103 | |
| 104 | /** |
| 105 | * Clear all color and depth targets and resume rendering into |
| 106 | * the framebuffer |
| 107 | */ |
| 108 | extern void __attribute__((overloadable)) |
| 109 | rsgClearAllRenderTargets(void); |
| 110 | |
| 111 | /** |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 112 | * Force Renderscript to finish all rendering commands |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 113 | */ |
| 114 | extern uint __attribute__((overloadable)) |
| 115 | rsgFinish(void); |
Jason Sams | f2bcce7 | 2010-03-26 15:33:42 -0700 | [diff] [blame] | 116 | |
Alex Sakhartchouk | 4325387 | 2011-09-28 15:23:18 -0700 | [diff] [blame] | 117 | #endif //defined(RS_VERSION) && (RS_VERSION >= 14) |
| 118 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 119 | /** |
| 120 | * Bind a new ProgramFragment to the rendering context. |
| 121 | * |
| 122 | * @param pf |
| 123 | */ |
| 124 | extern void __attribute__((overloadable)) |
| 125 | rsgBindProgramFragment(rs_program_fragment pf); |
| 126 | |
| 127 | /** |
| 128 | * Bind a new ProgramStore to the rendering context. |
| 129 | * |
| 130 | * @param ps |
| 131 | */ |
| 132 | extern void __attribute__((overloadable)) |
| 133 | rsgBindProgramStore(rs_program_store ps); |
| 134 | |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * @hide |
| 138 | * Get program store depth function |
| 139 | * |
| 140 | * @param ps |
| 141 | */ |
| 142 | extern rs_depth_func __attribute__((overloadable)) |
| 143 | rsgProgramStoreGetDepthFunc(rs_program_store ps); |
| 144 | |
| 145 | /** |
| 146 | * @hide |
| 147 | * Get program store depth mask |
| 148 | * |
| 149 | * @param ps |
| 150 | */ |
| 151 | extern bool __attribute__((overloadable)) |
| 152 | rsgProgramStoreGetDepthMask(rs_program_store ps); |
| 153 | /** |
| 154 | * @hide |
| 155 | * Get program store red component color mask |
| 156 | * |
| 157 | * @param ps |
| 158 | */ |
| 159 | extern bool __attribute__((overloadable)) |
| 160 | rsgProgramStoreGetColorMaskR(rs_program_store ps); |
| 161 | |
| 162 | /** |
| 163 | * @hide |
| 164 | * Get program store green component color mask |
| 165 | * |
| 166 | * @param ps |
| 167 | */ |
| 168 | extern bool __attribute__((overloadable)) |
| 169 | rsgProgramStoreGetColorMaskG(rs_program_store ps); |
| 170 | |
| 171 | /** |
| 172 | * @hide |
| 173 | * Get program store blur component color mask |
| 174 | * |
| 175 | * @param ps |
| 176 | */ |
| 177 | extern bool __attribute__((overloadable)) |
| 178 | rsgProgramStoreGetColorMaskB(rs_program_store ps); |
| 179 | |
| 180 | /** |
| 181 | * @hide |
| 182 | * Get program store alpha component color mask |
| 183 | * |
| 184 | * @param ps |
| 185 | */ |
| 186 | extern bool __attribute__((overloadable)) |
| 187 | rsgProgramStoreGetColorMaskA(rs_program_store ps); |
| 188 | |
| 189 | /** |
| 190 | * @hide |
| 191 | * Get program store blend source function |
| 192 | * |
| 193 | * @param ps |
| 194 | */ |
| 195 | extern rs_blend_src_func __attribute__((overloadable)) |
| 196 | rsgProgramStoreGetBlendSrcFunc(rs_program_store ps); |
| 197 | |
| 198 | /** |
| 199 | * @hide |
| 200 | * Get program store blend destination function |
| 201 | * |
| 202 | * @param ps |
| 203 | */ |
| 204 | extern rs_blend_dst_func __attribute__((overloadable)) |
| 205 | rsgProgramStoreGetBlendDstFunc(rs_program_store ps); |
| 206 | |
| 207 | /** |
| 208 | * @hide |
| 209 | * Get program store dither state |
| 210 | * |
| 211 | * @param ps |
| 212 | */ |
| 213 | extern bool __attribute__((overloadable)) |
| 214 | rsgProgramStoreGetDitherEnabled(rs_program_store ps); |
| 215 | |
| 216 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 217 | /** |
| 218 | * Bind a new ProgramVertex to the rendering context. |
| 219 | * |
| 220 | * @param pv |
| 221 | */ |
| 222 | extern void __attribute__((overloadable)) |
| 223 | rsgBindProgramVertex(rs_program_vertex pv); |
| 224 | |
| 225 | /** |
| 226 | * Bind a new ProgramRaster to the rendering context. |
| 227 | * |
| 228 | * @param pr |
| 229 | */ |
| 230 | extern void __attribute__((overloadable)) |
| 231 | rsgBindProgramRaster(rs_program_raster pr); |
| 232 | |
| 233 | /** |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 234 | * @hide |
| 235 | * Get program raster point sprite state |
| 236 | * |
| 237 | * @param pr |
| 238 | */ |
| 239 | extern bool __attribute__((overloadable)) |
| 240 | rsgProgramRasterGetPointSpriteEnabled(rs_program_raster pr); |
| 241 | |
| 242 | /** |
| 243 | * @hide |
| 244 | * Get program raster cull mode |
| 245 | * |
| 246 | * @param pr |
| 247 | */ |
| 248 | extern rs_cull_mode __attribute__((overloadable)) |
| 249 | rsgProgramRasterGetCullMode(rs_program_raster pr); |
| 250 | |
| 251 | /** |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 252 | * Bind a new Sampler object to a ProgramFragment. The sampler will |
| 253 | * operate on the texture bound at the matching slot. |
| 254 | * |
| 255 | * @param slot |
| 256 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 257 | extern void __attribute__((overloadable)) |
| 258 | rsgBindSampler(rs_program_fragment, uint slot, rs_sampler); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 259 | |
| 260 | /** |
Alex Sakhartchouk | 407f8ca | 2011-09-23 17:05:04 -0700 | [diff] [blame] | 261 | * @hide |
| 262 | * Get sampler minification value |
| 263 | * |
| 264 | * @param pr |
| 265 | */ |
| 266 | extern rs_sampler_value __attribute__((overloadable)) |
| 267 | rsgSamplerGetMinification(rs_sampler s); |
| 268 | |
| 269 | /** |
| 270 | * @hide |
| 271 | * Get sampler magnification value |
| 272 | * |
| 273 | * @param pr |
| 274 | */ |
| 275 | extern rs_sampler_value __attribute__((overloadable)) |
| 276 | rsgSamplerGetMagnification(rs_sampler s); |
| 277 | |
| 278 | /** |
| 279 | * @hide |
| 280 | * Get sampler wrap S value |
| 281 | * |
| 282 | * @param pr |
| 283 | */ |
| 284 | extern rs_sampler_value __attribute__((overloadable)) |
| 285 | rsgSamplerGetWrapS(rs_sampler s); |
| 286 | |
| 287 | /** |
| 288 | * @hide |
| 289 | * Get sampler wrap T value |
| 290 | * |
| 291 | * @param pr |
| 292 | */ |
| 293 | extern rs_sampler_value __attribute__((overloadable)) |
| 294 | rsgSamplerGetWrapT(rs_sampler s); |
| 295 | |
| 296 | /** |
| 297 | * @hide |
| 298 | * Get sampler anisotropy |
| 299 | * |
| 300 | * @param pr |
| 301 | */ |
| 302 | extern float __attribute__((overloadable)) |
| 303 | rsgSamplerGetAnisotropy(rs_sampler s); |
| 304 | |
| 305 | /** |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 306 | * Bind a new Allocation object to a ProgramFragment. The |
| 307 | * Allocation must be a valid texture for the Program. The sampling |
| 308 | * of the texture will be controled by the Sampler bound at the |
| 309 | * matching slot. |
| 310 | * |
| 311 | * @param slot |
| 312 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 313 | extern void __attribute__((overloadable)) |
| 314 | rsgBindTexture(rs_program_fragment, uint slot, rs_allocation); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 315 | |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 316 | /** |
| 317 | * Load the projection matrix for a currently bound fixed function |
| 318 | * vertex program. Calling this function with a custom vertex shader |
| 319 | * would result in an error. |
| 320 | * @param proj projection matrix |
| 321 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 322 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 323 | rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *proj); |
| 324 | /** |
| 325 | * Load the model matrix for a currently bound fixed function |
| 326 | * vertex program. Calling this function with a custom vertex shader |
| 327 | * would result in an error. |
| 328 | * @param model model matrix |
| 329 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 330 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 331 | rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *model); |
| 332 | /** |
| 333 | * Load the texture matrix for a currently bound fixed function |
| 334 | * vertex program. Calling this function with a custom vertex shader |
| 335 | * would result in an error. |
| 336 | * @param tex texture matrix |
| 337 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 338 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 339 | rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *tex); |
| 340 | /** |
| 341 | * Get the projection matrix for a currently bound fixed function |
| 342 | * vertex program. Calling this function with a custom vertex shader |
| 343 | * would result in an error. |
| 344 | * @param proj matrix to store the current projection matrix into |
| 345 | */ |
Jason Sams | 6445e52 | 2010-08-04 17:50:20 -0700 | [diff] [blame] | 346 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 347 | rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *proj); |
Alex Sakhartchouk | 95333f9 | 2010-08-16 17:40:10 -0700 | [diff] [blame] | 348 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 349 | /** |
| 350 | * Set the constant color for a fixed function emulation program. |
| 351 | * |
| 352 | * @param pf |
| 353 | * @param r |
| 354 | * @param g |
| 355 | * @param b |
| 356 | * @param a |
| 357 | */ |
Alex Sakhartchouk | 95333f9 | 2010-08-16 17:40:10 -0700 | [diff] [blame] | 358 | extern void __attribute__((overloadable)) |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 359 | 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] | 360 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 361 | /** |
| 362 | * Get the width of the current rendering surface. |
| 363 | * |
| 364 | * @return uint |
| 365 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 366 | extern uint __attribute__((overloadable)) |
| 367 | rsgGetWidth(void); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 368 | |
| 369 | /** |
| 370 | * Get the height of the current rendering surface. |
| 371 | * |
| 372 | * @return uint |
| 373 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 374 | extern uint __attribute__((overloadable)) |
| 375 | rsgGetHeight(void); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 376 | |
Jason Sams | b7e83bd | 2010-12-15 01:41:00 -0800 | [diff] [blame] | 377 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 378 | /** |
| 379 | * Sync the contents of an allocation from its SCRIPT memory space to its HW |
| 380 | * memory spaces. |
| 381 | * |
| 382 | * @param alloc |
| 383 | */ |
| 384 | extern void __attribute__((overloadable)) |
| 385 | rsgAllocationSyncAll(rs_allocation alloc); |
| 386 | |
Alex Sakhartchouk | 4325387 | 2011-09-28 15:23:18 -0700 | [diff] [blame] | 387 | #if (defined(RS_VERSION) && (RS_VERSION >= 14)) |
| 388 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 389 | /** |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 390 | * Sync the contents of an allocation from memory space |
| 391 | * specified by source. |
| 392 | * |
| 393 | * @param alloc |
| 394 | * @param source |
| 395 | */ |
| 396 | extern void __attribute__((overloadable)) |
| 397 | rsgAllocationSyncAll(rs_allocation alloc, |
| 398 | rs_allocation_usage_type source); |
| 399 | |
Alex Sakhartchouk | 4325387 | 2011-09-28 15:23:18 -0700 | [diff] [blame] | 400 | #endif //defined(RS_VERSION) && (RS_VERSION >= 14) |
| 401 | |
Alex Sakhartchouk | 74a8279 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 402 | /** |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 403 | * Low performance utility function for drawing a simple rectangle. Not |
| 404 | * intended for drawing large quantities of geometry. |
| 405 | * |
| 406 | * @param x1 |
| 407 | * @param y1 |
| 408 | * @param x2 |
| 409 | * @param y2 |
| 410 | * @param z |
| 411 | */ |
Jason Sams | b7e83bd | 2010-12-15 01:41:00 -0800 | [diff] [blame] | 412 | extern void __attribute__((overloadable)) |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 413 | rsgDrawRect(float x1, float y1, float x2, float y2, float z); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 414 | |
| 415 | /** |
| 416 | * Low performance utility function for drawing a simple quad. Not intended for |
| 417 | * drawing large quantities of geometry. |
| 418 | * |
| 419 | * @param x1 |
| 420 | * @param y1 |
| 421 | * @param z1 |
| 422 | * @param x2 |
| 423 | * @param y2 |
| 424 | * @param z2 |
| 425 | * @param x3 |
| 426 | * @param y3 |
| 427 | * @param z3 |
| 428 | * @param x4 |
| 429 | * @param y4 |
| 430 | * @param z4 |
| 431 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 432 | extern void __attribute__((overloadable)) |
| 433 | rsgDrawQuad(float x1, float y1, float z1, |
| 434 | float x2, float y2, float z2, |
| 435 | float x3, float y3, float z3, |
| 436 | float x4, float y4, float z4); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 437 | |
| 438 | |
| 439 | /** |
| 440 | * Low performance utility function for drawing a textured quad. Not intended |
| 441 | * for drawing large quantities of geometry. |
| 442 | * |
| 443 | * @param x1 |
| 444 | * @param y1 |
| 445 | * @param z1 |
| 446 | * @param u1 |
| 447 | * @param v1 |
| 448 | * @param x2 |
| 449 | * @param y2 |
| 450 | * @param z2 |
| 451 | * @param u2 |
| 452 | * @param v2 |
| 453 | * @param x3 |
| 454 | * @param y3 |
| 455 | * @param z3 |
| 456 | * @param u3 |
| 457 | * @param v3 |
| 458 | * @param x4 |
| 459 | * @param y4 |
| 460 | * @param z4 |
| 461 | * @param u4 |
| 462 | * @param v4 |
| 463 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 464 | extern void __attribute__((overloadable)) |
| 465 | rsgDrawQuadTexCoords(float x1, float y1, float z1, float u1, float v1, |
| 466 | float x2, float y2, float z2, float u2, float v2, |
| 467 | float x3, float y3, float z3, float u3, float v3, |
| 468 | float x4, float y4, float z4, float u4, float v4); |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 469 | |
| 470 | |
| 471 | /** |
| 472 | * Low performance function for drawing rectangles in screenspace. This |
| 473 | * function uses the default passthough ProgramVertex. Any bound ProgramVertex |
| 474 | * is ignored. This function has considerable overhead and should not be used |
| 475 | * for drawing in shipping applications. |
| 476 | * |
| 477 | * @param x |
| 478 | * @param y |
| 479 | * @param z |
| 480 | * @param w |
| 481 | * @param h |
| 482 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 483 | extern void __attribute__((overloadable)) |
| 484 | rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h); |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 485 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 486 | /** |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 487 | * Draw a mesh using the current context state. The whole mesh is |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 488 | * rendered. |
| 489 | * |
| 490 | * @param ism |
| 491 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 492 | extern void __attribute__((overloadable)) |
| 493 | rsgDrawMesh(rs_mesh ism); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 494 | /** |
| 495 | * Draw part of a mesh using the current context state. |
| 496 | * @param ism mesh object to render |
| 497 | * @param primitiveIndex for meshes that contain multiple primitive groups |
| 498 | * this parameter specifies the index of the group to draw. |
| 499 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 500 | extern void __attribute__((overloadable)) |
| 501 | rsgDrawMesh(rs_mesh ism, uint primitiveIndex); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 502 | /** |
| 503 | * Draw specified index range of part of a mesh using the current context state. |
| 504 | * @param ism mesh object to render |
| 505 | * @param primitiveIndex for meshes that contain multiple primitive groups |
| 506 | * this parameter specifies the index of the group to draw. |
| 507 | * @param start starting index in the range |
| 508 | * @param len number of indices to draw |
| 509 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 510 | extern void __attribute__((overloadable)) |
| 511 | rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len); |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 512 | |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 513 | /** |
| 514 | * Clears the rendering surface to the specified color. |
| 515 | * |
| 516 | * @param r |
| 517 | * @param g |
| 518 | * @param b |
| 519 | * @param a |
| 520 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 521 | extern void __attribute__((overloadable)) |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 522 | rsgClearColor(float r, float g, float b, float a); |
| 523 | |
| 524 | /** |
| 525 | * Clears the depth suface to the specified value. |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 526 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 527 | extern void __attribute__((overloadable)) |
Jason Sams | 09aeb8a | 2011-01-28 15:49:07 -0800 | [diff] [blame] | 528 | rsgClearDepth(float value); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 529 | /** |
| 530 | * Draws text given a string and location |
| 531 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 532 | extern void __attribute__((overloadable)) |
| 533 | rsgDrawText(const char *, int x, int y); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 534 | /** |
| 535 | * \overload |
| 536 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 537 | extern void __attribute__((overloadable)) |
| 538 | rsgDrawText(rs_allocation, int x, int y); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 539 | /** |
| 540 | * Binds the font object to be used for all subsequent font rendering calls |
| 541 | * @param font object to bind |
| 542 | */ |
Jason Sams | 7349547 | 2010-07-29 17:31:14 -0700 | [diff] [blame] | 543 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 544 | rsgBindFont(rs_font font); |
| 545 | /** |
| 546 | * Sets the font color for all subsequent rendering calls |
| 547 | * @param r red component |
| 548 | * @param g green component |
| 549 | * @param b blue component |
| 550 | * @param a alpha component |
| 551 | */ |
Alex Sakhartchouk | 9fc9f03 | 2010-08-04 14:45:48 -0700 | [diff] [blame] | 552 | extern void __attribute__((overloadable)) |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 553 | rsgFontColor(float r, float g, float b, float a); |
| 554 | /** |
| 555 | * Returns the bounding box of the text relative to (0, 0) |
| 556 | * Any of left, right, top, bottom could be NULL |
| 557 | */ |
Alex Sakhartchouk | 09c6735 | 2010-10-05 11:33:27 -0700 | [diff] [blame] | 558 | extern void __attribute__((overloadable)) |
| 559 | rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 560 | /** |
| 561 | * \overload |
| 562 | */ |
Alex Sakhartchouk | 09c6735 | 2010-10-05 11:33:27 -0700 | [diff] [blame] | 563 | extern void __attribute__((overloadable)) |
| 564 | rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 565 | /** |
| 566 | * Computes an axis aligned bounding box of a mesh object |
| 567 | */ |
Alex Sakhartchouk | ba4aa5c | 2010-08-13 14:32:23 -0700 | [diff] [blame] | 568 | extern void __attribute__((overloadable)) |
| 569 | rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ, |
| 570 | float *maxX, float *maxY, float *maxZ); |
Alex Sakhartchouk | 9996b75 | 2011-08-09 11:36:19 -0700 | [diff] [blame] | 571 | /** |
| 572 | * \overload |
| 573 | */ |
Jason Sams | 399dc9e | 2010-10-15 17:57:07 -0700 | [diff] [blame] | 574 | __inline__ static void __attribute__((overloadable, always_inline)) |
Alex Sakhartchouk | ba4aa5c | 2010-08-13 14:32:23 -0700 | [diff] [blame] | 575 | rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) { |
| 576 | float x1, y1, z1, x2, y2, z2; |
| 577 | rsgMeshComputeBoundingBox(mesh, &x1, &y1, &z1, &x2, &y2, &z2); |
| 578 | bBoxMin->x = x1; |
| 579 | bBoxMin->y = y1; |
| 580 | bBoxMin->z = z1; |
| 581 | bBoxMax->x = x2; |
| 582 | bBoxMax->y = y2; |
| 583 | bBoxMax->z = z2; |
| 584 | } |
| 585 | |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 586 | #endif |
Jason Sams | 51f36ab | 2010-03-18 14:36:05 -0700 | [diff] [blame] | 587 | |