# Code coverage report for src/core/GLInfo.js

# all files / src/core/ GLInfo.js

95.45% Statements 21/22
100% Branches 6/6
75% Functions 3/4
95.45% Lines 21/22

    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    621×

    1×

    26×
    26×

    26×
    364×
    364×

    26×
    52×
    52×

    26×
    316×
    1×

    316×

    26×

    365×
    365×
    1×

    365×
    1×

    365×

     var EXTENSION_LIST = [
        'OES_texture_float',
        'OES_texture_half_float',
        'OES_texture_float_linear',
        'OES_texture_half_float_linear',
        'OES_standard_derivatives',
        'OES_vertex_array_object',
        'OES_element_index_uint',
        'WEBGL_compressed_texture_s3tc',
        'WEBGL_depth_texture',
        'EXT_texture_filter_anisotropic',
        'EXT_shader_texture_lod',
        'WEBGL_draw_buffers',
        'EXT_frag_depth',
        'EXT_sRGB'
    ];

    var PARAMETER_NAMES = [
        'MAX_TEXTURE_SIZE',
        'MAX_CUBE_MAP_TEXTURE_SIZE'
    ];

    function GLInfo(_gl) {
        var extensions = {};
        var parameters = {};

        // Get webgl extension
        for (var i = 0; i < EXTENSION_LIST.length; i++) {
            var extName = EXTENSION_LIST[i];
            createExtension(extName);
        }
        // Get parameters
        for (var i = 0; i < PARAMETER_NAMES.length; i++) {
            var name = PARAMETER_NAMES[i];
            parameters[name] = _gl.getParameter(_gl[name]);
        }

        this.getExtension = function (name) {
            if (!(name in extensions)) {
                createExtension(name);
            }
            return extensions[name];
        };

        this.getParameter = function (name) {
            return parameters[name];
        };

        function createExtension(name) {
            var ext = _gl.getExtension(name);
            if (!ext) {
                ext = _gl.getExtension('MOZ_' + name);
            }
            if (!ext) {
                ext = _gl.getExtension('WEBKIT_' + name);
            }
            extensions[name] = ext;
        }
    }

    export default GLInfo;