/*
 * This source file is part of KEOS (Free 3D Engine)
 * For the latest info, see http://www.keosengine.org/
 * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
 * http://www.gnu.org/copyleft/lesser.txt.
 *
 */

#ifndef KEOS_RENDERWINDOW_H
#define KEOS_RENDERWINDOW_H

#include "KeosPrerequisites.h"
#include "KeosRenderTarget.h"

namespace Keos
{
    //-----------------------------------------------------------------------
    /** Manages the target rendering window.
     *  This class handles a window into which the contents
     *  of a scene are rendered. 
     *  This class is abstract since there may be
     *  different implementations for different windowing systems.
     */
    class KEOS_EXPORT IRenderWindow : public IRenderTarget
    {
    public:
        /** Default constructor.
         */
        IRenderWindow();

        /** Creates & displays the new window.
         *  @param strName Name and title of the window.
         *  @param nWidth The width of the window in pixels.
         *  @param nHeight The height of the window in pixels.
         *  @param nColourDepth The colour depth in bits. Ignored if
         *      fullScreen is false since the desktop depth is used.
         *  @param bFullScreen If true, the window fills the screen.
         */
		virtual void Create(const String& strName, uint nWidth, uint nHeight, uint nColourDepth, bool bFullScreen) = 0;
        
        /** Destroys the window.
         */
        virtual void Destroy(void) = 0;

        /** Alter the size of the window.
         *  @param nWidth The new width.
         *  @param nHeight The new height.
         */
        virtual void Resize(uint nWidth, uint nHeight) = 0;

        /** Reposition the window.
         *  @param nLeft The new left position.
         *  @param nTop The new top position.
         */
        virtual void Reposition(int nLeft, int nTop) = 0;

        /** Indicates whether the window has been closed by the user.
         */
        virtual bool IsClosed(void) const = 0;
		
        /** Swaps the frame buffers to display the next frame.
         *   @param
         *      bWaitForVSync If true, the system waits for the
         *      next vertical blank period (when the CRT beam turns off
         *      as it travels from bottom-right to top-left at the
         *      end of the pass) before flipping. If false, flipping
         *      occurs no matter what the beam position. Waiting for
         *      a vertical blank can be slower (and limits the
         *      framerate to the monitor refresh rate) but results
         *      in a steadier image with no 'tearing' (a flicker
         *      resulting from flipping buffers when the beam is
         *      in the progress of drawing the last frame).
         */
        virtual void SwapBuffers(bool bWaitForVSync = true) = 0;

        /** Returns true if window is running in fullscreen mode.
         */
        virtual bool IsFullScreen(void) const;

        /** Overloaded version of getMetrics from RenderTarget, including extra details
         *  specific to windowing systems.
         *  @param nWidth Window's width.
         *  @param nHeight Window's height.
         *  @param nColourDepth Window's colour depth.
         *  @param nLeft Window's left position.
         *  @param nTop Window's top position.
         */
        virtual void GetMetrics(uint& nWidth, uint& nHeight, uint& nColourDepth, 
			                        int& nLeft, int& nTop);

    protected:
        //! Fullscreen mode
        bool m_bIsFullScreen;
       
        //! Left position
        int m_nLeft;
        //! Top position
        int m_nTop;
    };

    //=======================================================================
    // IRenderWindow inline functions
    //=======================================================================

    //-----------------------------------------------------------------------
    inline bool IRenderWindow::IsFullScreen(void) const
    {
        return m_bIsFullScreen;
    }

} // Namespace Keos

#endif // KEOS_RENDERWINDOW_H
