Dragonfly Q&A

Color in GraphicsManager

0 like 0 dislike
The function drawCh in the GraphicsManager takes a parameter of type Color. Is this a df::Color or an sf::Color? I would expect the former because we are in namespace df, but the slides don't mention including Color.h, while SFML/Graphics.hpp (which contains sf::Color) is included.
asked Sep 17, 2015 in Engine Development by Andrew

2 Answers

1 like 0 dislike
I believe the parameter is df::Color, as code listing 4.68 then uses a switch to map the parameter to sf::Color. In that case, you would only need the SFML include for the graphics manager. Color.h would be included in any file that uses drawCh() (so you can pass the Dragonfly colors into drawCh()).
answered Sep 17, 2015 by TACaitlin
1 like 0 dislike
Caitlin is right - it should be df::Color for drawing.  This decouples any game code from SFML.  The engine maps the df::Color to an sf::Color.  The graphics manager should #include "Color.h" - not having it is an oversight (which I will correct in the slides and the next version of the book).  Sorry for any confusion.
answered Sep 18, 2015 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.