6

I'm making an universal openGL based app that should work on ipod/iphone 2G/3G/3GS/4 and iPad.

To deliver the best possible graphics I need to switch between different texture resolutions based on what device is running it.

For example, iPhone 2G needs textures that is no larger than 1024x1024, while iPhone 3GS can handle larger textures.

So, on iPhone 3GS I want to load a texture atlas that's 2048x2048, while iPhone 2G will get the downscaled 1024x1024 texture atlas.

Is there a simple and safe way to detect the maximum texture resolution available to openGL on any said device?

sinsro
  • 905
  • 7
  • 25

1 Answers1

10

Yes, use glGetIntegerv like:

int maxTextureSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);

Then you can use at most a maxTextureSize x maxTextureSize texture.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • This is not working for me. glGetIntegerv doesn't modify the value of maxTextureSize, glError is returning 0. Am I missing something? – louissmr Mar 14 '15 at 17:17
  • @louissmr you need to set the eaglContext: [EAGLContext setCurrentContext:[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]]; – l-l Jan 10 '17 at 23:02
  • is there anything i have to import to use this – krishan kumar May 15 '19 at 14:58