1
Window / Re: Is it possible for dynamic RenderWindow creation at runtime? (Multiple Windows)
« on: July 16, 2015, 03:45:47 pm »
I tried again, and I think it's working, but does anyone have any suggestions as to what I could do to clean up my code a little?
Thanks.
class Output : public Module
{
public:
struct WindowPanel
{
WindowPanel(sf::RenderWindow &a_window) : m_window(&a_window)
{
}
WindowPanel(const WindowPanel& a_window) : m_window(a_window.m_window)
{
}
WindowPanel& operator= (const WindowPanel& a_window)
{
}
sf::RenderWindow *m_window;
};
Output();
void CreatePanel();
std::vector<WindowPanel> m_screen;
};
{
public:
struct WindowPanel
{
WindowPanel(sf::RenderWindow &a_window) : m_window(&a_window)
{
}
WindowPanel(const WindowPanel& a_window) : m_window(a_window.m_window)
{
}
WindowPanel& operator= (const WindowPanel& a_window)
{
}
sf::RenderWindow *m_window;
};
Output();
void CreatePanel();
std::vector<WindowPanel> m_screen;
};
void Output::CreatePanel()
{
sf::RenderWindow* f_win;
f_win = new sf::RenderWindow;
WindowPanel f_wpan(*f_win);
m_screen.push_back(f_wpan);
}
{
sf::RenderWindow* f_win;
f_win = new sf::RenderWindow;
WindowPanel f_wpan(*f_win);
m_screen.push_back(f_wpan);
}
void Application::Run()
{
m_output->CreatePanel();
m_output->m_screen[Module::MAINSCREEN].m_window->create(sf::VideoMode(640, 480), "A.C.E. System Control", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
m_output->m_screen[Module::MAINSCREEN].m_window->setPosition(sf::Vector2i(m_core->GetDisplaySize().x - (m_output->m_screen[Module::MAINSCREEN].m_window->getSize().x + 15), 0));
while (m_output->m_screen[Module::MAINSCREEN].m_window->isOpen())
{
while (m_output->m_screen[Module::MAINSCREEN].m_window->pollEvent(m_input->m_event))
{
switch (m_input->m_event.type)
{
case sf::Event::Closed:
m_output->m_screen[Module::MAINSCREEN].m_window->close();
break;
case sf::Event::KeyPressed:
if (m_input->m_event.key.code == sf::Keyboard::Escape)
{
m_output->m_screen[Module::MAINSCREEN].m_window->close();
}
}//switch
}//pollEvent
m_output->m_screen[Module::MAINSCREEN].m_window->clear();
m_output->m_screen[Module::MAINSCREEN].m_window->display();
}//mainWindow.isOpen
}
{
m_output->CreatePanel();
m_output->m_screen[Module::MAINSCREEN].m_window->create(sf::VideoMode(640, 480), "A.C.E. System Control", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
m_output->m_screen[Module::MAINSCREEN].m_window->setPosition(sf::Vector2i(m_core->GetDisplaySize().x - (m_output->m_screen[Module::MAINSCREEN].m_window->getSize().x + 15), 0));
while (m_output->m_screen[Module::MAINSCREEN].m_window->isOpen())
{
while (m_output->m_screen[Module::MAINSCREEN].m_window->pollEvent(m_input->m_event))
{
switch (m_input->m_event.type)
{
case sf::Event::Closed:
m_output->m_screen[Module::MAINSCREEN].m_window->close();
break;
case sf::Event::KeyPressed:
if (m_input->m_event.key.code == sf::Keyboard::Escape)
{
m_output->m_screen[Module::MAINSCREEN].m_window->close();
}
}//switch
}//pollEvent
m_output->m_screen[Module::MAINSCREEN].m_window->clear();
m_output->m_screen[Module::MAINSCREEN].m_window->display();
}//mainWindow.isOpen
}
Thanks.