The point of this exercise, therefore, is to learn enough to assemble a very simple OpenGL game engine that will let me wander around, fly over, etc. terrains generated via the techniques I'm experimenting with. I figure another day or two will bring me to the point where I know enough to do that, and that I've learned the additional techniques I need. Today has brought me closer to that point.
|A woman standing on a hillside, with a cloudy sky behind.|
The terrain is no longer flat. The basic skybox is in place with clouds anyway you look. The blocky man from yesterday has been replaced by a woman who doesn't quite render properly (texture mapping problem) but is still less freaky than the box man. The woman and one of the tree models were free models I downloaded online.
Alas, that brings me to one of the major limitations of the game engine as it stands. It only supports OBJ models that are textured by one and only one texture file. Untextured OBJ models, or those with multiple textures, are not properly supported. There's a lot of good free models, at least for a demo/experiment like this, but I can't load most of them, even after converting them to OBJ via Blender, because of the poor support.
At first glance that sounds like a simple thing to resolve. It actually is with respect to reading the file format. But efficient data structures for rendering, on the other hand, I am still considering. At this point, I think the likely solution in my eventual engine (as opposed to what is emerging from the tutorial) is that a model may actually become a list of paired geometries and materials. When rendering multiple instances of a model (as with the trees, ferns, flowers, etc.) I'd iterate over the list of instances once per paired geometry/material. So if a model had geometry/material A, B and we had instances 1, 2, 3, 4 of the model, we'd render 1A, 2A, 3A, 4A, 1B, 2B, 3B, 4B so there would only be one state change, between 4A and 1B.
I'm also considering how to deal with non-textured models. Models with simple color can still be very useful. Perhaps auto-generating a texture map with all the used colors on it, and assigning texture coordinates to vertices such that they map to the correct color block of the texture map, may be the answer. That would let the same shader handle both types of models.
Anyhow, I'm going to finish out at least three more of the tutorials (day/night cycle, normal mapping, and mouse picking) before I start creating my own, limited engine. I'm not trying to create a major game, nor sell an engine, but some of this experimental stuff is just more easily implemented using lower level graphics programming - but alas at a slightly higher level than OpenGL itself provides. I don't think running out and using a full blown scene graph or game engine is the solution, so I shall continue.