<commit_before>#include <zombye/rendering/texture.hpp>

namespace zombye {
    texture::texture(const gli::texture2D& texture) noexcept
    : width_{texture[0].dimensions().x}, height_{texture[0].dimensions().y} {
        glGenTextures(1, &id_);
        glBindTexture(GL_TEXTURE_2D, id_);
        // adapted from http://www.g-truc.net/project-0024.html
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(texture.levels() - 1));
        if (gli::is_compressed(texture.format())) {
            for (gli::texture2D::size_type level = 0; level < texture.levels(); ++level) {
                glCompressedTexImage2D(GL_TEXTURE_2D,
                GLint(level),
                GLenum{gli::internal_format(texture.format())},
                GLsizei(texture[level].dimensions().x),
                GLsizei(texture[level].dimensions().y),
                0,
                GLsizei(texture[level].size()),
                texture[level].data());
            }
        } else {
            for (gli::texture2D::size_type level = 0; level < texture.levels(); ++level) {
                glTexImage2D(GL_TEXTURE_2D,
                GLint(level),
                GLenum(gli::internal_format(texture.format())),
                GLsizei(texture[level].dimensions().x),
                GLsizei(texture[level].dimensions().y),
                0,
                GLenum(gli::external_format(texture.format())),
                GLenum(gli::type_format(texture.format())),
                texture[level].data());
            }
        }
    }

    texture::~texture() {
        glDeleteTextures(1, &id_);
    }
<commit_msg>add trilinear mip map interpolation<commit_after>#include <zombye/rendering/texture.hpp>

namespace zombye {
    texture::texture(const gli::texture2D& texture) noexcept
    : width_{texture.dimensions().x}, height_{texture.dimensions().y} {
        glGenTextures(1, &id_);
        glBindTexture(GL_TEXTURE_2D, id_);
        // adapted from http://www.g-truc.net/project-0024.html
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(texture.levels() - 1));
        if (gli::is_compressed(texture.format())) {
            for (gli::texture2D::size_type level = 0; level < texture.levels(); ++level) {
                glCompressedTexImage2D(GL_TEXTURE_2D,
                GLint(level),
                GLenum{gli::internal_format(texture.format())},
                GLsizei(texture[level].dimensions().x),
                GLsizei(texture[level].dimensions().y),
                0,
                GLsizei(texture[level].size()),
                texture[level].data());
            }
        } else {
            for (gli::texture2D::size_type level = 0; level < texture.levels(); ++level) {
                glTexImage2D(GL_TEXTURE_2D,
                GLint(level),
                GLenum(gli::internal_format(texture.format())),
                GLsizei(texture[level].dimensions().x),
                GLsizei(texture[level].dimensions().y),
                0,
                GLenum(gli::external_format(texture.format())),
                GLenum(gli::type_format(texture.format())),
                texture[level].data());
            }
        }

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    }

    texture::~texture() {
        glDeleteTextures(1, &id_);
    }

{'fraction_non_alphanumeric': 0.13806706114398423, 'fraction_numerical': 0.013524936601859678, 'mean_word_length': 2.250915750915751, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4925300', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1065, 'n_words': 132}