extensions.hh 3.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/***********************************************************************
 * Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
 * All rights reserved.                                                *
 * Distributed under the terms of the MIT License (see LICENSE.TXT).   *
 **********************************************************************/

/**
 * Basic checks if an extension is available.
 * Depending on whether GLEW, the internal loader or anything else was
 * used to get the OpenGL function pointers and extensions, the implementation
 * will differ.
 * Only the extensions are listed here that are needed inside of ACGL itself,
 * it is not a complete list! It can also change and checks can get removed
 * if they are not needed inside of ACGL.
 * Applications should perform there own checks depending on the extension
 * loader choosen for the app and not rely on these checks!
 *
 * Each check will return true if the extension is available.
 **/

#ifndef ACGL_OPENGL_EXTENSIONS_HH
#define ACGL_OPENGL_EXTENSIONS_HH

#include <ACGL/OpenGL/GL.hh>

namespace ACGL{
namespace OpenGL{

// anisotrophic texture filtering
inline bool ACGL_EXT_texture_filter_anisotrophic() {
    #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN
        return (ogl_ext_EXT_texture_filter_anisotropic != ogl_LOAD_FAILED);
33
    #elif ACGL_EXTENSION_LOADER_GLEW
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        return GLEW_EXT_texture_filter_anisotropic;
    #else
        // if needed define the constants so the code will compile, it
        // will never be run anyway as this check will return false!
        #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
        #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
        #endif
        #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
        #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
        #endif
        return false;
    #endif
}

// EXT_geometry_shader4 & ARB_geometry_shader4 are identical and may not be available if the context is 3.2+ anyway!
inline bool ACGL_EXT_geometry_shader4() {
    #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN
        return (ogl_ext_EXT_geometry_shader4 != ogl_LOAD_FAILED);
52
    #elif ACGL_EXTENSION_LOADER_GLEW
53 54 55 56 57 58 59 60 61 62
        return GLEW_EXT_geometry_shader4;
    #else
        return false;
    #endif
}

// EXT_geometry_shader4 & ARB_geometry_shader4 are identical and may not be available if the context is 3.2+ anyway!
inline bool ACGL_ARB_geometry_shader4() {
    #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN
        return (ogl_ext_ARB_geometry_shader4 != ogl_LOAD_FAILED);
63
    #elif ACGL_EXTENSION_LOADER_GLEW
64 65 66 67 68 69 70 71 72
        return GLEW_ARB_geometry_shader4;
    #else
        return false;
    #endif
}

inline bool ACGL_ARB_tessellation_shader() {
    #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN
        return (ogl_ext_ARB_tessellation_shader != ogl_LOAD_FAILED);
73
    #elif ACGL_EXTENSION_LOADER_GLEW
74 75 76 77 78 79 80 81 82
        return GLEW_ARB_tessellation_shader;
    #else
        return false;
    #endif
}

inline bool ACGL_ARB_compute_shader() {
    #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN
        return (ogl_ext_ARB_compute_shader != ogl_LOAD_FAILED);
83
    #elif ACGL_EXTENSION_LOADER_GLEW
84 85 86 87 88 89
        return GLEW_ARB_compute_shader;
    #else
        return false;
    #endif
}

90
// ARB debug output
Robert Menzel's avatar
Robert Menzel committed
91 92 93
inline bool ACGL_ARB_debug_output() {
    #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN
        return (ogl_ext_ARB_debug_output != ogl_LOAD_FAILED);
94
    #elif ACGL_EXTENSION_LOADER_GLEW
Robert Menzel's avatar
Robert Menzel committed
95 96 97 98 99 100
        return GLEW_ARB_debug_output;
    #else
        return false;
    #endif
}

101 102 103 104 105

} // OpenGL
} // ACGL

#endif // ACGL_OPENGL_EXTENSIONS_HH