/*
 * Copyright (c) 2004-2008 Derelict Developers
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * * Neither the names 'Derelict', 'DerelictGL', nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
module derelict.opengl.extension.ext.texture3D;

private
{
    import derelict.opengl.gltypes;
    import derelict.opengl.gl;
    import derelict.opengl.extension.loader;
    import derelict.util.wrapper;
}

private bool enabled = false;

struct EXTTexture3D
{
    static bool load(char[] extString)
    {
        if(extString.findStr("GL_EXT_texture3D") == -1)
            return false;

        if(!glBindExtFunc(cast(void**)&glTexImage3DEXT, "glTexImage3DEXT"))
            return false;
        if(!glBindExtFunc(cast(void**)&glTexSubImage3DEXT, "glTexSubImage3DEXT"))
            return false;

        enabled = true;
        return true;
    }

    static bool isEnabled()
    {
        return enabled;
    }
}

version(DerelictGL_NoExtensionLoaders)
{
}
else
{
    static this()
    {
        DerelictGL.registerExtensionLoader(&EXTTexture3D.load);
    }
}

enum : GLenum
{
    GL_PACK_SKIP_IMAGES_EXT           = 0x806B,
    GL_PACK_IMAGE_HEIGHT_EXT          = 0x806C,
    GL_UNPACK_SKIP_IMAGES_EXT         = 0x806D,
    GL_UNPACK_IMAGE_HEIGHT_EXT        = 0x806E,
    GL_TEXTURE_3D_EXT                 = 0x806F,
    GL_PROXY_TEXTURE_3D_EXT           = 0x8070,
    GL_TEXTURE_DEPTH_EXT              = 0x8071,
    GL_TEXTURE_WRAP_R_EXT             = 0x8072,
    GL_MAX_3D_TEXTURE_SIZE_EXT        = 0x8073,
}

extern(System):

typedef void function(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoid*) pfglTexImage3DEXT;
typedef void function(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*) pfglTexSubImage3DEXT;

pfglTexImage3DEXT       glTexImage3DEXT;
pfglTexSubImage3DEXT    glTexSubImage3DEXT;
