blob: 79f182c1cc121b3c26bcf6b85693a2fda5584b32 (
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
67
68
|
#pragma once
#include <forstio/window/xcb.hpp>
#ifndef SAW_OGL
#error "OpenGL is not supported"
#endif
#include "gl_backends.hpp"
#include "gl_context.hpp"
#include "gl_window.hpp"
#include <GL/glx.hpp>
namespace saw {
namespace gfx {
struct glx_library_extensions {
public:
std::string_view raw_extension_string;
GLXContext (*glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*) = nullptr;
};
template<>
class gpu_context<backend::gl_linux_xcb> final {
private:
glx_library_extensions ext_lib_;
own<device<backend::linux_xcb>> device_;
int visual_id_;
GLXContext context_;
GLXFBConfig fb_config_;
friend class gpu_window<backend::gl_linux_xcb>;
public:
gpu_context(const glx_library_extensions&, own<device<backend::linux_xcb>>, int, GLXContext, GLXFBConfig);
~gpu_context();
own<gpu_window<backend::gl_linux_xcb>> create_window(const video_mode&, std::string_view);
void flush();
};
template<>
class gpu_window<backend::gl_linux_xcb> final {
private:
own<window<backend::linux_xcb>> window_;
gpu_context<backend::gl_linux_xcb>* context_;
::GLXWindow glx_window_handle_;
public:
gpu_window(own<window<backend::linux_xcb>> window, gpu_context<backend::gl_linux_xcb>& ctx,
::GLXWindow);
~gpu_window();
void bind();
void swap();
void show();
void hide();
const video_mode& get_video_mode() const;
const std::string_view get_title() const;
void resize(size_t height, size_t width);
conveyor<data<schema::WindowEvents>> on_event();
};
}
}
|