To pursue this avenue of thought further I have two questions:
Is there a special function in glsl for reading in integral textures that does not clamp it as a float between 0.0f - 1.0f? If not how does OpenGL handle the conversion from signed int to float for negative numbers?
Does the GL_BLEND still apply for integer textures? For example I would like to have in my application:
fakeStencil = -1;
And for this to decrement the fake stencil by exactly 1. Would that work?
I actually have a more fundamental problem:
If I attach a texture defined like so:
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, wWidth, wHeight, 0, GL_RED, GL_RED_INTEGER, NULL);
To a frame buffer object as a color attachment, I get nothing. Even trying to draw to the other regular floating point color attachment fails.
If I however change the above call to glTexImage2D to a safe one like
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, wWidth, wHeight, 0, GL_RGBA, GL_FLOAT, NULL);
Then I can draw to both color attachments (as expected).
I have checked for framebuffer completeness in both cases and everything seems to be a-ok. So what am I doing wrong now?
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8I, wWidth, wHeight, 0, GL_RED_INTEGER, GL_BYTE, NULL);
unsure whether to use GL_BYTE or GL_INT as type.