how can I share variables between glsl and python in the bge?
to my surprise the bge keeps glsl functions as strings until they're in use, but for some reason you can't use replace on them. Therefore if you want to share memory between a glsl shader and the bge you can do something like this below. worked great for me anyway.

for i in range(257):
    f = """        
        varying vec4 maps[256];
        void main()
       {
          gl_FragColor = maps[100];//this is not valid because i doesn't exist here.
       }        
    """   
    f=list(f)
    a=str(i)

    f[100:103]=a

    f="".join(f)    
    print('verify:',f[100],f[101],f[102])

    FragmentShaders.append(f)