I am working on a very simple world editor, just something that allows me to load a dotScene and select options. I am using wxWidgets and luke's dotsceneloader from the wiki.
The only problem is that I use wxWidgets to select the file, which returns the path to the file in a wxString. How would I then pass this to the dotsceneloader?
Convert wxString to Ogre::String
- Game_Ender
- Ogre Magi
- Posts: 1269
- Joined: Wed May 25, 2005 2:31 am
- Location: Rockville, MD, USA
Ogre::String is just a typedef of std::string, so just look up in the wxWidgets docs how to convert a wxString to a std::string. The first step is probably conversion to a char*.
Robotics @ Maryland AUV Team - Software Lead
-
- OGRE Retired Team Member
- Posts: 2903
- Joined: Thu Jan 18, 2007 2:48 pm
- x 58
- Contact:
wxWidget's disregarding of STL is a huge pain in the ass, imho. Converting wxString to std::string is just one of it. But anyway, here are two quick helper functions to do it:
You might want to change the encoding to suit your needs, though UTF-8 should be fine for most cases.
Code: Select all
inline wxString conv(const std::string& s)
{
return wxString(s.c_str(), wxConvUTF8);
}
inline std::string conv(const wxString& s)
{
return std::string(s.mb_str(wxConvUTF8));
}