|
The OpenGL way of doing thingsOpenGL is a low-level API. In POV-Ray you can describe complex objects by declaring primitives (basic, built-in objects) such as 'sphere' and 'box', and add or subtract them from each other. In OpenGL you have to build everything from the ground and up. You start with vertices, and connect them to make triangles, which in turn can be combined to build e.g. a sphere. The OpenGL primitives are more basic, such as 'triangles' and 'triangle-strips'. GLU, the OpenGL Utilities, adds some higher-level functionality, such as 'sphere' and 'cylinder' primitives, but it is still a lot of work to build complex shapes. Note: OpenGL can be useful for 2D graphics, too. By specifying that objects far away should not look smaller than close objects, you'll get a flat 2D world. This is used in some 2D games. OpenGL is a state machine. This means that when you set any properties, they will stay that way, independent of scopes and function calls, until the program stops or you change them. If you are not aware of this, you will, like I did, experience some weird bugs.
A red house on a red island in a red seaWhile this does sound kind of poetic, it does not show much of what you can do with OpenGL. It has no textures, and only one light source. But for a newbie OpenGL program, it does look kind of cool, doesn't it? Basically, what I wanted to do was to build a landscape from a height field. The height field is just a 2D array in map.hpp. (In a real world application you would of course use an image instead.) Each point in the height field corresponds to the height of a vertex in my landscape, and four points make up a square. To make my landscape more detailed, I split the squares into triangles when necessary. I actually use a second 2D array to determine how to split each square, upper-left-to-lower-right or upper-right-to-lower-left. Then I make the whole scene rotate, with an option to pause the rotation. If you think this is a somewhat cumbersome and ineffective way of doing things, you are completely right. One example of this is that all my triangles are evenly distributed. The world would be both faster to render and better looking if I had used large triangles for flat surfaces, and small triangles for uneven surfaces. But I am, as I must have pointed out a few times by now, just a newbie. Comment List
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||