GLSL 4.2 - how to retrieve size of image?

1k Views Asked by At

In GLSL 4.2 one can use the image2D datatype with imageLoad and imageStore functions. those functions take ivec to determine which pixel to write/read. in order to calculate the proper ivec, i need to know the size of the image. But how do I retrieve this?

textureSize() seems to work only with samplers, not with images.

How to do it?

2

There are 2 best solutions below

0
On BEST ANSWER

You don't. They didn't put in a function to get the image's size, so you'll have to pass it in via a uniform.

1
On

You can use imageSize() in GLSL 4.3. Take a look at GLSL specification from OpenGL.org.