Hi everyone !
I've been beginning a GUI recently for a game project with a friend. I've already coded a kind of rich-text:
I'm now trying to implement several GUI classes, all inheriting from sf::Drawable :
Every part of a window will be inheriting of Widget
For example in the source I added Button : Widget which draws a box and a text label
Window, which contains a sf::RenderImage container where we will draw every Widget that has been added to the vector of widgets via void add(Widget widget)
My problem occurs when I try to draw all my Drawable Widgets in my sf::RenderImage named container. I really don't see what I do wrong and the compiler error message doesn't help me much :
void Window::Render(sf::RenderTarget &target, sf::Renderer &renderer) const
{
for (unsigned int i = 0; i < widgets.size(); i++)
{
container.Draw(widgets[i]);
}
sprite.SetImage(container.GetImage());
sprite.SetPosition(pos.x, pos.y);
target.Draw(sprite);
}
1>c:\users\tenchi\documents\visual studio 2008\projects\sfmlgui\sfmlgui\gui.cpp(133) : error C2663: 'sf::RenderTarget::Draw' : 2 overloads have no legal conversion for 'this' pointer
1>c:\users\tenchi\documents\visual studio 2008\projects\sfmlgui\sfmlgui\gui.cpp(136) : error C2662: 'sf::Sprite::SetImage' : cannot convert 'this' pointer from 'const sf::Sprite' to 'sf::Sprite &'
1> Conversion loses qualifiers
1>c:\users\tenchi\documents\visual studio 2008\projects\sfmlgui\sfmlgui\gui.cpp(137) : error C2663: 'sf::Drawable::SetPosition' : 2 overloads have no legal conversion for 'this' pointer
I have uploaded the VC2008 project
here. The preceding errors occur in gui.cpp at the very bottom (I commented the lines that don't compile so you can build the project normally to test it)
(If you build it, don't run it from visual studio but from either Debug/ or Release/ so that the program finds resources/ ... didn't find how to do this clean)