Hey,
I'm writing a game in SFML 1.6 that requires I colourise various images on the screen (i.e. platforms, enemies, etc). Each game object has a sprite which refers to common images in my resource manager.
What I originally tried to do was store the original, uncolourised image in the resource manager, then apply the PostFX to the sprite as I was drawing it (As I'd do when writing games with directx), however, I found out I couldn't do that. That is, according to the documentation I either have to apply the PostFX to the screen or to an image.
So I decided to just store a copy of each colourised image in the resource manager. I only need a handful of different copies anyway (As in, I'm only colourising to 5-6 discrete colours). So, I load the original image, create a new image which copies the original image, and then try to apply the PostFX to that.
However, I'm unsure how to actually tell the PostFX to apply the effect. For the frame buffer, you call a draw on the effect, and that applies it to everything drawn previously, but how do I do it for an image in memory?
Or do I have it wrong and applying the effect on the image does what I originally wanted (As in, applies it only to the drawn instance rather than the image in memory)? If so, how do I do this properly, since calling sprite.GetImage() as the second parameter for the SetTexture call returns a const mismatch error.
The code that changes the images (in memory, I'm hoping) looks like:
tempEffect = ShaderManager::Get()->getEffectByIndex(tempIndex);
tempEffect->SetTexture("framebuffer", (&initial));
tempEffect->SetParameter("colour", (float)colours[red].r/255,(float)colours[red].g/255,
(float)colours[red].b/255);
App->Draw((*tempEffect));
Initial is the sf::Image& which contains the pixels I'd like to colourise. tempEffect is the sf::PostFX which does this. I'm just not sure how to actually "submit" it (i.e. I'm not sure what the last line should be)
Any suggestions would be much appreciated,
Josh