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