Multi instancing support in OpenGL-ES

Hi,

I’m new to OpenGL-ES development.
As I understand from the GL-ES manual and specs document, for rendering a particular primitive we need to call few functions to set the parameter for the primitive and then call the glDrawArrays() to render the primitive.

e.g. to draw a line, the application code should look like

            /* Line width is by default 1 pixel. /
            glLineWidthx(nThickness);

            /
Set the current vertices to use from aVertices array. /
            glVertexPointer(2, GL_SHORT, 0, aVertices);

            /
Set the current vertices to use color from colors array. /
            glColorPointer(4, GL_BYTE, 0, aColors);
           
            /
Draw the primitive using elements from vertices array. */
            glDrawArrays(GL_LINES, 0, 1);

where glLineWidthx() should set the value of a global variable (because we don’t have any structures in GL-ES to pass the data to implementation layer) to nThickness and which will be used by the line drawing function.

Now my query is if we use global variables in the implementation, how can we support the multi instancing capability.

Please help me in clearing this doubt and let me know if I’m wrong in my understanding of the GL-ES application/implementation code.

Thanking You in Advance,
Himanshu


If you’re asking whether it’s possible to draw multiple lines with different widths in a single draw call, the answer is no. If you need to draw lots of lines with varying width and you are draw call limited, it might be worth tessellating the lines to pairs of triangles and draw them with a single call to glDrawElements(GL_TRIANGLES, …).