Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
679 views
in Technique[技术] by (71.8m points)

opengl es - Non power of two textures in iOS

In my iOS app (targeted for iPad), I'd like to use non power of two (NPT) textures. My GL_VERSION query returns "OpenGL ES 2.0 APPLE". According to the spec, it should support NPT textures, but a simple test shows that I need to resize the texture to 2^N before it shows up.

Does Apple not support the full ES 2.0 spec? Where can I find documentation on what is not supported?

I am using Xcode 4.3.2 and iOS 5.1.

Edit:

A closer look at the ES 2.0.25 spec (section 3.8.2), reveals that there are a few conditions to be met for NPOT to work. Essentially if I use the settings below, I am able to load NPOT textures:

// use linear filetring
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// clamp to edge
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Should I close this or answer my own question?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As mentioned in my edit, I found the solution. NPOT on ES 2.0 requires that you use linear filtering and clamp to edge. Also, no mipmaps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...