This section introduces some of the core features of OpenGL. Much of the discussion in this section is limited to 2D. For now, all you need to know about 3D is that it adds a third direction to the x and y directions that are used in 2D.
The term Primitive in OpenGL is used to refer to two similar but separate concepts. The first is the interpretive scheme used by OpenGL to determine what a stream of vertices represents when being rendered. Such sequences of vertices can be arbitrarily long.
OpenGL provides us with several different types of shapes that we can draw in order to get the geometry we want on the screen. In brief, they are:. A line strip is a series of lines, where each point in the line has a point before it and after it, except for the end points.
A triangle strip is a series of connected trianglessharing verticesallowing for more efficient memory usage for computer graphics. They are more efficient than triangle lists without indexing, but usually equally fast or slower than indexed triangle lists. This allows for less use of disk space, as well as making them faster to load into RAM. This sequence would be decoded as a set of triangles with vertices at ABC, BCD, CDE and DEF - although the exact order that the verticies are read will not be in left-to-right order as this would result in adjacent triangles facing alternating directions.
By learning OpenGL, you've decided that you want to do all of the hard work yourself. That inevitably means that you'll be thrown in the deep, but once you understand the essentials, you'll see that doing things the hard way doesn't have to be so difficult after all. To top that all, the exercises at the end of this chapter will show you the sheer amount of control you have over the rendering process by doing things the modern way!
I have a quad strip and a texture. I can use the texture with single quads and the texture is fine - but when I try to apply it to the strip it gets stretched out across the entire strip instead of 1 texture tile in each section of the quad strip. Any help would be greatly appreciated.
To give us more control, and the ability to draw more complicated shapes, we have to use different functions. To start a shape defined by vertices, we use the glBegin function. Here are some possible arguments:.
Shop now. Triangles are the preferred primitive for object composition because most OpenGL hardware specifically accelerates triangles, but they are not the only primitives available. Some hardware provides for acceleration of other shapes as well, and programmatically, using a general-purpose graphics primitive might be simpler.