Question

I need to pass texture data to a shader program without using OpenGL textures because I'm not using a power of two texture but I get the error with this fragment shader.

varying highp vec2 texcoord;
uniform ivec4 texdata[172800];
void main(){
 int pixel = int(360.0 * texcoord.y + texcoord.x);
 gl_FragColor = vec4(texdata[pixel].x,texdata[pixel].y,texdata[pixel].z,1);
}

How can I pass this data?

Was it helpful?

Solution

Actually, the newer iOS models that support OpenGL ES 2.0 have the ability to use non-power-of-two textures because that is provided for in the OpenGL ES 2.0 specification. These devices also allow for non-power-of-two textures to be used in OpenGL ES 1.1 via the GL_APPLE_texture_2D_limited_npot extension, which I describe in more detail in my answer here.

The restrictions Apple places on these non-power-of-two textures is that they must not be mipmapped and they must use GL_CLAMP_TO_EDGE for the wrapping:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

I use such textures in my OpenGL ES 2.0 sample application here.

You shouldn't need to find another way to pass your textures in to your shaders on these devices.

OTHER TIPS

The OpenGL/ES 2 spec only requires that GLSL integers are at least 17 bits (able to represent the range [-2^16,2^16)), and integers are used for array indexes, so you can't reliably create an array with more than 65535 elements. You might not be able to create one that big in any case, as there are limits on the total amount of uniform data that may be much lower. If you want access to a larger amount of data, you need to use a texture.

This error is probably coming from your integer constant 172800 which is apparently too big for your platform's GLSL implementation.

There are non-power-of-2 texture targets, so no reason to do this. http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt

Or you just pad your non-power-of-2 data into a power-of-2 frame.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top