summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/Tex/Sampler2D.h
blob: eea80abb1d31728314e94cac3c8e918c02311283 (plain)
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
/*
 * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibGL/GL/gl.h>
#include <LibGfx/Vector2.h>
#include <LibGfx/Vector4.h>

namespace GL {

class Texture2D;

class Sampler2D final {
public:
    Sampler2D(Texture2D const& texture)
        : m_texture(texture)
    {
    }

    GLint min_filter() const { return m_min_filter; }
    GLint mag_filter() const { return m_mag_filter; }
    GLint wrap_s_mode() const { return m_wrap_s_mode; }
    GLint wrap_t_mode() const { return m_wrap_t_mode; }

    void set_min_filter(GLint value) { m_min_filter = value; }
    void set_mag_filter(GLint value) { m_mag_filter = value; }
    void set_wrap_s_mode(GLint value) { m_wrap_s_mode = value; }
    void set_wrap_t_mode(GLint value) { m_wrap_t_mode = value; }

    FloatVector4 sample(FloatVector4 const& uv) const;

private:
    Texture2D const& m_texture;

    GLint m_min_filter { GL_NEAREST_MIPMAP_LINEAR };
    GLint m_mag_filter { GL_LINEAR };
    GLint m_wrap_s_mode { GL_REPEAT };
    GLint m_wrap_t_mode { GL_REPEAT };
};
}