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

Author Topic: Another SFML2 + wxWidgets thread..  (Read 3661 times)

0 Members and 1 Guest are viewing this topic.

Haikarainen

  • Guest
Another SFML2 + wxWidgets thread..
« on: September 12, 2011, 10:36:31 pm »
So yeah, I noticed the wxWidgets examples as of 1.6 is broken in 2.0, and I'm attempting to restore them, or at least the wxSFMLCanvas-class. Please reply if you can help me, or if you've had problems with these as well and know solutions to your problems, so we can once in for all collect all the problems and solutions in one thread.

The first problem I discovered:
Code: [Select]
sf::RenderWindow::Create(GetHandle());
Gives us "Invalid conversion from void* to HWND__*"

Fix:
Code: [Select]
sf::RenderWindow::Create((HWND__*)GetHandle());
This fix works for me but is known to give warnings to other people.

...

EDIT; For the rest of the problems; Either read this thread or look at the full example sources :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Another SFML2 + wxWidgets thread..
« Reply #1 on: September 13, 2011, 07:57:22 am »
Quote
first problem

You must have a very old revision of SFML 2... This is fixed in the current version.

Quote
Second problem

I'm not sure it is a fix, looks like a workaround. Destructors are generated by the compiler (not inherited!) if not defined explicitely, there's nothing wrong with that.

Quote
Third problem

It may be related to the second problem. This is not an inheritance problem, the linker tries to find functions which are declared directly in the wxSFMLCanvas class. This kind of functions are usually declared by a macro (DECLARE_EVENT_TABLE?), and implemented by another one (BEGIN_EVENT_TABLE/END_EVENT_TABLE). Maybe you forgot this second step? It's not shown in the tutorial, but it's in the complete downloadable source code at the bottom of the page.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Another SFML2 + wxWidgets thread..
« Reply #2 on: September 13, 2011, 07:59:39 am »
I can see from this screenshot that it's indeed missing :lol:

https://legacy.sfmluploads.org/cache/pics/119_noname-test.PNG
Laurent Gomila - SFML developer

Haikarainen

  • Guest
Another SFML2 + wxWidgets thread..
« Reply #3 on: September 13, 2011, 04:12:06 pm »
Lol well would you look at that :) will go through the full sourcecode.

BTW my current revision isnt that old, max 1 week.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Another SFML2 + wxWidgets thread..
« Reply #4 on: September 13, 2011, 04:14:48 pm »
Quote
BTW my current revision isnt that old, max 1 week.

Yeah, sorry I misread the code. It's wxWidgets that returns a void* and SFML that requires a HWND. I thought it was the other way round.
So the cast is expected now but wasn't in older versions of SFML, you're perfectly right.
Laurent Gomila - SFML developer

Haikarainen

  • Guest
Another SFML2 + wxWidgets thread..
« Reply #5 on: September 13, 2011, 04:18:26 pm »
Quote from: "Laurent"
Quote
BTW my current revision isnt that old, max 1 week.

Yeah, sorry I misread the code. It's wxWidgets that returns a void* and SFML that requires a HWND. I thought it was the other way round.
So the cast is expected now but wasn't in older versions of SFML, you're perfectly right.


Allright, well just fyi; The complete tutorial files works perfectly copypasted, except for that one line :) Or at least it compiles with no warnings, WinXP MinGW-GCC, Codeblocks, Dont know the SFML version but the folder says "d6a40cf".

Haikarainen

  • Guest
Another SFML2 + wxWidgets thread..
« Reply #6 on: September 13, 2011, 05:23:17 pm »
Hmm got stuck again..

Code: [Select]
new Canvas_MapViewer(this, wxID_ANY, wxPoint(50, 50), wxSize(700, 500));

Results in:

Code: [Select]
In constructor 'nnmeFrame::nnmeFrame(wxFrame*, const wxString&)':|
error: no matching function for call to 'Canvas_MapViewer::Canvas_MapViewer(nnmeFrame* const, <anonymous enum>, wxPoint, wxSize)'|
note: candidates are: Canvas_MapViewer::Canvas_MapViewer(wxWindow*, wxWindowID, wxPoint&, wxSize&, long int)|
note:                 Canvas_MapViewer::Canvas_MapViewer(const Canvas_MapViewer&)|
||=== Build finished: 1 errors, 0 warnings ===|


Canvas_MapViewer is basically "MyCanvas" in the examples. MyCanvas is copypasted to mapviewer, wxsfmlcanvas is also copy pasted.

nnmeFrame is a derived wxFrame, and I've tried it the tutorialway too without any success

Haikarainen

  • Guest
Another SFML2 + wxWidgets thread..
« Reply #7 on: September 13, 2011, 07:16:51 pm »
bump

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Another SFML2 + wxWidgets thread..
« Reply #8 on: September 13, 2011, 09:56:16 pm »
Quote
bump

Seriously? ... This is not a chat.

Quote
error: no matching function for call to 'Canvas_MapViewer::Canvas_MapViewer(nnmeFrame* const, <anonymous enum>, wxPoint, wxSize)'|
note: candidates are: Canvas_MapViewer::Canvas_MapViewer(wxWindow*, wxWindowID, wxPoint&, wxSize&, long int)|

Does nnmeFrame* inherit from wxWindow?
Why are the point and size arguments non-const references (which forbids to pass non-named temporary variables)?
Laurent Gomila - SFML developer

Haikarainen

  • Guest
Another SFML2 + wxWidgets thread..
« Reply #9 on: September 13, 2011, 10:07:48 pm »
Quote
Does nnmeFrame* inherit from wxWindow?

No, but wxFrame(wich inherits from wxWindow)

Quote
Why are the point and size arguments non-const references (which forbids to pass non-named temporary variables)?


Kinda copy&pasted from tutorial, thanks, works now!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Another SFML2 + wxWidgets thread..
« Reply #10 on: September 13, 2011, 10:14:31 pm »
Quote
No, but wxFrame(wich inherits from wxWindow)

So... yes ;)

Quote
Kinda copy&pasted from tutorial, thanks, works now!

He he, be careful when copy-pasting, it's easy to let an error sneak in :P
Laurent Gomila - SFML developer

 

anything