/* * ===================================================================================== * * Filename: InventoryState.cpp * * Description: * * Created: 20/06/2018 23:13:50 * * Author: Quentin Bazin, * * ===================================================================================== */ #include "ApplicationStateStack.hpp" #include "InventoryState.hpp" #include "Mouse.hpp" InventoryState::InventoryState(ApplicationState *parent) : ApplicationState(parent) { m_shader.createProgram(); m_shader.addShader(GL_VERTEX_SHADER, "shaders/basic.v.glsl"); m_shader.addShader(GL_FRAGMENT_SHADER, "shaders/basic.f.glsl"); m_shader.linkProgram(); Mouse::setCursorGrabbed(false); Mouse::setCursorVisible(true); Mouse::resetToWindowCenter(); } void InventoryState::onEvent(const SDL_Event &event) { // if (m_parent) // m_parent->onEvent(event); if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) { Mouse::setCursorGrabbed(true); Mouse::setCursorVisible(false); m_stateStack->pop(); } m_widget.onEvent(event); } void InventoryState::update() { if (m_parent) m_parent->update(); } void InventoryState::draw(RenderTarget &target, RenderStates states) const { if (m_parent) target.draw(*m_parent); states.shader = &m_shader; target.draw(m_widget, states); }