glGenTextures(1, &texId); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texId); // Allocate graphics memory.glTexImage2D(GL_TEXTURE_2D, 0, format, cols, rows, 0, format, type, NULL); // Allocate memory for mipmap. glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Create off-screen framebuffer object and attach the texture to it. glGenFramebuffers(1, &fboId); glBindFramebuffer(GL_FRAMEBUFFER, fboId); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texId, 0);// Now render to that texture...// Generate MIP map.glBindTexture(GL_TEXTURE_2D, texId);glGenerateMipmap(GL_TEXTURE_2D);
256^2 + 128^2 + ... + 1^2 ~= 90,000 texels to generate
90,000 * 55 / 1.2e9 ~= 4ms