#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
#define BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP

// Boost.Geometry - extensions-gis-projections (based on PROJ4)
// This file is automatically generated. DO NOT EDIT.

// Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

// This file is converted from PROJ4, http://trac.osgeo.org/proj
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
// PROJ4 is maintained by Frank Warmerdam
// PROJ4 is converted to Boost.Geometry by Barend Gehrels

// Last updated version of proj: 4.9.1

// Original copyright notice:

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#include <boost/geometry/util/math.hpp>

#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>

namespace boost { namespace geometry { namespace projections
{
    #ifndef DOXYGEN_NO_DETAIL
    namespace detail { namespace vandg2
    {

            static const double TOL = 1e-10;
            static const double TWORPI = 0.63661977236758134308;

            struct par_vandg2
            {
                int    vdg3;
            };

            // template class, using CRTP to implement forward/inverse
            template <typename Geographic, typename Cartesian, typename Parameters>
            struct base_vandg2_spheroid : public base_t_f<base_vandg2_spheroid<Geographic, Cartesian, Parameters>,
                     Geographic, Cartesian, Parameters>
            {

                 typedef double geographic_type;
                 typedef double cartesian_type;

                par_vandg2 m_proj_parm;

                inline base_vandg2_spheroid(const Parameters& par)
                    : base_t_f<base_vandg2_spheroid<Geographic, Cartesian, Parameters>,
                     Geographic, Cartesian, Parameters>(*this, par) {}

                // FORWARD(s_forward)  spheroid
                // Project coordinates from geographic (lon, lat) to cartesian (x, y)
                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
                {
                    double x1, at, bt, ct;

                    bt = fabs(TWORPI * lp_lat);
                    if ((ct = 1. - bt * bt) < 0.)
                        ct = 0.;
                    else
                        ct = sqrt(ct);
                    if (fabs(lp_lon) < TOL) {
                        xy_x = 0.;
                        xy_y = geometry::math::pi<double>() * (lp_lat < 0. ? -bt : bt) / (1. + ct);
                    } else {
                        at = 0.5 * fabs(geometry::math::pi<double>() / lp_lon - lp_lon / geometry::math::pi<double>());
                        if (this->m_proj_parm.vdg3) {
                            x1 = bt / (1. + ct);
                            xy_x = geometry::math::pi<double>() * (sqrt(at * at + 1. - x1 * x1) - at);
                            xy_y = geometry::math::pi<double>() * x1;
                        } else {
                            x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
                                (1. + at * at * bt * bt);
                            xy_x = geometry::math::pi<double>() * x1;
                            xy_y = geometry::math::pi<double>() * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
                        }
                        if ( lp_lon < 0.) xy_x = -xy_x;
                        if ( lp_lat < 0.) xy_y = -xy_y;
                    }
                }

                static inline std::string get_name()
                {
                    return "vandg2_spheroid";
                }

            };

            // van der Grinten II
            template <typename Parameters>
            void setup_vandg2(Parameters& par, par_vandg2& proj_parm)
            {
                proj_parm.vdg3 = 0;
            }

            // van der Grinten III
            template <typename Parameters>
            void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
            {
                proj_parm.vdg3 = 1;
                par.es = 0.;
            }

        }} // namespace detail::vandg2
    #endif // doxygen

    /*!
        \brief van der Grinten II projection
        \ingroup projections
        \tparam Geographic latlong point type
        \tparam Cartesian xy point type
        \tparam Parameters parameter type
        \par Projection characteristics
         - Miscellaneous
         - Spheroid
         - no inverse
        \par Example
        \image html ex_vandg2.gif
    */
    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
    struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>
    {
        inline vandg2_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>(par)
        {
            detail::vandg2::setup_vandg2(this->m_par, this->m_proj_parm);
        }
    };

    /*!
        \brief van der Grinten III projection
        \ingroup projections
        \tparam Geographic latlong point type
        \tparam Cartesian xy point type
        \tparam Parameters parameter type
        \par Projection characteristics
         - Miscellaneous
         - Spheroid
         - no inverse
        \par Example
        \image html ex_vandg3.gif
    */
    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
    struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>
    {
        inline vandg3_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>(par)
        {
            detail::vandg2::setup_vandg3(this->m_par, this->m_proj_parm);
        }
    };

    #ifndef DOXYGEN_NO_DETAIL
    namespace detail
    {

        // Factory entry(s)
        template <typename Geographic, typename Cartesian, typename Parameters>
        class vandg2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
        {
            public :
                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
                {
                    return new base_v_f<vandg2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
                }
        };

        template <typename Geographic, typename Cartesian, typename Parameters>
        class vandg3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
        {
            public :
                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
                {
                    return new base_v_f<vandg3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
                }
        };

        template <typename Geographic, typename Cartesian, typename Parameters>
        inline void vandg2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
        {
            factory.add_to_factory("vandg2", new vandg2_entry<Geographic, Cartesian, Parameters>);
            factory.add_to_factory("vandg3", new vandg3_entry<Geographic, Cartesian, Parameters>);
        }

    } // namespace detail
    #endif // doxygen

}}} // namespace boost::geometry::projections

#endif // BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP


// Copyright (c) 2012 Christopher Lux <christopherlux@gmail.com>
// Distributed under the Modified BSD License, see license.txt.

#include <cassert>

#include <boost/static_assert.hpp>

#include <scm/gl_core/render_device/opengl/gl_core.h>

namespace scm {
namespace gl {
namespace util {

inline
unsigned
gl_internal_format(const data_format d)
{
    static unsigned gl_int_fmts[] = {
        GL_NONE,        // FORMAT_NULL                 = 0x00u,

        // normalized integer formats (NORM)
        GL_R8,          // FORMAT_R_8,
        GL_RG8,         // FORMAT_RG_8,
        GL_RGB8,        // FORMAT_RGB_8,
        GL_RGBA8,       // FORMAT_RGBA_8,

        GL_R16,         // FORMAT_R_16,
        GL_RG16,        // FORMAT_RG_16,
        GL_RGB16,       // FORMAT_RGB_16,
        GL_RGBA16,      // FORMAT_RGBA_16,

        GL_R8_SNORM,    // FORMAT_R_8S,
        GL_RG8_SNORM,   // FORMAT_RG_8S,
        GL_RGB8_SNORM,  // FORMAT_RGB_8S,
        GL_RGBA8_SNORM, // FORMAT_RGBA_8S,

        GL_R16_SNORM,   // FORMAT_R_16S,
        GL_RG16_SNORM,  // FORMAT_RG_16S,
        GL_RGB16_SNORM, // FORMAT_RGB_16S,
        GL_RGBA16_SNORM,// FORMAT_RGBA_16S,

        // swizzled integer formats
        GL_RGB8,        // FORMAT_BGR_8,
        GL_RGBA8,       // FORMAT_BGRA_8,

        // srgb integer formats
        GL_SRGB8,       // FORMAT_SRGB_8,
        GL_SRGB8_ALPHA8,// FORMAT_SRGBA_8,

        // unnormalized integer formats (UNORM)
        GL_R8I,         // FORMAT_R_8I,
        GL_RG8I,        // FORMAT_RG_8I,
        GL_RGB8I,       // FORMAT_RGB_8I,
        GL_RGBA8I,      // FORMAT_RGBA_8I,

        GL_R16I,        // FORMAT_R_16I,
        GL_RG16I,       // FORMAT_RG_16I,
        GL_RGB16I,      // FORMAT_RGB_16I,
        GL_RGBA16I,     // FORMAT_RGBA_16I,

        GL_R32I,        // FORMAT_R_32I,
        GL_RG32I,       // FORMAT_RG_32I,
        GL_RGB32I,      // FORMAT_RGB_32I,
        GL_RGBA32I,     // FORMAT_RGBA_32I,

        GL_R8UI,        // FORMAT_R_8UI,
        GL_RG8UI,       // FORMAT_RG_8UI,
        GL_RGB8UI,      // FORMAT_RGB_8UI,
        GL_RGBA8UI,     // FORMAT_RGBA_8UI,

        GL_R16UI,       // FORMAT_R_16UI,
        GL_RG16UI,      // FORMAT_RG_16UI,
        GL_RGB16UI,     // FORMAT_RGB_16UI,
        GL_RGBA16UI,    // FORMAT_RGBA_16UI,

        GL_R32UI,       // FORMAT_R_32UI,
        GL_RG32UI,      // FORMAT_RG_32UI,
        GL_RGB32UI,     // FORMAT_RGB_32UI,
        GL_RGBA32UI,    // FORMAT_RGBA_32UI,

        // floating point formats
        GL_R16F,        // FORMAT_R_16F,
        GL_RG16F,       // FORMAT_RG_16F,
        GL_RGB16F,      // FORMAT_RGB_16F,
        GL_RGBA16F,     // FORMAT_RGBA_16F,

        GL_R32F,        // FORMAT_R_32F,
        GL_RG32F,       // FORMAT_RG_32F,
        GL_RGB32F,      // FORMAT_RGB_32F,
        GL_RGBA32F,     // FORMAT_RGBA_32F,

        // special packed formats
        GL_RGB9_E5,     // FORMAT_RGB9_E5,
        GL_R11F_G11F_B10F,// FORMAT_R11B11G10F,

        // compressed formats
        GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,           //FORMAT_BC1_RGBA,        // DXT1
        GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,     //FORMAT_BC1_SRGBA,       // DXT1
        GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,           //FORMAT_BC2_RGBA,        // DXT3
        GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,     //FORMAT_BC2_SRGBA,       // DXT3
        GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,           //FORMAT_BC3_RGBA,        // DXT5
        GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,     //FORMAT_BC3_SRGBA,       // DXT5
        GL_COMPRESSED_RED_RGTC1,                    //FORMAT_BC4_R,           // RGTC1
        GL_COMPRESSED_SIGNED_RED_RGTC1,             //FORMAT_BC4_R_S,         // RGTC1
        GL_COMPRESSED_RG_RGTC2,                     //FORMAT_BC5_RG,          // RGTC2
        GL_COMPRESSED_SIGNED_RG_RGTC2,              //FORMAT_BC5_RG_S,        // RGTC2
        GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB,    //FORMAT_BC6H_RGB_F,      // BPTC
        GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB,  //FORMAT_BC6H_RGB_UF,     // BPTC
        GL_COMPRESSED_RGBA_BPTC_UNORM_ARB,          //FORMAT_BC7_RGBA,        // BPTC
        GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB,    //FORMAT_BC8_SRGBA,       // BPTC

        // depth stencil formats
        GL_DEPTH_COMPONENT16, // FORMAT_D16,
        GL_DEPTH_COMPONENT24, // FORMAT_D24,
        GL_DEPTH_COMPONENT32, // FORMAT_D32,
        GL_DEPTH_COMPONENT32F, // FORMAT_D32F,
        GL_DEPTH24_STENCIL8, // FORMAT_D24_S8,
        GL_DEPTH32F_STENCIL8 // FORMAT_D32F_S8,
    };

    BOOST_STATIC_ASSERT((sizeof(gl_int_fmts) / sizeof(unsigned)) == FORMAT_COUNT);

    assert(FORMAT_NULL <= d && d < FORMAT_COUNT);

    return gl_int_fmts[d];
}

inline
unsigned
gl_base_format(const data_format d)
{
    static unsigned gl_int_bfmts[] = {
        GL_NONE,        // FORMAT_NULL                 = 0x00u,

        // normalized integer formats (NORM)
        GL_RED,         // FORMAT_R_8,
        GL_RG,          // FORMAT_RG_8,
        GL_RGB,         // FORMAT_RGB_8,
        GL_RGBA,        // FORMAT_RGBA_8,

        GL_RED,         // FORMAT_R_16,
        GL_RG,          // FORMAT_RG_16,
        GL_RGB,         // FORMAT_RGB_16,
        GL_RGBA,        // FORMAT_RGBA_16,

        GL_RED,         // FORMAT_R_8S,
        GL_RG,          // FORMAT_RG_8S,
        GL_RGB,         // FORMAT_RGB_8S,
        GL_RGBA,        // FORMAT_RGBA_8S,

        GL_RED,         // FORMAT_R_16S,
        GL_RG,          // FORMAT_RG_16S,
        GL_RGB,         // FORMAT_RGB_16S,
        GL_RGBA,        // FORMAT_RGBA_16S,

        // swizzled integer formats
        GL_BGR,         // FORMAT_BGR_8,
        GL_BGRA,        // FORMAT_BGRA_8,

        // srgb integer formats
        GL_RGB,         // FORMAT_SRGB_8,
        GL_RGBA,        // FORMAT_SRGBA_8,

        // unnormalized integer formats (UNORM)
        GL_RED_INTEGER, // FORMAT_R_8I,
        GL_RG_INTEGER,  // FORMAT_RG_8I,
        GL_RGB_INTEGER, // FORMAT_RGB_8I,
        GL_RGBA_INTEGER,// FORMAT_RGBA_8I,

        GL_RED_INTEGER, // FORMAT_R_16I,
        GL_RG_INTEGER,  // FORMAT_RG_16I,
        GL_RGB_INTEGER, // FORMAT_RGB_16I,
        GL_RGBA_INTEGER,// FORMAT_RGBA_16I,

        GL_RED_INTEGER, // FORMAT_R_32I,
        GL_RG_INTEGER,  // FORMAT_RG_32I,
        GL_RGB_INTEGER, // FORMAT_RGB_32I,
        GL_RGBA_INTEGER,// FORMAT_RGBA_32I,

        GL_RED_INTEGER, // FORMAT_R_8UI,
        GL_RG_INTEGER,  // FORMAT_RG_8UI,
        GL_RGB_INTEGER, // FORMAT_RGB_8UI,
        GL_RGBA_INTEGER,// FORMAT_RGBA_8UI,

        GL_RED_INTEGER, // FORMAT_R_16UI,
        GL_RG_INTEGER,  // FORMAT_RG_16UI,
        GL_RGB_INTEGER, // FORMAT_RGB_16UI,
        GL_RGBA_INTEGER,// FORMAT_RGBA_16UI,

        GL_RED_INTEGER, // FORMAT_R_32UI,
        GL_RG_INTEGER,  // FORMAT_RG_32UI,
        GL_RGB_INTEGER, // FORMAT_RGB_32UI,
        GL_RGBA_INTEGER,// FORMAT_RGBA_32UI,

        // floating point formats
        GL_RED,         // FORMAT_R_16F,
        GL_RG,          // FORMAT_RG_16F,
        GL_RGB,         // FORMAT_RGB_16F,
        GL_RGBA,        // FORMAT_RGBA_16F,

        GL_RED,         // FORMAT_R_32F,
        GL_RG,          // FORMAT_RG_32F,
        GL_RGB,         // FORMAT_RGB_32F,
        GL_RGBA,        // FORMAT_RGBA_32F,

        // special packed formats
        GL_RGB,         // FORMAT_RGB9_E5,
        GL_RGB,         // FORMAT_R11B11G10F,

        // compressed formats
        GL_RGBA,        //FORMAT_BC1_RGBA,        // DXT1
        GL_RGBA,        //FORMAT_BC1_SRGBA,       // DXT1
        GL_RGBA,        //FORMAT_BC2_RGBA,        // DXT3
        GL_RGBA,        //FORMAT_BC2_SRGBA,       // DXT3
        GL_RGBA,        //FORMAT_BC3_RGBA,        // DXT5
        GL_RGBA,        //FORMAT_BC3_SRGBA,       // DXT5
        GL_RED,         //FORMAT_BC4_R,           // RGTC1
        GL_RED,         //FORMAT_BC4_R_S,         // RGTC1
        GL_RG,          //FORMAT_BC5_RG,          // RGTC2
        GL_RG,          //FORMAT_BC5_RG_S,        // RGTC2
        GL_RGB,         //FORMAT_BC6H_RGB_F,      // BPTC
        GL_RGB,         //FORMAT_BC6H_RGB_UF,     // BPTC
        GL_RGBA,        //FORMAT_BC7_RGBA,        // BPTC
        GL_RGBA,        //FORMAT_BC7_SRGBA,       // BPTC

        // depth stencil formats
        GL_DEPTH_COMPONENT, // FORMAT_D16,
        GL_DEPTH_COMPONENT, // FORMAT_D24,
        GL_DEPTH_COMPONENT, // FORMAT_D32,
        GL_DEPTH_COMPONENT, // FORMAT_D32F,
        GL_DEPTH_STENCIL, // FORMAT_D24_S8,
        GL_DEPTH_STENCIL // FORMAT_D32F_S8,
    };

    BOOST_STATIC_ASSERT((sizeof(gl_int_bfmts) / sizeof(unsigned)) == FORMAT_COUNT);

    assert(FORMAT_NULL <= d && d < FORMAT_COUNT);

    return gl_int_bfmts[d];
}

inline
unsigned
gl_base_type(const data_format d)
{
    static unsigned gl_btypes[] = {
        GL_NONE,        // FORMAT_NULL                 = 0x00u,

        // normalized integer formats (NORM)
        GL_UNSIGNED_BYTE,          // FORMAT_R_8,
        GL_UNSIGNED_BYTE,         // FORMAT_RG_8,
        GL_UNSIGNED_BYTE,        // FORMAT_RGB_8,
        GL_UNSIGNED_BYTE,       // FORMAT_RGBA_8,

        GL_UNSIGNED_SHORT,         // FORMAT_R_16,
        GL_UNSIGNED_SHORT,        // FORMAT_RG_16,
        GL_UNSIGNED_SHORT,       // FORMAT_RGB_16,
        GL_UNSIGNED_SHORT,      // FORMAT_RGBA_16,

        GL_BYTE,    // FORMAT_R_8S,
        GL_BYTE,   // FORMAT_RG_8S,
        GL_BYTE,  // FORMAT_RGB_8S,
        GL_BYTE, // FORMAT_RGBA_8S,

        GL_SHORT,   // FORMAT_R_16S,
        GL_SHORT,  // FORMAT_RG_16S,
        GL_SHORT, // FORMAT_RGB_16S,
        GL_SHORT,// FORMAT_RGBA_16S,

        // swizzled integer formats
        GL_UNSIGNED_BYTE,        // FORMAT_BGR_8,
        GL_UNSIGNED_INT_8_8_8_8_REV,       // FORMAT_BGRA_8,

        // srgb integer formats
        GL_UNSIGNED_BYTE,       // FORMAT_SRGB_8,
        GL_UNSIGNED_BYTE,// FORMAT_SRGBA_8,

        // unnormalized integer formats (UNORM)
        GL_BYTE,         // FORMAT_R_8I,
        GL_BYTE,        // FORMAT_RG_8I,
        GL_BYTE,       // FORMAT_RGB_8I,
        GL_BYTE,      // FORMAT_RGBA_8I,

        GL_SHORT,        // FORMAT_R_16I,
        GL_SHORT,       // FORMAT_RG_16I,
        GL_SHORT,      // FORMAT_RGB_16I,
        GL_SHORT,     // FORMAT_RGBA_16I,

        GL_INT,        // FORMAT_R_32I,
        GL_INT,       // FORMAT_RG_32I,
        GL_INT,      // FORMAT_RGB_32I,
        GL_INT,     // FORMAT_RGBA_32I,

        GL_UNSIGNED_BYTE,        // FORMAT_R_8UI,
        GL_UNSIGNED_BYTE,       // FORMAT_RG_8UI,
        GL_UNSIGNED_BYTE,      // FORMAT_RGB_8UI,
        GL_UNSIGNED_BYTE,     // FORMAT_RGBA_8UI,

        GL_UNSIGNED_SHORT,       // FORMAT_R_16UI,
        GL_UNSIGNED_SHORT,      // FORMAT_RG_16UI,
        GL_UNSIGNED_SHORT,     // FORMAT_RGB_16UI,
        GL_UNSIGNED_SHORT,    // FORMAT_RGBA_16UI,

        GL_UNSIGNED_INT,       // FORMAT_R_32UI,
        GL_UNSIGNED_INT,      // FORMAT_RG_32UI,
        GL_UNSIGNED_INT,     // FORMAT_RGB_32UI,
        GL_UNSIGNED_INT,    // FORMAT_RGBA_32UI,

        // floating point formats
        GL_HALF_FLOAT,        // FORMAT_R_16F,
        GL_HALF_FLOAT,       // FORMAT_RG_16F,
        GL_HALF_FLOAT,      // FORMAT_RGB_16F,
        GL_HALF_FLOAT,     // FORMAT_RGBA_16F,

        GL_FLOAT,        // FORMAT_R_32F,
        GL_FLOAT,       // FORMAT_RG_32F,
        GL_FLOAT,      // FORMAT_RGB_32F,
        GL_FLOAT,     // FORMAT_RGBA_32F,

        // special packed formats
        GL_FLOAT,     // FORMAT_RGB9_E5,
        GL_FLOAT,// FORMAT_R11B11G10F,

        // compressed formats
        GL_UNSIGNED_BYTE,   //FORMAT_BC1_RGBA,        // DXT1
        GL_UNSIGNED_BYTE,   //FORMAT_BC1_SRGBA,       // DXT1
        GL_UNSIGNED_BYTE,   //FORMAT_BC2_RGBA,        // DXT3
        GL_UNSIGNED_BYTE,   //FORMAT_BC2_SRGBA,       // DXT3
        GL_UNSIGNED_BYTE,   //FORMAT_BC3_RGBA,        // DXT5
        GL_UNSIGNED_BYTE,   //FORMAT_BC3_SRGBA,       // DXT5
        GL_UNSIGNED_BYTE,   //FORMAT_BC4_R,           // RGTC1
        GL_UNSIGNED_BYTE,   //FORMAT_BC4_R_S,         // RGTC1
        GL_UNSIGNED_BYTE,   //FORMAT_BC5_RG,          // RGTC2
        GL_UNSIGNED_BYTE,   //FORMAT_BC5_RG_S,        // RGTC2
        GL_FLOAT,           // FORMAT_BC6H_RGB_F,      // BPTC
        GL_FLOAT,           // FORMAT_BC6H_RGB_UF,     // BPTC
        GL_UNSIGNED_BYTE,   //FORMAT_BC7_RGBA,        // BPTC
        GL_UNSIGNED_BYTE,   //FORMAT_BC7_SRGBA,       // BPTC

        // depth stencil formats
        GL_UNSIGNED_SHORT, // FORMAT_D16,
        GL_UNSIGNED_INT, // FORMAT_D24,
        GL_UNSIGNED_INT, // FORMAT_D32,
        GL_FLOAT, // FORMAT_D32F,
        GL_UNSIGNED_INT_24_8, // FORMAT_D24_S8,
        GL_FLOAT_32_UNSIGNED_INT_24_8_REV// FORMAT_D32F_S8,
    };

    BOOST_STATIC_ASSERT((sizeof(gl_btypes) / sizeof(unsigned)) == FORMAT_COUNT);

    assert(FORMAT_NULL <= d && d < FORMAT_COUNT);

    return gl_btypes[d];
}

} // namespace util
} // namespace gl
} // namespace scm