21
21
22
22
#include < hex/api/task_manager.hpp>
23
23
#include < hex/api/theme_manager.hpp>
24
+ #include < hex/helpers/logger.hpp>
24
25
25
26
26
27
namespace ImGuiExt {
@@ -29,6 +30,20 @@ namespace ImGuiExt {
29
30
30
31
namespace {
31
32
33
+ bool isOpenGLExtensionSupported (const char *name) {
34
+ GLint extensionCount = 0 ;
35
+ glGetIntegerv (GL_NUM_EXTENSIONS, &extensionCount);
36
+
37
+ for (GLint i = 0 ; i < extensionCount; i++) {
38
+ std::string_view extension = reinterpret_cast <const char *>(glGetStringi (GL_EXTENSIONS, i));
39
+ if (extension == name) {
40
+ return true ;
41
+ }
42
+ }
43
+
44
+ return false ;
45
+ }
46
+
32
47
constexpr auto getGLFilter (Texture::Filter filter) {
33
48
switch (filter) {
34
49
using enum Texture::Filter;
@@ -68,7 +83,13 @@ namespace ImGuiExt {
68
83
if (filter == Texture::Filter::Nearest)
69
84
return texture;
70
85
71
- #if 0
86
+ if (!isOpenGLExtensionSupported (" GL_ARB_texture_multisample" )) {
87
+ hex::log::error (" Platform does not support texture multisample! Bailing out!" );
88
+ return texture;
89
+ }
90
+
91
+ #if defined(GL_TEXTURE_2D_MULTISAMPLE)
92
+
72
93
constexpr static auto SampleCount = 8 ;
73
94
74
95
// Generate renderbuffer
@@ -83,18 +104,20 @@ namespace ImGuiExt {
83
104
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
84
105
85
106
// Attach texture to color attachment 0
86
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D , texture, 0);
107
+ glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE , texture, 0 );
87
108
88
109
// Attach renderbuffer to depth-stencil attachment
89
110
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderbuffer);
90
111
91
112
// Check framebuffer status
92
113
if (glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
93
- return 0;
114
+ hex::log::error (" Platform claim to support texture multisample but the API is failing! Bailing out!" );
115
+ return texture;
94
116
}
95
117
96
118
// Unbind framebuffer
97
119
glBindFramebuffer (GL_FRAMEBUFFER, 0 );
120
+
98
121
#endif
99
122
100
123
return texture;
0 commit comments