I have noticed that in my calculateLightsGPU function this line:
Screen.sfRenderWindow_drawSprite(Sprite, &States);
which is where i beleive the fragment shader is ran from yet outputs nothing at all to the screen.
Now i thought hang on i have earlier in the function already set the entire texture to be a single color which is the overlay i use for "night time" that has alpha same color i use for the cpu version of this function.
There should atleast be that color overlay over the screen regardless of if the shader has drawn the lights on the overlay at all. so i tried setting it to this:
Screen.sfRenderWindow_drawSprite(Sprite, null);
Now, while ofcause the shader doesnt run it is drawing the overlay to the screen without any of the lights on it as expected. so because of this is it possible that there is something wrong with my rendering states.
How am i meant to set them up to work with shaders? currently i have the shader loaded from file and then i do this:
sfRenderStates States;
States.shader = Shader;
States.blendMode = sfBlendAdd;
is it possible that this is where i went wrong? and if so how should it be done?
In an attempt to do this differently then i have gone back to the idea of using a RenderTexture, clearing it each frame to the ambient color value (mostly transparent dark blue for night time) and the texture for the sprite that i am applying the shader to will be updated to entirely transparent for each light, then the idea is for the shader to draw it, draw it to the RenderTexture until all lights are done then draw the RenderTexture to the screen.
Firstly to be sure i have set the texture of the state as such:
States.texture = RenTex.sfRenderTexture_getTexture();
Now what i have is the overlay color being correctly overlayed over the screen but still no "lights" here is the updated funciton:
void calculateLightsGPU(DDLight*[] lights = []) {
RenTex.sfRenderTexture_clear(Color);
Sprite.sfSprite_setTexture(Texture, 1);
sfVector3f shaderlight;
foreach (DDLight* light; lights) {
Texture.sfTexture_updateFromImage(Image, 0, 0);
shaderlight.x = light.Position.x;
shaderlight.y = light.Position.y;
shaderlight.z = light.Range;
Shader.sfShader_setVector3Parameter("light", shaderlight);
Shader.sfShader_setColorParameter("lcolor", light.Color);
RenTex.sfRenderTexture_drawSprite(Sprite, &States);
}
RenTex.sfRenderTexture_display();
Sprite.sfSprite_setTexture(States.texture, 0);
Screen.sfRenderWindow_drawSprite(Sprite, null);
}
Please guys i need help with this, the shader should be doing something but if i remove the entire foreach loop the output is exactly the same!