int main() { // Create the main rendering window App.Create(sf::VideoMode(640,480,32), "SFML Graphics"); UIState uistate; uistate.renderer = &App; InitEntities(); PhysicsSub physSub(&App, &entitysystem); RenderingSystem renderSys(&App, &entitysystem); ControllerSystem controller(&App, &entitysystem); ProjectileSystem projSys(&App, &entitysystem); bool inventory = false; int invX; int invY; std::vector<Entity*> players; entitysystem.getEntities<CompPlayer>(players); Entity* player = players[0]; // Start game loop while (App.IsOpen()) { // Process events sf::Event Event; while (App.PollEvent(Event)) { uistate.uiEvents(Event); // Close window : exit if (Event.Type == sf::Event::Closed) App.Close(); if(Event.Type == sf::Event::MouseButtonPressed && Event.MouseButton.Button == sf::Mouse::Right) { inventory = !inventory; if(inventory) invX = sf::Mouse::GetPosition(App).x; invY = sf::Mouse::GetPosition(App).y; } if(Event.Type == sf::Event::MouseButtonPressed && Event.MouseButton.Button == sf::Mouse::Left) makeProjectile(); } controller.Tick(Clock.GetElapsedTime().AsSeconds()); physSub.Tick(Clock.GetElapsedTime().AsSeconds()); projSys.Tick(Clock.GetElapsedTime().AsSeconds()); // Clear the screen with red color App.Clear(sf::Color::Black); uistate.imgui_prepare(); if(widget::button(uistate, GEN_ID, sf::Vector2f(100, 30), sf::Vector2f(520, 10), "button", 24)) entitysystem.deleteEntity(player); if(inventory) if(widget::button(uistate, GEN_ID, sf::Vector2f(100, 30), sf::Vector2f(invX, invY), "inventory", 20)) player = makePlayer(); uistate.imgui_finish(); renderSys.Tick(Clock.GetElapsedTime().AsSeconds()); // Display window contents on screen App.Display(); Clock.Restart(); } return EXIT_SUCCESS; }
void renderer::clearFrameBuffer(unsigned buffers, const colour &c, float d, unsigned short s) const { renderSys()->_setViewport(_viewport); renderSys()->clearFrameBuffer(buffers, c, d, s); }