I am loading the texture.png texture by using GLKit as per the code below:
// Setup texture
CGImageRef imageRef = [[UIImage imageNamed:@"texture.png"] CGImage];
GLKTextureInfo texInfo = [GLKTextureLoader textureWithCGImage:imageRef options:nil error:NULL];
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texInfo.name);
// Set parameters that control texture sampling for the bound
// texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_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);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texInfo.width, texInfo.height, 0, GL_RGB, GL_UNSIGNED_BYTE, XXXX);
XXXX is the data which specifies a pointer to the image data in memory. The problem is that I am using GLKit to load the texture but I couldn’t find in the apple documentation any way to retrieve the data from the GLKTextureInfo class. Does anyone know how I can fix that?
If you’ve called
[GLKTextureLoader textureWithCGImage:options:error:], you don’t need to upload the bitmap data. It’s already happened, so the call toglTexImage2D()is unnecessary.