HI !
I'm beginner and trying to write a simple app which creates a basic window based on properties the user enters .
Now I want to try to save the current state and load it later , thus I'm using a struct :
struct SLInfo
{
sf::ContextSettings winMainSettings ; //winMain.getSettings ()
sf::WindowHandle winMainSystemHandle ; //winMain.getSystemHandle ()
}
and a function to save :
int SaveCurrentState (sf::RenderWindow & winMain)
{
SLInfo Info ;
ofstream SaveFile ("some_file" , ios::binary) ;
Info.winMainSettings = winMain.getSettings () ;
Info.winMainSystemHandle = winMain.getSystemHandle () ;
SaveFile.write (reinterpret_cast <char *> (& Info) , sizeof (Info)) ;
return 1 ;
}
(is that refrence sign (&) before winMain correct?)
(Most of the code is omitted so that it looks simple and easier for you to check it)
and a function to load :
SLInfo LoadFile (string FileName)
{
ifstream LoadLoc (FileName.c_str () , ios::binary) ;
SLInfo Loader ;
LoadLoc.read (reinterpret_cast <char *> (& Loader) , sizeof (Loader)) ;
return Loader ;
}
Then in another function I open the window like this :
SLInfo winMainInfo ;
string FileName ;
cout << "\nEnter file name :\n" ;
cin >> FileName ;
winMainInfo = LoadFile (FileName.c_str ()) ;
sf::RenderWindow winMain (winMainInfo.winMainSystemHandle , winMainInfo.winMainSettings) ;
(+ while window.isOpen () and event handlings , I omitted those parts too)
But when I run it (using Code::Blocks 12.11) I see these messages in console :
Failed to set pixel format for device context -- cannot creat OpenGL context
Failed to activate the window's context
Failed to activate the window's context
And I see no window at all .
Thanks in advanced for helping.
And if there is any additional info on my code needs to be provided let me know .
Thanks .