summaryrefslogtreecommitdiffstats
path: root/src/opengl/common.h
blob: c84c69fde47e3b44f8f8c9a2b19ab7034e7911a1 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * This file is part of libplacebo.
 *
 * libplacebo is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * libplacebo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with libplacebo. If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "../common.h"
#include "../log.h"
#include "../gpu.h"
#include "pl_thread.h"

#include <libplacebo/opengl.h>

// Collision with llvm-mingw <winnt.h>
#undef MemoryBarrier

#define GLAD_GL
#define GLAD_GLES2
#include <glad/gl.h>
#include <glad/egl.h>

typedef GladGLContext gl_funcs;

// PL_PRIV(pl_opengl)
struct gl_ctx {
    pl_log log;
    struct pl_opengl_params params;
    bool is_debug;
    bool is_debug_egl;
    bool is_gles;

    // For context locking
    pl_mutex lock;
    int count;

    // Dispatch table
    gl_funcs func;
};

struct gl_cb {
    void (*callback)(void *priv);
    void *priv;
    GLsync sync;
};

struct fbo_format {
    pl_fmt fmt;
    const struct gl_format *glfmt;
};

// For locking/unlocking
bool gl_make_current(pl_opengl gl);
void gl_release_current(pl_opengl gl);