At the moment, I am just allocating more than I need in an array.
That sounds like you're not familiar with STL containers. I strongly recommend to have a look at them, they simplify dynamic management of multiple elements tremendously.
...and yes... I'm still new to programming.
I tried with Vectors... but it's a pain in the backside... was wondering if there are better options than this:
#include <SFML/Graphics.hpp>
#include <vector>
class WindowPanels {
public:
WindowPanels(sf::RenderWindow &a_window) : m_window(a_window)
{
};
WindowPanels(const WindowPanels& a_window) : m_window(a_window.m_window)
{
};
WindowPanels& operator= (const WindowPanels& game_object)
{
};
sf::RenderWindow& m_window;
};
int main()
{
std::vector<WindowPanels> wp_test;
sf::RenderWindow *t_win;
for (int i = 0; i < 10; i++)
{
t_win = new sf::RenderWindow;
WindowPanels p_win(*t_win);
wp_test.push_back(p_win);
}
wp_test[0].m_window.create(sf::VideoMode(640, 480), "A.C.E. System Control", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[1].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 01", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[2].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 02", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[3].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 03", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[4].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 04", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[5].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 05", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[6].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 06", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[7].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 07", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
wp_test[8].m_window.create(sf::VideoMode(320, 240), "A.C.E. Panel 08", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
sf::Event mE;
while (wp_test[0].m_window.isOpen())
{
while (wp_test[0].m_window.pollEvent(mE))
{
switch (mE.type)
{
case sf::Event::Closed:
wp_test[0].m_window.close();
break;
case sf::Event::KeyPressed:
if (mE.key.code == sf::Keyboard::Escape)
{
wp_test[0].m_window.close();
}
break;
}
}
//clear/update/display
}
}
I'm trying to make render manager to output to different windows depending on what state my application is in, and what objects need to be drawn.
this was my first attempt at it:
m_output->Run();
m_output->m_window[0].create(sf::VideoMode(640, 480), "A.C.E. System Control", sf::Style::Titlebar | sf::Style::Close, sf::ContextSettings(0U, 0U, 8));
//m_output->m_window[0].setPosition(sf::Vector2i(0, 0));
m_output->m_window[0].setPosition(sf::Vector2i(m_core->m_displayWidth - (m_output->m_window[0].getSize().x + 15), 0));
while (m_output->m_window[0].isOpen())
{
while (m_output->m_window[0].pollEvent(m_input->m_event))
{
switch (m_input->m_event.type)
{
case sf::Event::Closed:
m_output->m_window[0].close();
break;
case sf::Event::KeyPressed:
if (m_input->m_event.key.code == sf::Keyboard::Escape)
{
m_output->m_window[0].close();
}
}//switch
}//pollEvent
m_output->m_window[0].clear();
m_output->m_window[0].display();
}//mainWindow.isOpen