hm.. I tried to adapt (just a little the tutorial from SFML1.6) : here is the code I used :
#include "wx/wx.h"
#include <SFML/Graphics.hpp>
class wxSFMLCanvas : public wxControl, public sf::RenderWindow
{
public :
wxSFMLCanvas(wxWindow* Parent = NULL, wxWindowID Id = -1, const wxPoint& Position = wxDefaultPosition,
const wxSize& Size = wxDefaultSize, long Style = 0);
virtual ~wxSFMLCanvas();
private :
DECLARE_EVENT_TABLE()
virtual void OnUpdate();
void OnIdle(wxIdleEvent&);
void OnPaint(wxPaintEvent&);
void OnEraseBackground(wxEraseEvent&);
};
void wxSFMLCanvas::OnIdle(wxIdleEvent&)
{
Refresh();
}
void wxSFMLCanvas::OnPaint(wxPaintEvent&)
{
wxPaintDC Dc(this);
OnUpdate();
display();
}
#ifdef __WXGTK__
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <wx/gtk/win_gtk.h>
#endif
wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
wxControl(Parent, Id, Position, Size, Style)
{
#ifdef __WXGTK__
gtk_widget_realize(m_wxwindow);
gtk_widget_set_double_buffered(m_wxwindow, false);
GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window;
XFlush(GDK_WINDOW_XDISPLAY(Win));
sf::RenderWindow::create(GDK_WINDOW_XWINDOW(Win));
#else
sf::RenderWindow::create(GetHandle());
#endif
}
class MyCanvas : public wxSFMLCanvas
{
public :
MyCanvas(wxWindow* Parent,
wxWindowID Id,
wxPoint& Position,
wxSize& Size,
long Style = 0) :
wxSFMLCanvas(Parent, Id, Position, Size, Style)
{
mySprite.setColor(sf::Color::Cyan);
//mySprite.SetImage(myImage);
}
private :
virtual void OnUpdate()
{
clear(sf::Color(0, 128, 128));
draw(mySprite);
}
//sf::Image myImage;
sf::Sprite mySprite;
};
class MyFrame : public wxFrame
{
public :
MyFrame() :
wxFrame(NULL, wxID_ANY, "SFML wxWidgets", wxDefaultPosition, wxSize(800, 600))
{
new MyCanvas(this, wxID_ANY, wxPoint(50, 50), wxSize(700, 500));
}
};
class MyApplication : public wxApp
{
private :
virtual bool OnInit()
{
MyFrame* MainFrame = new MyFrame;
MainFrame->Show();
return true;
}
};
IMPLEMENT_APP(MyApplication);
& i get this error :
1>minimal.obj : error LNK2001: unresolved external symbol "protected: virtual struct wxEventTable const * __thiscall wxSFMLCanvas::GetEventTable(void)const " (?GetEventTable@wxSFMLCanvas@@MBEPBUwxEventTable@@XZ)
1>minimal.obj : error LNK2001: unresolved external symbol "protected: virtual class wxEventHashTable & __thiscall wxSFMLCanvas::GetEventHashTable(void)const " (?GetEventHashTable@wxSFMLCanvas@@MBEAAVwxEventHashTable@@XZ)
1>minimal.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall wxSFMLCanvas::OnUpdate(void)" (?OnUpdate@wxSFMLCanvas@@MAEXXZ)
1>minimal.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall wxSFMLCanvas::~wxSFMLCanvas(void)" (??1wxSFMLCanvas@@UAE@XZ) referenced in function "public: virtual void * __thiscall wxSFMLCanvas::`scalar deleting destructor'(unsigned int)" (??_GwxSFMLCanvas@@UAEPAXI@Z)
1>vc_mswud\minimal.exe : fatal error LNK1120: 4 unresolved externals
NB : I implemented the code on the minimal sample from wxWidget ( so that I didnt have to add wxWidget dependancies) and I have added the lib/include SFML dependancies :
(linker/General, Linker/Input and c/c++/General)
I'm sure I' doing a mistake so;ewhere ( i do believe that its a problem of linking libraries ) but as I'm completely new to wxWidget, I just tried what I thought was the easier : comes from their sample to add SFML2.0 inside. I hope you can help me here,
Thanks,
gabriel