Feature 4 Post Mortem
Surrounding my terrain with a skybox was a pretty simple process, although I was able to make it difficult by overlooking a couple of syntax issues. I did most of the work before Chris posted his video, so I’ll have to cite the guys at stackoverflow and opengl.org. The code was essentially the same as all of the code that we have been using to texture objects. The only difference was that we used GL_TEXTURE_CUBE_MAP instead of GL_TEXTURE_2D, and we uploaded 6 different images to the same spot in memory. This is what the code looked like.
In the shaders, I had to make sure to use the vertex coordinates of my cube as the texture coordinates, because the cube should always be centered at the player’s location (which can be done by adding a getFrom() function to the Camera class and using it to translate the cube to the from position of the camera). We also set the z component of the vertex coordinate to be equal to the w component, which forces the graphics card to do some division, and pushes the cube back behind everything else in the scene. My only issues were caused by a couple of really embarrassing errors. After I watched the video, I was able to solve all of them. Here are some pictures of my skybox:
Here is a video of me looking at my own skybox… http://youtu.be/ldY-AGYOcjA