OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="d-graphics"> | 3 <section id="d-graphics"> |
4 <span id="devguide-coding-3d-graphics"></span><h1 id="d-graphics"><span id="devg
uide-coding-3d-graphics"></span>3D Graphics</h1> | 4 <span id="devguide-coding-3d-graphics"></span><h1 id="d-graphics"><span id="devg
uide-coding-3d-graphics"></span>3D Graphics</h1> |
5 <p>Native Client applications use the <a class="reference external" href="http:/
/en.wikipedia.org/wiki/OpenGL_ES">OpenGL ES 2.0</a> API for 3D rendering. This d
ocument | 5 <p>Native Client applications use the <a class="reference external" href="http:/
/en.wikipedia.org/wiki/OpenGL_ES">OpenGL ES 2.0</a> API for 3D rendering. This d
ocument |
6 describes how to call the OpenGL ES 2.0 interface in a Native Client module and | 6 describes how to call the OpenGL ES 2.0 interface in a Native Client module and |
7 how to build an efficient rendering loop. It also explains how to validate GPU | 7 how to build an efficient rendering loop. It also explains how to validate GPU |
8 drivers and test for specific GPU capabilities, and provides tips to help ensure | 8 drivers and test for specific GPU capabilities, and provides tips to help ensure |
9 your rendering code runs efficiently.</p> | 9 your rendering code runs efficiently.</p> |
10 <aside class="note"> | 10 <aside class="note"> |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 </ul> | 387 </ul> |
388 <h3 id="don-ts">Don’ts</h3> | 388 <h3 id="don-ts">Don’ts</h3> |
389 <ul class="small-gap"> | 389 <ul class="small-gap"> |
390 <li><strong>Don’t use client side buffers.</strong> OpenGL ES 2.0 can use
client side data with | 390 <li><strong>Don’t use client side buffers.</strong> OpenGL ES 2.0 can use
client side data with |
391 <code>glVertexAttribPointer</code> and <code>glDrawElements</code>, but this is
really slow. Try | 391 <code>glVertexAttribPointer</code> and <code>glDrawElements</code>, but this is
really slow. Try |
392 to avoid client side buffers. Use Vertex Buffer Objects (VBOs) instead.</li> | 392 to avoid client side buffers. Use Vertex Buffer Objects (VBOs) instead.</li> |
393 <li><strong>Don’t mix vertex data and index data.</strong> By default, Pep
per 3D binds buffers | 393 <li><strong>Don’t mix vertex data and index data.</strong> By default, Pep
per 3D binds buffers |
394 to a single point. You could create a buffer and bind it to both | 394 to a single point. You could create a buffer and bind it to both |
395 <code>GL_ARRAY_BUFFER</code> and <code>GL_ELEMENT_ARRAY_BUFFER</code>, but that
would be | 395 <code>GL_ARRAY_BUFFER</code> and <code>GL_ELEMENT_ARRAY_BUFFER</code>, but that
would be |
396 expensive overhead and it is not recommended.</li> | 396 expensive overhead and it is not recommended.</li> |
397 <li><strong>Don’t call ``glGet*`` or ``glCheck*`` during rendering.</stron
g> This is normal | 397 <li><strong>Don’t call glGet* or glCheck* during rendering.</strong> This
is normal |
398 advice for OpenGL programs, but is particularly important for 3D on | 398 advice for OpenGL programs, but is particularly important for 3D on |
399 Chrome. Calls to any OpenGL ES 2.0 function whose name begins with these | 399 Chrome. Calls to any OpenGL ES 2.0 function whose name begins with these |
400 strings blocks the Native Client thread. This includes <code>glGetError</code>;
avoid | 400 strings blocks the Native Client thread. This includes <code>glGetError</code>;
avoid |
401 calling it in release builds.</li> | 401 calling it in release builds.</li> |
402 <li><strong>Don’t use fixed point (``GL_FIXED``) vertex attributes.</stron
g> Fixed point | 402 <li><strong>Don’t use fixed point (GL_FIXED) vertex attributes.</strong> F
ixed point |
403 attributes are not supported in OpenGL ES 2.0, so emulating them in OpenGL ES | 403 attributes are not supported in OpenGL ES 2.0, so emulating them in OpenGL ES |
404 2.0 is slow. By default, <code>GL_FIXED</code> support is turned off in the Pepp
er 3D | 404 2.0 is slow. By default, <code>GL_FIXED</code> support is turned off in the Pepp
er 3D |
405 API.</li> | 405 API.</li> |
406 <li><strong>Don’t read data from the GPU.</strong> Don’t call <code>
glReadPixels</code>, as it is slow.</li> | 406 <li><strong>Don’t read data from the GPU.</strong> Don’t call <code>
glReadPixels</code>, as it is slow.</li> |
407 <li><strong>Don’t update a small portion of a large buffer.</strong> In th
e current OpenGL ES | 407 <li><strong>Don’t update a small portion of a large buffer.</strong> In th
e current OpenGL ES |
408 2.0 implementation when you update a portion of a buffer (with | 408 2.0 implementation when you update a portion of a buffer (with |
409 <code>glSubBufferData</code> for example) the entire buffer must be reprocessed.
To | 409 <code>glSubBufferData</code> for example) the entire buffer must be reprocessed.
To |
410 avoid this problem, keep static and dynamic data in different buffers.</li> | 410 avoid this problem, keep static and dynamic data in different buffers.</li> |
411 <li><strong>Don’t call ``glDisable(GL_TEXTURE_2D)``.</strong> This is an O
penGL ES 2.0 | 411 <li><strong>Don’t call glDisable(GL_TEXTURE_2D).</strong> This is an OpenG
L ES 2.0 |
412 error. Each time it is called, an error messages will appear in Chrome’s | 412 error. Each time it is called, an error messages will appear in Chrome’s |
413 <code>about:gpu</code> tab.</li> | 413 <code>about:gpu</code> tab.</li> |
414 </ul> | 414 </ul> |
415 </section> | 415 </section> |
416 | 416 |
417 {{/partials.standard_nacl_article}} | 417 {{/partials.standard_nacl_article}} |
OLD | NEW |