I'm having a problem getting a post effect to work in 1.6. I got the tutorial working and then i tried applying the same effect to a project i am working on. The only difference is that I have a class that deals with all the graphics. So I added the sf::PostFx as a private member and then loaded it in the constructor of the class. Then drew it using a pointer to the sf::RenderWindow i also stored in the class i guess minimum code is the following:
class Graphics
{
public:
Graphics();
~Graphics();
void Draw();
void Load(sf::RenderWindow * Window, Hud * MyHud, QuadTree * MyQuadTree, Objects * everything);
private:
sf::View View;
sf::Vector2f Center;
sf::Vector2f HalfSize;
void ChangeView();
QuadTree * QuadTreePtr;
Hud * HudPtr;
sf::RenderWindow * WindowPtr;
Objects * Everything;
Shadow Shadows;
void DrawMenu();
sf::PostFX Effect;
};
and then the draw function that draws all the objects on the screen for me
void Graphics::Draw()
{
// Update view based on gambino's position
ChangeView();
// Get the mouse position in the range [0, 1]
float X = WindowPtr->GetInput().GetMouseX()/
static_cast<float>(WindowPtr->GetWidth());
float Y = WindowPtr->GetInput().GetMouseY()/
static_cast<float>(WindowPtr->GetHeight());
// Update the effect parameters
Effect.SetParameter("color", 0.5f, X, Y);
// Clear screen of previous renderings
WindowPtr->Clear();
// Calculate New Position of background
Everything->BkGrndImg.SetPosition(WindowPtr->GetView().GetCenter().x*
(1-BGTRANSSCALE),
WindowPtr->GetView().GetCenter().y*
(1-BGTRANSSCALE));
// Draw Background
WindowPtr->Draw(Everything->BkGrndImg);
WindowPtr->Draw(Effect);
// Get Vector of objects to draw from quadtree
sf::Rect<float> viewrect = View.GetRect();
vector<BaseObject*> ToDraw = QuadTreePtr->Query(viewrect);
for(unsigned int i=0;i<ToDraw.size();++i)
{
ToDraw[i]->Draw(*WindowPtr);
}
// Display Heads Up Display
HudPtr->DrawStatusBars(*WindowPtr,Everything->Gambino);
HudPtr->DisplayFrameRate(*WindowPtr);
// Draw menu if open
if(state.GetMenu())
{
DrawMenu();
}
// Draw QuadTree for debugging purposes if TAB is being held down
if(state.DrawQuadTree)
{
QuadTreePtr->Draw();
}
WindowPtr->Display();
}
I'm just wondering what I could be doing wrong or if there is something about post effects that doesn't allow me to do it this way. Again, the tutorial does work and i am able to load the effect with this project it just doesn't seem to do anything.