开发者

iOS / GLES2: How to programmatically determine maximum available texture units?

Determining maximum texture size is no problem: How to detect maximum texture resolution on iPhone?


Also, the documentation specifies the maximum number of samplers that a fragment shader can handle, here

That link specifies under the heading

OpenGL ES 2.0 on the PowerVR SGX

You can use up to 8 textures in a fragment shader

you load textures eg:

// bind gem texture to slot #0, and inform shader via uniform
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, texId_dull );
glUniform1i( [ self.program idForUniform: "U1_sampId_Gem" ],  (GLuint)0 );

// ... similarly for texture #1
glActiveTexture( GL_TEXTURE1 );
glBindTexture( GL_TEXTURE_2D, texId_sparkle );
glUniform1i( [ self.program idForUniform: "U2_sampId_Sparkle" ],  (GLuint)1 );

and COMMAND+click on GL_TEXTURE1 reveals constants all the way to GL_TEXTURE31, so it looks like they are preparing a couple of g开发者_运维百科enerations ahead.


But where can I find the maximum number of textures that can be created.

glGenTextures( n, pTexID ); // what is max n?

Is this only limited by the physical amount of memory available for video on the device? (I read there is no actual physical distinction between VRAM and RAM, it is the same memory). Or can some lower limit be guaranteed?


That's right, the number of texture objects created by

glGenTextures()

is bound only by memory.

The number of texture units (8 on your hardware) can btw. be queried at runtime using

int num_texture_units;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &num_texture_units);


I just found an answer here:

glGenTextures - is there a limit to the number of textures?

Basically it says you are only limited by memory. so it is not possible to give a safe maximum. You have to check whether the texture was successfully created each time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜