

Reduce computations performed for each vertex. Reduce the time spent copying vertex data to the graphics hardware. Reduce the pre-processing that must occur before OpenGL ES can transfer the vertex data to the graphics hardware. The practices described in this chapter can be summarized in a few basic principles: One advantage of OpenGL ES is that it standardizes on a single set of functions to submit vertex data to OpenGL ES, removing older and less efficient mechanisms that were provided by OpenGL.Īpps that must submit a large number of primitives to render a frame need to carefully manage their vertex data and how they provide it to OpenGL ES. The graphics hardware than acts on the vertex data, processing each vertex in the shader, assembling primitives and rasterizing them out into the framebuffer. When your app calls a function in OpenGL ES to draw a set of vertices, the vertex data is copied from your app to the graphics hardware. Your app may configure an attribute to be a constant, which means the same values are used for all vertices submitted as part of a draw command, or an array, which means that each vertex a value for that attribute. Figure 8-1 Conversion of attribute data to shader variables The last component is filled with 1, and other unspecified components are filled with 0, as illustrated in Figure 8-1. When an attribute is loaded into a shader variable, any components that are not provided in the app data are filled in with default values by OpenGL ES. For example, a color might be defined as four GLubyte components (red, green, blue, alpha). All components in the attribute share a common data type. You define an attribute as a vector consisting of one to four components. An OpenGL 1.1 app uses attributes defined by the fixed-function pipeline.

An OpenGL ES 2.0 or 3.0 app is free to define its own attributes each attribute in the vertex data corresponds to an attribute variable that acts as an input to the vertex shader. This chapter provides a refresher on vertex data and follows it with targeted advice for how to efficiently process vertex data.Ī vertex consists of one or more attributes, such as the position, the color, the normal, or texture coordinates. But no matter which primitives you use in your app or how the pipeline is configured, your app provides vertices to OpenGL ES. In some apps, all primitives are drawn using the same pipeline configuration other apps may render different elements of the frame using different techniques. To render a frame using OpenGL ES your app configures the graphics pipeline and submits graphics primitives to be drawn. Best Practices for Working with Vertex Data To create high-performance code on GPUs, use the Metal framework instead.
