Bind custom uniform values to a 2D filter (using bgl wrapper)

@youle

Yes this is for the UPBGE addon, I already use the new API there. However there are still some problems:

One is this message: “Invalid texture sample index: X”
It appears either by loading from disk or internal. Interstingly now that I use glDeleteTextures() the X is always the same after first execution, but the message still appears.

The second problem, wich may be related to the first, is that for some reason the same texture is binded to the sampler2D uniform when loading it from disk, but it works well when loading from a material. This always happens with the last texture I bind.

Here you have my current project, see the core/glsl/global/filter2D.py for the implementation.

texturesProblem.zip (629 KB)

The file works even without the addon, but if you install the addon and try to open it with “Load Game Project” it should work better.

I’m using UPBGE 0.1.0 by the way.

EDIT: Ohh, I’m not using the .setTexture() at all, I’ll try with that.
EDIT: My god, I’ve just added that signle line of code and it fixes everything… this is the first time in a lot of years that I feel like I’m coding magic again.