7
« on: August 29, 2009, 11:19:12 am »
Okay here's a test code I wrote,
no text is being output to the subwindow (mode_window)
and I don't know why?
See the bottom of this post for the main loop and
you should have no problem understanding whats going on.
oss - a globally defined ostringstream
mode[] - bool mode[ NUMBER_OF_MODES ]
void Display::set_mode (const int which)
{
mode[which] = (mode[which] ? false : true);
if (which == MODE_INSPECT)
{
if (mode[which])
{
mode_window.Create( sf::VideoMode(256, 192,32), "",
sf::Style::None);
populate_mode_window();
}
else
{
mode_window.Close();
}
}
}
void Display::populate_mode_window()
{
sf::String text("", font);
text.SetColor( sf::Color( 250, 234, 200 ));
text.SetSize( 10.0 );
mode_window.Clear( sf::Color(0, 0, 255) );
oss << "Can I see this text!";
text.SetText( oss.str() );
oss.str("");
mode_window.Draw( text );
mode_window.Display();
}
++++++++++++ Main.cpp +++++++++++++
display.set_mode( MODE_INSPECT );
while (App.IsOpened())
{
while (display.mode_window.IsOpened())
{
while (display.mode_window.GetEvent(display.Event))
{
if ((display.Event.Type == sf::Event::KeyPressed)
&& (display.Event.Key.Code == sf::Key::L))
{ // This will close the mode_window
display.set_mode( MODE_INSPECT );
break;
}
}
}
// Main window operations here ......
}