/*Copyright (C) 2010-2012 Duncan Deveaux

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEF_WINDOW
#define DEF_WINDOW

#include <SDL/SDL.h>
#include "Graphics/GL.hpp"

#include "Tools/Timer.hpp"

#include "Structs/Vector.hpp"
#include "Structs/Box.hpp"
#include "Structs/Color.hpp"
#include <string>

class Window
{
    public:
        Window();
        Window(const std::string &title, int width, int height, int bitsPerPixel, bool fullscreen);
        
        void init(int width, int height, int bitsPerPixel, bool fullscreen);
        void initView(float viewWidth, float viewHeight);
        
        void resize(int width, int height, bool fullscreen);
        
        void clear(const Color &color = Color());
        void flush();
        
        void pollEvent(SDL_Event &event);
        void waitEvent(SDL_Event &event);
        
        Vector viewCoords(const Vector &windowCoords) const;
        Vector windowCoords(const Vector &viewCoords) const;
        
        //Get and set methods
        void setTitle(const std::string &title);
        const std::string &getTitle() const;
        
        void setFrameRate(float frameRate);
        float getFrameRate() const;
        
        int getWidth() const;
        int getHeight() const;
        int getBitsPerPixel() const;
        
        float getViewWidth() const;
        float getViewHeight() const;
    
    private:
        std::string m_title;
        SDL_Surface *m_screen;
        
        float m_viewWidth, m_viewHeight;
        Box m_viewPort;
        
        Uint32 m_frameRate;
        Timer m_time;
};

#endif
