To render an image with reflection based on a cube map, and also render the cube map itself, carry out the following steps:
- We'll start by defining a function that will load the six images of the cube map into a single texture target:
GLuint Texture::loadCubeMap(const std::string &baseName, const std::string &extension) { GLuint texID; glGenTextures(1, &texID); glBindTexture(GL_TEXTURE_CUBE_MAP, texID); const char * suffixes[] = { "posx", "negx", "posy", "negy", "posz", "negz" }; GLint w, h; // Load the first one to get width/height std::string texName = baseName + "_" + suffixes[0] + extension; GLubyte * data = Texture::loadPixels(texName, w, h, false); // Allocate immutable storage for the whole cube map texture glTexStorage2D(GL_TEXTURE_CUBE_MAP, ...