PrusaSlicer-NonPlainar/src/slic3r/GUI/OpenGLManager.hpp

107 lines
2.8 KiB
C++
Raw Normal View History

#ifndef slic3r_OpenGLManager_hpp_
#define slic3r_OpenGLManager_hpp_
2018-05-09 08:47:04 +00:00
2020-05-06 12:48:40 +00:00
class wxWindow;
2018-06-11 13:13:13 +00:00
class wxGLCanvas;
class wxGLContext;
2018-05-09 08:47:04 +00:00
namespace Slic3r {
namespace GUI {
class OpenGLManager
2018-05-09 08:47:04 +00:00
{
public:
enum class EFramebufferType : unsigned char
{
2020-03-02 12:09:12 +00:00
Unknown,
Arb,
Ext
};
class GLInfo
{
mutable bool m_detected{ false };
mutable int m_max_tex_size{ 0 };
mutable float m_max_anisotropy{ 0.0f };
mutable std::string m_version;
mutable std::string m_glsl_version;
mutable std::string m_vendor;
mutable std::string m_renderer;
public:
GLInfo() = default;
const std::string& get_version() const;
const std::string& get_glsl_version() const;
const std::string& get_vendor() const;
const std::string& get_renderer() const;
int get_max_tex_size() const;
float get_max_anisotropy() const;
bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const;
std::string to_string(bool format_as_html, bool extensions) const;
private:
void detect() const;
};
2018-05-09 08:47:04 +00:00
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
// Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets
struct OSInfo
{
int major{ 0 };
int minor{ 0 };
int micro{ 0 };
};
#endif //__APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
private:
enum class EMultisampleState : unsigned char
{
Unknown,
Enabled,
Disabled
};
2018-05-09 08:47:04 +00:00
bool m_gl_initialized{ false };
wxGLContext* m_context{ nullptr };
static GLInfo s_gl_info;
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
// Part of hack to remove crash when closing the application on OSX 10.9.5 when building against newer wxWidgets
static OSInfo s_os_info;
#endif //__APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
2019-05-21 12:19:03 +00:00
static bool s_compressed_textures_supported;
static EMultisampleState s_multisample;
static EFramebufferType s_framebuffers_type;
2018-05-09 08:47:04 +00:00
public:
OpenGLManager() = default;
~OpenGLManager();
2018-05-09 08:47:04 +00:00
bool init_gl();
2018-05-09 08:47:04 +00:00
wxGLContext* init_glcontext(wxGLCanvas& canvas);
2019-05-21 12:19:03 +00:00
static bool are_compressed_textures_supported() { return s_compressed_textures_supported; }
static bool can_multisample() { return s_multisample == EMultisampleState::Enabled; }
2020-03-02 12:09:12 +00:00
static bool are_framebuffers_supported() { return (s_framebuffers_type != EFramebufferType::Unknown); }
static EFramebufferType get_framebuffers_type() { return s_framebuffers_type; }
static wxGLCanvas* create_wxglcanvas(wxWindow& parent);
static const GLInfo& get_gl_info() { return s_gl_info; }
2018-05-09 08:47:04 +00:00
private:
2019-05-21 12:19:03 +00:00
static void detect_multisample(int* attribList);
2018-05-09 08:47:04 +00:00
};
} // namespace GUI
} // namespace Slic3r
#endif // slic3r_OpenGLManager_hpp_