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

Author Topic: Text in subwindow not showing.  (Read 2552 times)

0 Members and 1 Guest are viewing this topic.

Sirt

  • Newbie
  • *
  • Posts: 27
    • View Profile
Text in subwindow not showing.
« 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 ]

Code: [Select]

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();
        }
    }
}

Code: [Select]

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 +++++++++++++
Code: [Select]

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 ......
}

Sirt

  • Newbie
  • *
  • Posts: 27
    • View Profile
Text in subwindow not showing.
« Reply #1 on: August 29, 2009, 11:55:11 am »
Sorry,a logical error of mine.
Feel free to delete this post since it's misleading.