/usr/share/gtk-doc/html/cogl/cogl-Vertex-Buffers.html is in libcogl-doc 1.10.0-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Vertex Buffers</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Cogl Reference Manual">
<link rel="up" href="ch01.html" title="Cogl - a modern 3D graphics API">
<link rel="prev" href="cogl-Clipping.html" title="Clipping">
<link rel="next" href="cogl-Matrices.html" title="Matrices">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="cogl-Clipping.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Cogl Reference Manual</th>
<td><a accesskey="n" href="cogl-Matrices.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#cogl-Vertex-Buffers.synopsis" class="shortcut">Top</a>
|
<a href="#cogl-Vertex-Buffers.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="cogl-Vertex-Buffers"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="cogl-Vertex-Buffers.top_of_page"></a>Vertex Buffers</span></h2>
<p>Vertex Buffers — An API for submitting extensible arrays of vertex
attributes to be mapped into the GPU for fast drawing.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="cogl-Vertex-Buffers.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis"><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="returnvalue">CoglHandle</span></a> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-new" title="cogl_vertex_buffer_new ()">cogl_vertex_buffer_new</a> (<em class="parameter"><code>unsigned <span class="type">int</span> n_vertices</code></em>);
unsigned <span class="returnvalue">int</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-get-n-vertices" title="cogl_vertex_buffer_get_n_vertices ()">cogl_vertex_buffer_get_n_vertices</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-add" title="cogl_vertex_buffer_add ()">cogl_vertex_buffer_add</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>,
<em class="parameter"><code><span class="type">guint8</span> n_components</code></em>,
<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglAttributeType" title="enum CoglAttributeType"><span class="type">CoglAttributeType</span></a> type</code></em>,
<em class="parameter"><code><span class="type">gboolean</span> normalized</code></em>,
<em class="parameter"><code><span class="type">guint16</span> stride</code></em>,
<em class="parameter"><code>const <span class="type">void</span> *pointer</code></em>);
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-delete" title="cogl_vertex_buffer_delete ()">cogl_vertex_buffer_delete</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>);
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()">cogl_vertex_buffer_submit</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-disable" title="cogl_vertex_buffer_disable ()">cogl_vertex_buffer_disable</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>);
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-enable" title="cogl_vertex_buffer_enable ()">cogl_vertex_buffer_enable</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>);
enum <a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode">CoglVerticesMode</a>;
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-draw" title="cogl_vertex_buffer_draw ()">cogl_vertex_buffer_draw</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code><a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode"><span class="type">CoglVerticesMode</span></a> mode</code></em>,
<em class="parameter"><code><span class="type">int</span> first</code></em>,
<em class="parameter"><code><span class="type">int</span> count</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-is-vertex-buffer" title="cogl_is_vertex_buffer ()">cogl_is_vertex_buffer</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);
enum <a class="link" href="cogl-Vertex-Buffers.html#CoglIndicesType" title="enum CoglIndicesType">CoglIndicesType</a>;
<a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="returnvalue">CoglHandle</span></a> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-indices-new" title="cogl_vertex_buffer_indices_new ()">cogl_vertex_buffer_indices_new</a> (<em class="parameter"><code><a class="link" href="cogl-Vertex-Buffers.html#CoglIndicesType" title="enum CoglIndicesType"><span class="type">CoglIndicesType</span></a> indices_type</code></em>,
<em class="parameter"><code>const <span class="type">void</span> *indices_array</code></em>,
<em class="parameter"><code><span class="type">int</span> indices_len</code></em>);
<span class="returnvalue">void</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-draw-elements" title="cogl_vertex_buffer_draw_elements ()">cogl_vertex_buffer_draw_elements</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code><a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode"><span class="type">CoglVerticesMode</span></a> mode</code></em>,
<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> indices</code></em>,
<em class="parameter"><code><span class="type">int</span> min_index</code></em>,
<em class="parameter"><code><span class="type">int</span> max_index</code></em>,
<em class="parameter"><code><span class="type">int</span> indices_offset</code></em>,
<em class="parameter"><code><span class="type">int</span> count</code></em>);
<a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="returnvalue">CoglHandle</span></a> <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-indices-get-for-quads" title="cogl_vertex_buffer_indices_get_for_quads ()">cogl_vertex_buffer_indices_get_for_quads</a>
(<em class="parameter"><code>unsigned <span class="type">int</span> n_indices</code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="cogl-Vertex-Buffers.html#cogl-is-vertex-buffer-indices" title="cogl_is_vertex_buffer_indices ()">cogl_is_vertex_buffer_indices</a> (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="cogl-Vertex-Buffers.description"></a><h2>Description</h2>
<p>
For example to describe a textured triangle, you could create a new cogl
vertex buffer with 3 vertices, and then you might add 2 attributes for each
vertex:
</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
a "gl_Position" describing the (x,y,z) position for each vertex.
</li>
<li class="listitem">
a "gl_MultiTexCoord0" describing the (tx,ty) texture coordinates for each
vertex.
</li>
</ol></div>
<p>
</p>
<p>
The Vertex Buffer API is designed to be a fairly raw mechanism for
developers to be able to submit geometry to Cogl in a format that can be
directly consumed by an OpenGL driver and mapped into your GPU for fast
re-use. It is designed to avoid repeated validation of the attributes by the
driver; to minimize transport costs (e.g. considering indirect GLX
use-cases) and to potentially avoid repeated format conversions when
attributes are supplied in a format that is not natively supported by the
GPU.
</p>
<p>
Although this API does allow you to modify attributes after they have been
submitted to the GPU you should be aware that modification is not that
cheap, since it implies validating the new data and potentially the
OpenGL driver will need to reformat it for the GPU.
</p>
<p>
If at all possible think of tricks that let you re-use static attributes,
and if you do need to repeatedly update attributes (e.g. for some kind of
morphing geometry) then only update and re-submit the specific attributes
that have changed.
</p>
</div>
<div class="refsect1">
<a name="cogl-Vertex-Buffers.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="cogl-vertex-buffer-new"></a><h3>cogl_vertex_buffer_new ()</h3>
<pre class="programlisting"><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="returnvalue">CoglHandle</span></a> cogl_vertex_buffer_new (<em class="parameter"><code>unsigned <span class="type">int</span> n_vertices</code></em>);</pre>
<p>
Creates a new vertex buffer that you can use to add attributes.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>n_vertices</code></em> :</span></p></td>
<td>The number of vertices that your attributes will correspond to.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a new <a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a>
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-get-n-vertices"></a><h3>cogl_vertex_buffer_get_n_vertices ()</h3>
<pre class="programlisting">unsigned <span class="returnvalue">int</span> cogl_vertex_buffer_get_n_vertices (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);</pre>
<p>
Retrieves the number of vertices that <em class="parameter"><code>handle</code></em> represents
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the number of vertices</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-add"></a><h3>cogl_vertex_buffer_add ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_add (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>,
<em class="parameter"><code><span class="type">guint8</span> n_components</code></em>,
<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglAttributeType" title="enum CoglAttributeType"><span class="type">CoglAttributeType</span></a> type</code></em>,
<em class="parameter"><code><span class="type">gboolean</span> normalized</code></em>,
<em class="parameter"><code><span class="type">guint16</span> stride</code></em>,
<em class="parameter"><code>const <span class="type">void</span> *pointer</code></em>);</pre>
<p>
Adds an attribute to a buffer, or replaces a previously added
attribute with the same name.
</p>
<p>
You either can use one of the built-in names such as "gl_Vertex", or
"gl_MultiTexCoord0" to add standard attributes, like positions, colors
and normals, or you can add custom attributes for use in shaders.
</p>
<p>
The number of vertices declared when calling <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-new" title="cogl_vertex_buffer_new ()"><code class="function">cogl_vertex_buffer_new()</code></a>
determines how many attribute values will be read from the supplied
<em class="parameter"><code>pointer</code></em>.
</p>
<p>
The data for your attribute isn't copied anywhere until you call
<a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a>, or issue a draw call which automatically
submits pending attribute changes. so the supplied pointer must remain
valid until then. If you are updating an existing attribute (done by
re-adding it) then you still need to re-call <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a>
to commit the changes to the GPU. Be carefull to minimize the number
of calls to <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a>, though.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>If you are interleving attributes it is assumed that each interleaved
attribute starts no farther than +- stride bytes from the other attributes
it is interleved with. I.e. this is ok:
<pre class="programlisting">
|-0-0-0-0-0-0-0-0-0-0|
</pre>
This is not ok:
<pre class="programlisting">
|- - - - -0-0-0-0-0-0 0 0 0 0|
</pre>
(Though you can have multiple groups of interleved attributes)</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>attribute_name</code></em> :</span></p></td>
<td>The name of your attribute. It should be a valid GLSL
variable name and standard attribute types must use one of following
built-in names: (Note: they correspond to the built-in names of GLSL)
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">"gl_Color"</li>
<li class="listitem">"gl_Normal"</li>
<li class="listitem">"gl_MultiTexCoord0, gl_MultiTexCoord1, ..."</li>
<li class="listitem">"gl_Vertex"</li>
</ul></div>
To support adding multiple variations of the same attribute the name
can have a detail component, E.g. "gl_Color::active" or
"gl_Color::inactive"</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n_components</code></em> :</span></p></td>
<td>The number of components per attribute and must be 1, 2,
3 or 4</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>a <a class="link" href="cogl-General-API.html#CoglAttributeType" title="enum CoglAttributeType"><span class="type">CoglAttributeType</span></a> specifying the data type of each component.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>normalized</code></em> :</span></p></td>
<td>If <code class="literal">TRUE</code>, this specifies that values stored in an integer
format should be mapped into the range [-1.0, 1.0] or [0.0, 1.0]
for unsigned values. If <code class="literal">FALSE</code> they are converted to floats
directly.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>stride</code></em> :</span></p></td>
<td>This specifies the number of bytes from the start of one attribute
value to the start of the next value (for the same attribute). So, for
example, with a position interleved with color like this:
XYRGBAXYRGBAXYRGBA, then if each letter represents a byte, the
stride for both attributes is 6. The special value 0 means the
values are stored sequentially in memory.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>pointer</code></em> :</span></p></td>
<td>This addresses the first attribute in the vertex array. This
must remain valid until you either call <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a> or
issue a draw call.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-delete"></a><h3>cogl_vertex_buffer_delete ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_delete (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>);</pre>
<p>
Deletes an attribute from a buffer. You will need to call
<a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a> or issue a draw call to commit this
change to the GPU.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>attribute_name</code></em> :</span></p></td>
<td>The name of a previously added attribute</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-submit"></a><h3>cogl_vertex_buffer_submit ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_submit (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);</pre>
<p>
Submits all the user added attributes to the GPU; once submitted, the
attributes can be used for drawing.
</p>
<p>
You should aim to minimize calls to this function since it implies
validating your data; it potentially incurs a transport cost (especially if
you are using GLX indirect rendering) and potentially a format conversion
cost if the GPU doesn't natively support any of the given attribute formats.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-disable"></a><h3>cogl_vertex_buffer_disable ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_disable (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>);</pre>
<p>
Disables a previosuly added attribute.
</p>
<p>
Since it can be costly to add and remove new attributes to buffers; to make
individual buffers more reuseable it is possible to enable and disable
attributes before using a buffer for drawing.
</p>
<p>
You don't need to call <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a> after using this
function.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>attribute_name</code></em> :</span></p></td>
<td>The name of the attribute you want to disable</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-enable"></a><h3>cogl_vertex_buffer_enable ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_enable (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code>const <span class="type">char</span> *attribute_name</code></em>);</pre>
<p>
Enables a previosuly disabled attribute.
</p>
<p>
Since it can be costly to add and remove new attributes to buffers; to make
individual buffers more reuseable it is possible to enable and disable
attributes before using a buffer for drawing.
</p>
<p>
You don't need to call <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-submit" title="cogl_vertex_buffer_submit ()"><code class="function">cogl_vertex_buffer_submit()</code></a> after using this function
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>attribute_name</code></em> :</span></p></td>
<td>The name of the attribute you want to enable</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="CoglVerticesMode"></a><h3>enum CoglVerticesMode</h3>
<pre class="programlisting">typedef enum {
COGL_VERTICES_MODE_POINTS = 0x0000,
COGL_VERTICES_MODE_LINES = 0x0001,
COGL_VERTICES_MODE_LINE_LOOP = 0x0002,
COGL_VERTICES_MODE_LINE_STRIP = 0x0003,
COGL_VERTICES_MODE_TRIANGLES = 0x0004,
COGL_VERTICES_MODE_TRIANGLE_STRIP = 0x0005,
COGL_VERTICES_MODE_TRIANGLE_FAN = 0x0006
} CoglVerticesMode;
</pre>
<p>
Different ways of interpreting vertices when drawing.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="COGL-VERTICES-MODE-POINTS:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_POINTS</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_POINTS</code>
</td>
</tr>
<tr>
<td><p><a name="COGL-VERTICES-MODE-LINES:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_LINES</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_LINES</code>
</td>
</tr>
<tr>
<td><p><a name="COGL-VERTICES-MODE-LINE-LOOP:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_LINE_LOOP</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_LINE_LOOP</code>
</td>
</tr>
<tr>
<td><p><a name="COGL-VERTICES-MODE-LINE-STRIP:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_LINE_STRIP</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_LINE_STRIP</code>
</td>
</tr>
<tr>
<td><p><a name="COGL-VERTICES-MODE-TRIANGLES:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_TRIANGLES</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_TRIANGLES</code>
</td>
</tr>
<tr>
<td><p><a name="COGL-VERTICES-MODE-TRIANGLE-STRIP:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_TRIANGLE_STRIP</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_TRIANGLE_STRIP</code>
</td>
</tr>
<tr>
<td><p><a name="COGL-VERTICES-MODE-TRIANGLE-FAN:CAPS"></a><span class="term"><code class="literal">COGL_VERTICES_MODE_TRIANGLE_FAN</code></span></p></td>
<td>FIXME, equivalent to <code class="literal">GL_TRIANGLE_FAN</code>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 1.0</p>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-draw"></a><h3>cogl_vertex_buffer_draw ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_draw (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code><a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode"><span class="type">CoglVerticesMode</span></a> mode</code></em>,
<em class="parameter"><code><span class="type">int</span> first</code></em>,
<em class="parameter"><code><span class="type">int</span> count</code></em>);</pre>
<p>
Allows you to draw geometry using all or a subset of the
vertices in a vertex buffer.
</p>
<p>
Any un-submitted attribute changes are automatically submitted before
drawing.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
<td>A <a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode"><span class="type">CoglVerticesMode</span></a> specifying how the vertices should be
interpreted.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>first</code></em> :</span></p></td>
<td>Specifies the index of the first vertex you want to draw with</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td>
<td>Specifies the number of vertices you want to draw.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-is-vertex-buffer"></a><h3>cogl_is_vertex_buffer ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> cogl_is_vertex_buffer (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);</pre>
<p>
Checks whether <em class="parameter"><code>handle</code></em> is a Vertex Buffer Object
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>a <a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> for a vertex buffer object</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> if the handle is a VBO, and <code class="literal">FALSE</code>
otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 1.0</p>
</div>
<hr>
<div class="refsect2">
<a name="CoglIndicesType"></a><h3>enum CoglIndicesType</h3>
<pre class="programlisting">typedef enum {
COGL_INDICES_TYPE_UNSIGNED_BYTE,
COGL_INDICES_TYPE_UNSIGNED_SHORT,
COGL_INDICES_TYPE_UNSIGNED_INT
} CoglIndicesType;
</pre>
<p>
You should aim to use the smallest data type that gives you enough
range, since it reduces the size of your index array and can help
reduce the demand on memory bandwidth.
</p>
<p>
Note that <a class="link" href="cogl-Vertex-Buffers.html#COGL-INDICES-TYPE-UNSIGNED-INT:CAPS"><code class="literal">COGL_INDICES_TYPE_UNSIGNED_INT</code></a> is only supported if the
<a class="link" href="cogl-General-API.html#COGL-FEATURE-UNSIGNED-INT-INDICES:CAPS"><code class="literal">COGL_FEATURE_UNSIGNED_INT_INDICES</code></a> feature is available. This
should always be available on OpenGL but on OpenGL ES it will only
be available if the GL_OES_element_index_uint extension is
advertized.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="COGL-INDICES-TYPE-UNSIGNED-BYTE:CAPS"></a><span class="term"><code class="literal">COGL_INDICES_TYPE_UNSIGNED_BYTE</code></span></p></td>
<td>Your indices are unsigned bytes
</td>
</tr>
<tr>
<td><p><a name="COGL-INDICES-TYPE-UNSIGNED-SHORT:CAPS"></a><span class="term"><code class="literal">COGL_INDICES_TYPE_UNSIGNED_SHORT</code></span></p></td>
<td>Your indices are unsigned shorts
</td>
</tr>
<tr>
<td><p><a name="COGL-INDICES-TYPE-UNSIGNED-INT:CAPS"></a><span class="term"><code class="literal">COGL_INDICES_TYPE_UNSIGNED_INT</code></span></p></td>
<td>Your indices are unsigned ints
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-indices-new"></a><h3>cogl_vertex_buffer_indices_new ()</h3>
<pre class="programlisting"><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="returnvalue">CoglHandle</span></a> cogl_vertex_buffer_indices_new (<em class="parameter"><code><a class="link" href="cogl-Vertex-Buffers.html#CoglIndicesType" title="enum CoglIndicesType"><span class="type">CoglIndicesType</span></a> indices_type</code></em>,
<em class="parameter"><code>const <span class="type">void</span> *indices_array</code></em>,
<em class="parameter"><code><span class="type">int</span> indices_len</code></em>);</pre>
<p>
Depending on how much geometry you are submitting it can be worthwhile
optimizing the number of redundant vertices you submit. Using an index
array allows you to reference vertices multiple times, for example
during triangle strips.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>indices_type</code></em> :</span></p></td>
<td>a <a class="link" href="cogl-Vertex-Buffers.html#CoglIndicesType" title="enum CoglIndicesType"><span class="type">CoglIndicesType</span></a> specifying the data type used for
the indices.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>indices_array</code></em> :</span></p></td>
<td>Specifies the address of
your array of indices. <span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=indices_len]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>indices_len</code></em> :</span></p></td>
<td>The number of indices in indices_array</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A CoglHandle for the indices which you can pass to
<a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-draw-elements" title="cogl_vertex_buffer_draw_elements ()"><code class="function">cogl_vertex_buffer_draw_elements()</code></a>.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-draw-elements"></a><h3>cogl_vertex_buffer_draw_elements ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> cogl_vertex_buffer_draw_elements (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>,
<em class="parameter"><code><a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode"><span class="type">CoglVerticesMode</span></a> mode</code></em>,
<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> indices</code></em>,
<em class="parameter"><code><span class="type">int</span> min_index</code></em>,
<em class="parameter"><code><span class="type">int</span> max_index</code></em>,
<em class="parameter"><code><span class="type">int</span> indices_offset</code></em>,
<em class="parameter"><code><span class="type">int</span> count</code></em>);</pre>
<p>
This function lets you use an array of indices to specify the vertices
within your vertex buffer that you want to draw. The indices themselves
are created by calling <a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-indices-new" title="cogl_vertex_buffer_indices_new ()"><code class="function">cogl_vertex_buffer_indices_new()</code></a>
</p>
<p>
Any un-submitted attribute changes are automatically submitted before
drawing.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>A vertex buffer handle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
<td>A <a class="link" href="cogl-Vertex-Buffers.html#CoglVerticesMode" title="enum CoglVerticesMode"><span class="type">CoglVerticesMode</span></a> specifying how the vertices should be
interpreted.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>indices</code></em> :</span></p></td>
<td>A CoglHandle for a set of indices allocated via
<a class="link" href="cogl-Vertex-Buffers.html#cogl-vertex-buffer-indices-new" title="cogl_vertex_buffer_indices_new ()"><code class="function">cogl_vertex_buffer_indices_new()</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>min_index</code></em> :</span></p></td>
<td>Specifies the minimum vertex index contained in indices</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>max_index</code></em> :</span></p></td>
<td>Specifies the maximum vertex index contained in indices</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>indices_offset</code></em> :</span></p></td>
<td>An offset into named indices. The offset marks the first
index to use for drawing.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>count</code></em> :</span></p></td>
<td>Specifies the number of vertices you want to draw.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-vertex-buffer-indices-get-for-quads"></a><h3>cogl_vertex_buffer_indices_get_for_quads ()</h3>
<pre class="programlisting"><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="returnvalue">CoglHandle</span></a> cogl_vertex_buffer_indices_get_for_quads
(<em class="parameter"><code>unsigned <span class="type">int</span> n_indices</code></em>);</pre>
<p>
Creates a vertex buffer containing the indices needed to draw pairs
of triangles from a list of vertices grouped as quads. There will
be at least <em class="parameter"><code>n_indices</code></em> entries in the buffer (but there may be
more).
</p>
<p>
The indices will follow this pattern:
</p>
<p>
0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7 ... etc
</p>
<p>
For example, if you submit vertices for a quad like like that shown
in <a class="xref" href="cogl-Vertex-Buffers.html#quad-indices-order" title="Figure 4. Example of vertices submitted to form a quad">Figure 4, “Example of vertices submitted to form a quad”</a> then you can request 6
indices to render two triangles like those shown in <a class="xref" href="cogl-Vertex-Buffers.html#quad-indices-triangles" title="Figure 5. Illustration of the triangle indices that will be generated">Figure 5, “Illustration of the triangle indices that will be generated”</a>.
</p>
<p>
</p>
<div class="figure">
<a name="quad-indices-order"></a><p class="title"><b>Figure 4. Example of vertices submitted to form a quad</b></p>
<div class="figure-contents"><div><img src="quad-indices-order.png" alt="Example of vertices submitted to form a quad"></div></div>
</div>
<p><br class="figure-break">
</p>
<p>
</p>
<div class="figure">
<a name="quad-indices-triangles"></a><p class="title"><b>Figure 5. Illustration of the triangle indices that will be generated</b></p>
<div class="figure-contents"><div><img src="quad-indices-triangles.png" alt="Illustration of the triangle indices that will be generated"></div></div>
</div>
<p><br class="figure-break">
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>n_indices</code></em> :</span></p></td>
<td>the number of indices in the vertex buffer.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A <a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><code class="literal">CoglHandle</code></a> containing the indices. The handled is
owned by Cogl and should not be modified or unref'd.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="cogl-is-vertex-buffer-indices"></a><h3>cogl_is_vertex_buffer_indices ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> cogl_is_vertex_buffer_indices (<em class="parameter"><code><a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a> handle</code></em>);</pre>
<p>
Checks whether <em class="parameter"><code>handle</code></em> is a handle to the indices for a vertex
buffer object
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>handle</code></em> :</span></p></td>
<td>a <a class="link" href="cogl-General-API.html#CoglHandle" title="CoglHandle"><span class="type">CoglHandle</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<code class="literal">TRUE</code> if the handle is indices, and <code class="literal">FALSE</code>
otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 1.4</p>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.18</div>
</body>
</html>
|