Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Integrating SFML with wxWidgets  (Read 1304 times)

0 Members and 1 Guest are viewing this topic.

KubixOFF

  • Newbie
  • *
  • Posts: 3
    • View Profile
Integrating SFML with wxWidgets
« on: February 27, 2025, 10:30:53 am »
Hello.
I trying to integrate SFML with wxWidgets control like in the tutorial on SFML website bu its not working. The Window i freez and cannot clik on close icon. Mabe this tutorial is old? I using sfml 3.0 and wxwidgets 3.2.6.
Can someone help me or show simple code how to draw sfml square into wxwidget control or something?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11155
    • View Profile
    • development blog
    • Email
Re: Integrating SFML with wxWidgets
« Reply #1 on: February 27, 2025, 10:43:06 am »
You mean the tutorial for SFML 1.6, which is two major version ago and something over 15 years old? I do believe the tutorial is old indeed. ;D

What code have you written so far, maybe there's something that stands out.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KubixOFF

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Integrating SFML with wxWidgets
« Reply #2 on: February 27, 2025, 01:47:18 pm »
Yes i talking about tutorial from 1.6 version.

this is my sample code i just want to my window show.


#include <wx/wxprec.h>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <wx/wx.h>

class TestFrame : public wxFrame {
public:
    TestFrame(const wxString& title);
    ~TestFrame();

};


class sfmlframe : public wxControl, public sf::RenderWindow
{
public:
    sfmlframe(wxWindow* Parent = NULL, wxWindowID id = -1, wxPoint point = wxDefaultPosition, wxSize size = wxDefaultSize, long s = 0) : wxControl(Parent, id, point, size, s)
    {
       
        sf::WindowHandle h = this->GetHandle();
        sf::RenderWindow::create(h);

    };
    ~sfmlframe() {};
};

TestFrame::TestFrame(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600)) {



    sfmlframe* frame = new sfmlframe(this, wxID_ANY, wxDefaultPosition, wxSize(200, 150),0);

}

TestFrame::~TestFrame() {

}

class MyApp : public wxApp {
public:
    virtual bool OnInit();
};

bool MyApp::OnInit() {
    TestFrame* frame = new TestFrame(wxT("Sample code"));
    frame->Show(true);
    return true;
}

wxIMPLEMENT_APP(MyApp);



thats happend after compile - nothing will show
after i comment the line:
//  sfmlframe* frame = new sfmlframe(this, wxID_ANY, wxDefaultPosition, wxSize(200, 150),0);

and compile it the wxFrame will show

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11155
    • View Profile
    • development blog
    • Email
Re: Integrating SFML with wxWidgets
« Reply #3 on: February 27, 2025, 02:48:00 pm »
I don't see you implementing OnPaint.

Not sure if wxWidgets needs a specific call to process events, which is what I assume that is failing currently where you can't close the window.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

KubixOFF

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Integrating SFML with wxWidgets
« Reply #4 on: Today at 08:03:08 am »
There is some problem with SFML 3.0.
When i use wxWidgets 3.2.6 and SFML 3.0 - on main private computer everything work perfect.
When i use the same stack and the same code in work computer there is issues and window is freez.

Then i download SFML 2.6.2 and with wxWidgets 3.2.6. work perfect. I think there is something wrong with new event api but mabe i doing something wrong.
Here is my code which work with wxWidgets 3.2.6 and sfml 3.0 on my private computer:
https://github.com/KubixOFFs/wxSFMLControl

 

anything