/*
 * 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_RENDERSYSTEMCAPABILITIES_H
#define KEOS_RENDERSYSTEMCAPABILITIES_H

#include "KeosPrerequisites.h"

namespace Keos
{
    //! Enum describing the different hardware capabilities we want to check for
    enum TCapability
    {
        //! Supports generating mipmaps in hardware
        CAP_HW_MIPMAPPING           = 0x00000001,
        //! Supports compressed textures in the DXT/ST3C formats
		CAP_TEXTURE_COMPRESSION_DXT = 0x00000002,
        //! Supports non-power of two textures
        CAP_NON_POWER_OF_2_TEXTURES = 0x00000004,
        //! Supports vertex programs (vertex shaders)
		CAP_VERTEX_PROGRAM          = 0x00000008,
        //! Supports fragment programs (pixel shaders)
		CAP_FRAGMENT_PROGRAM        = 0x00000010,
   

// not yet support
/*        //RSC_MULTITEXTURE          = 0x00000001,
        RSC_BLENDING                = 0x00000004,
        /// Supports anisotropic texture filtering
        RSC_ANISOTROPY              = 0x00000008,
        /// Supports fixed-function DOT3 texture blend
        RSC_DOT3                    = 0x00000010,
        /// Supports cube mapping
        RSC_CUBEMAPPING             = 0x00000020,
        /// Supports hardware stencil buffer
        RSC_HWSTENCIL               = 0x00000040,
        /// Supports hardware vertex and index buffers
        RSC_VBO                     = 0x00000080,
        /// Supports compressed textures
		RSC_TEXTURE_COMPRESSION     = 0x00000800,
        /// Supports compressed textures in the VTC format
		RSC_TEXTURE_COMPRESSION_VTC = 0x00002000,
        /// Supports performing a scissor test to exclude areas of the screen
        RSC_SCISSOR_TEST            = 0x00004000,
        /// Supports separate stencil updates for both front and back faces
        RSC_TWO_SIDED_STENCIL       = 0x00008000,
        /// Supports wrapping the stencil value at the range extremeties
        RSC_STENCIL_WRAP            = 0x00010000,
        /// Supports hardware occlusion queries
        RSC_HWOCCLUSION				= 0x00020000,
        /// Supports user clipping planes
        RSC_USER_CLIP_PLANES		= 0x00040000,
		/// Supports the VET_UBYTE4 vertex element type
		RSC_VERTEX_FORMAT_UBYTE4	= 0x00080000,
		/// Supports infinite far plane projection
		RSC_INFINITE_FAR_PLANE      = 0x00100000,
        /// Supports hardware render-to-texture (bigger than framebuffer)
        RSC_HWRENDER_TO_TEXTURE     = 0x00200000,
        /// Supports float textures and render targets
        RSC_TEXTURE_FLOAT           = 0x00400000,
		/// Supports 3d (volume) textures
		RSC_TEXTURE_3D				= 0x01000000
*/
    };

    //-----------------------------------------------------------------------
    /** Class for storing the capabilities of the graphics card.
     * 
     */
    class KEOS_EXPORT CRenderSystemCapabilities 
    {
        private:
         
            //! The number of texture units available
            ushort m_nNumTextureUnits;
            //! The best vertex program that this card / rendersystem supports
            String m_strMaxVertexProgramVersion;
            //! The best fragment program that this card / rendersystem supports
            String m_strMaxFragmentProgramVersion;
            
            //! Stores the capabilities flags
            int m_nCapabilities;

    	public:	

            /** Default constructor.
             */
            CRenderSystemCapabilities ();

            /** Destructor.
             */
            ~CRenderSystemCapabilities ();

            /** Set the number of texture units the current output hardware
             *  supports.
             */
            void SetNumTextureUnits(ushort nNum)
            {
                m_nNumTextureUnits = nNum;
            }

            /** Return the number of texture units the current output hardware
             *  supports.
             */
            ushort GetNumTextureUnits(void) const
            {
                return m_nNumTextureUnits;
            }

            /** Adds a capability flag to m_nCapabilities.
             */
            void SetCapability(const TCapability c) 
            { 
                m_nCapabilities |= c;
            }

            /** Checks for a capability.
             */
            bool HasCapability(const TCapability c) const
            {
                if(m_nCapabilities & c)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

            /** Gets the best low-level vertex program version supported.
             */
            const String& GetMaxVertexProgramVersion(void) const
            {
                return m_strMaxVertexProgramVersion;
            }

            /** Gets the best fragment program that this card / rendersystem supports.
             */
            const String& GetMaxFragmentProgramVersion(void) const
            {
                return m_strMaxFragmentProgramVersion;
            }

            /** Sets the best low-level vertex program version supported.
             */
            void SetMaxVertexProgramVersion(const String& strVer)
            {
                m_strMaxVertexProgramVersion = strVer;
            }

            /** Sets the best fragment program that this card / rendersystem supports.
             */
            void SetMaxFragmentProgramVersion(const String& strVer)
            {
                m_strMaxFragmentProgramVersion = strVer;
            }

            /** Write the capabilities in the logger. 
             */
            void Log();

    };

} // namespave Keos

#endif // KEOS_RENDERSYSTEMCAPABILITIES_H

