Proud Member
Proud Member

Reputation: 40496

How to draw a colored rectangle in OpenGL ES?

Is this easy to do? I don't want to use texture images. I want to create a rectangle, probably of two polygons, and then set a color on this. A friend who claims to know OpenGL a little bit said that I must always use triangles for everything and that I must use textures for everything when I want it colored. Can't imagine that is true.

Upvotes: 0

Views: 4178

Answers (2)

Jerry Coffin
Jerry Coffin

Reputation: 490128

With OpenGL ES 2.0, you do have to use a shader, which (among other things) normally sets the color. As long as you want one solid color for the whole thing, you can do it in the vertex shader.

Upvotes: 1

Ben Jackson
Ben Jackson

Reputation: 93720

You can set per-vertex colors (which can all be the same) and draw quads. The tricky part about OpenGL ES is that they don't support immediate mode, so you have a much steeper initial learning curve compared to OpenGL.

This question covers the differences between OpenGL and ES:

OpenGL vs OpenGL ES 2.0 - Can an OpenGL Application Be Easily Ported?

Upvotes: 4

Related Questions