<commit_before>use DrawError;

use uniforms::SamplerBehavior;

use gl;
use context::CommandContext;
use version::Version;
use version::Api;
use GlObject;
use ToGlEnum;

/// An OpenGL sampler object.
pub struct SamplerObject {
    id: gl::types::GLuint,
    destroyed: bool,
}

impl SamplerObject {
    /// Builds a new sampler object.
    pub fn new(ctxt: &mut CommandContext, behavior: &SamplerBehavior) -> SamplerObject {
        // making sure that the backend supports samplers
        assert!(ctxt.version >= &Version(Api::Gl, 3, 2) ||
                ctxt.version >= &Version(Api::GlEs, 3, 0) ||
                ctxt.extensions.gl_arb_sampler_objects);

        let sampler = unsafe {
            use std::mem;
            #[allow(deprecated)]
            let mut sampler: gl::types::GLuint = mem::uninitialized();
            ctxt.gl.GenSamplers(1, &mut sampler);
            sampler
        };

        unsafe {
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_WRAP_S,
                                      behavior.wrap_function.0.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_WRAP_T,
                                      behavior.wrap_function.1.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_WRAP_R,
                                      behavior.wrap_function.2.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_MIN_FILTER,
                                      behavior.minify_filter.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_MAG_FILTER,
                                      behavior.magnify_filter.to_glenum() as gl::types::GLint);

            if let Some(dtc) = behavior.depth_texture_comparison {
                ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_COMPARE_MODE,
                                          gl::COMPARE_R_TO_TEXTURE as gl::types::GLint);
                ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_COMPARE_FUNC,
                                          dtc.to_glenum() as gl::types::GLint);
            }

            if let Some(max_value) = ctxt.capabilities.max_texture_max_anisotropy {
                let value = if behavior.max_anisotropy as f32 > max_value {
                    max_value
                } else {
                    behavior.max_anisotropy as f32
                };
<commit_msg>one int<commit_after>use DrawError;

use uniforms::SamplerBehavior;

use gl;
use context::CommandContext;
use version::Version;
use version::Api;
use GlObject;
use ToGlEnum;

/// An OpenGL sampler object.
pub struct SamplerObject {
    id: gl::types::GLuint,
    destroyed: bool,
}

impl SamplerObject {
    /// Builds a new sampler object.
    pub fn new(ctxt: &mut CommandContext, behavior: &SamplerBehavior) -> SamplerObject {
        // making sure that the backend supports samplers
        assert!(ctxt.version >= &Version(Api::Gl, 3, 2) ||
                ctxt.version >= &Version(Api::GlEs, 3, 0) ||
                ctxt.extensions.gl_arb_sampler_objects);

        let sampler = unsafe {
            let mut sampler: gl::types::GLuint = 0;
            ctxt.gl.GenSamplers(1, &mut sampler);
            sampler
        };

        unsafe {
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_WRAP_S,
                                      behavior.wrap_function.0.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_WRAP_T,
                                      behavior.wrap_function.1.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_WRAP_R,
                                      behavior.wrap_function.2.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_MIN_FILTER,
                                      behavior.minify_filter.to_glenum() as gl::types::GLint);
            ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_MAG_FILTER,
                                      behavior.magnify_filter.to_glenum() as gl::types::GLint);

            if let Some(dtc) = behavior.depth_texture_comparison {
                ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_COMPARE_MODE,
                                          gl::COMPARE_R_TO_TEXTURE as gl::types::GLint);
                ctxt.gl.SamplerParameteri(sampler, gl::TEXTURE_COMPARE_FUNC,
                                          dtc.to_glenum() as gl::types::GLint);
            }

            if let Some(max_value) = ctxt.capabilities.max_texture_max_anisotropy {
                let value = if behavior.max_anisotropy as f32 > max_value {
                    max_value
                } else {
                    behavior.max_anisotropy as f32
                };

{'fraction_non_alphanumeric': 0.10182876142975894, 'fraction_numerical': 0.005195344970906068, 'mean_word_length': 1.8631766805472934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3586743', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1371, 'n_words': 256}