Help, glBindImageTexture / Imagestore / gl unkown type 0x904e

I want to write my ssbo values into a texture3d.
When looking for the best way to do this… I think that the best method is to use a compute shader using the imageStore method (requires 4.2, which I am sure to set).

I dont have my code checked in, and not in front of my, so my pseudo code might not be exactly representative of what I am trying… but this is what I have so far. Nothing throws errors, but i dont think its working correctly.

On the c++ side:

glBindImageTexture(0, mtexture->getId(), 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA8);

On the shader side (writing into texels):

layout (binding=0, RGBA8) writeonly uniform image3D tex3D;
void main(){
    imageStore(tex3D, ivec3(x,y,z), vec4(1.0,0.0,0.0,1.0));

Then I bind this 3d texture as a sampler into another shader:

gl::ScopedTextureBind scoped3dTexb(mtexture);

And trying to sample it (in uv space):

uniform sampler3D uTexture;

In the end, not getting red, as I would expect… just black.
Using the glBindImageTexture as I dont think that the cinder ScopedTextureBind does the same thing. Is there a cinder method to bind image? Possibly my use of the raw gl call is wrong (it’s almost a certainty), and someone can point me to the correct way to use that? I’ve tried multiple configurations of binding and uniform layouts. But haven’t found a solution.

Otherwise, any direction on getting this to work is greatly appreciated. Thank you.


I was able to get image texture working with raw GL calls in Cinder:

glUniform1i(glGetUniformLocation(mGlslProg->getHandle(), "tex3D"), 0);
glBindImageTexture(0, mtexture->getId(), 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_RGBA8);

I don’t remember why, but I’m guessing the GlslProg::uniform() method doesn’t handle image textures correctly.

Thank you or your reply. I implemented your suggested code… And it might work. But i just realized that I am having another issue before even getting to that point of reading the image in the shader…

I am getting a gl error:

|error  | uint8_t cinder::gl::typeToBytes(GLenum)[605] Unknown gl type constant 0x904e

I remember looking into this before. But found no answers. I do know however, that it is totally related to my line:

layout (binding=0, RGBA8) writeonly uniform image3D tex3D;

Hopefully someone has some insight on how to rectify this error.

I had that error before here:

Fwiw I managed to get it (finally) writing to a 3d Tex after that.

Hi, Thank you.
These changes did in fact remove the errors I was getting. However, I still need to fiddle around in my ever changing code to see if I can get it to actually draw to the Image.
Thank you for your help.