summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/Tex/TextureUnit.cpp
blob: 06dab3a314fd5000a75835a5507e42f840aa97be (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
/*
 * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibGL/GL/gl.h>
#include <LibGL/Tex/TextureUnit.h>

namespace GL {

void TextureUnit::bind_texture_to_target(GLenum texture_target, const RefPtr<Texture>& texture)
{
    switch (texture_target) {
    case GL_TEXTURE_2D:
        m_texture_target_2d = static_ptr_cast<Texture2D>(texture);
        m_currently_bound_target = GL_TEXTURE_2D;
        m_currently_bound_texture = texture;
        break;
    default:
        VERIFY_NOT_REACHED();
    }
}

void TextureUnit::unbind_texture(GLenum texture_target)
{
    switch (texture_target) {
    case GL_TEXTURE_2D:
        m_texture_target_2d = nullptr;
        m_currently_bound_target = GL_NONE;
        break;
    default:
        VERIFY_NOT_REACHED();
    }

    m_currently_bound_texture = nullptr;
}

}