OLD | NEW |
1 .. _devguide-coding-3D-graphics: | 1 .. _devguide-coding-3D-graphics: |
2 | 2 |
3 ########### | 3 ########### |
4 3D Graphics | 4 3D Graphics |
5 ########### | 5 ########### |
6 | 6 |
7 Native Client applications use the `OpenGL ES 2.0 | 7 Native Client applications use the `OpenGL ES 2.0 |
8 <http://en.wikipedia.org/wiki/OpenGL_ES>`_ API for 3D rendering. This document | 8 <http://en.wikipedia.org/wiki/OpenGL_ES>`_ API for 3D rendering. This document |
9 describes how to call the OpenGL ES 2.0 interface in a Native Client module and | 9 describes how to call the OpenGL ES 2.0 interface in a Native Client module and |
10 how to build an efficient rendering loop. It also explains how to validate GPU | 10 how to build an efficient rendering loop. It also explains how to validate GPU |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 500 |
501 * **Don't use client side buffers.** OpenGL ES 2.0 can use client side data with | 501 * **Don't use client side buffers.** OpenGL ES 2.0 can use client side data with |
502 ``glVertexAttribPointer`` and ``glDrawElements``, but this is really slow. Try | 502 ``glVertexAttribPointer`` and ``glDrawElements``, but this is really slow. Try |
503 to avoid client side buffers. Use Vertex Buffer Objects (VBOs) instead. | 503 to avoid client side buffers. Use Vertex Buffer Objects (VBOs) instead. |
504 | 504 |
505 * **Don't mix vertex data and index data.** By default, Pepper 3D binds buffers | 505 * **Don't mix vertex data and index data.** By default, Pepper 3D binds buffers |
506 to a single point. You could create a buffer and bind it to both | 506 to a single point. You could create a buffer and bind it to both |
507 ``GL_ARRAY_BUFFER`` and ``GL_ELEMENT_ARRAY_BUFFER``, but that would be | 507 ``GL_ARRAY_BUFFER`` and ``GL_ELEMENT_ARRAY_BUFFER``, but that would be |
508 expensive overhead and it is not recommended. | 508 expensive overhead and it is not recommended. |
509 | 509 |
510 * **Don't call ``glGet*`` or ``glCheck*`` during rendering.** This is normal | 510 * **Don't call glGet* or glCheck* during rendering.** This is normal |
511 advice for OpenGL programs, but is particularly important for 3D on | 511 advice for OpenGL programs, but is particularly important for 3D on |
512 Chrome. Calls to any OpenGL ES 2.0 function whose name begins with these | 512 Chrome. Calls to any OpenGL ES 2.0 function whose name begins with these |
513 strings blocks the Native Client thread. This includes ``glGetError``; avoid | 513 strings blocks the Native Client thread. This includes ``glGetError``; avoid |
514 calling it in release builds. | 514 calling it in release builds. |
515 | 515 |
516 * **Don't use fixed point (``GL_FIXED``) vertex attributes.** Fixed point | 516 * **Don't use fixed point (GL_FIXED) vertex attributes.** Fixed point |
517 attributes are not supported in OpenGL ES 2.0, so emulating them in OpenGL ES | 517 attributes are not supported in OpenGL ES 2.0, so emulating them in OpenGL ES |
518 2.0 is slow. By default, ``GL_FIXED`` support is turned off in the Pepper 3D | 518 2.0 is slow. By default, ``GL_FIXED`` support is turned off in the Pepper 3D |
519 API. | 519 API. |
520 | 520 |
521 * **Don't read data from the GPU.** Don't call ``glReadPixels``, as it is slow. | 521 * **Don't read data from the GPU.** Don't call ``glReadPixels``, as it is slow. |
522 | 522 |
523 * **Don't update a small portion of a large buffer.** In the current OpenGL ES | 523 * **Don't update a small portion of a large buffer.** In the current OpenGL ES |
524 2.0 implementation when you update a portion of a buffer (with | 524 2.0 implementation when you update a portion of a buffer (with |
525 ``glSubBufferData`` for example) the entire buffer must be reprocessed. To | 525 ``glSubBufferData`` for example) the entire buffer must be reprocessed. To |
526 avoid this problem, keep static and dynamic data in different buffers. | 526 avoid this problem, keep static and dynamic data in different buffers. |
527 | 527 |
528 * **Don't call ``glDisable(GL_TEXTURE_2D)``.** This is an OpenGL ES 2.0 | 528 * **Don't call glDisable(GL_TEXTURE_2D).** This is an OpenGL ES 2.0 |
529 error. Each time it is called, an error messages will appear in Chrome's | 529 error. Each time it is called, an error messages will appear in Chrome's |
530 ``about:gpu`` tab. | 530 ``about:gpu`` tab. |
OLD | NEW |