2018-05-09 08:47:04 +00:00
|
|
|
#ifndef slic3r_GLCanvas3DManager_hpp_
|
|
|
|
#define slic3r_GLCanvas3DManager_hpp_
|
|
|
|
|
2018-12-06 11:52:28 +00:00
|
|
|
#include "libslic3r/BoundingBox.hpp"
|
2018-05-09 08:47:04 +00:00
|
|
|
|
|
|
|
#include <map>
|
2018-06-11 13:13:13 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2018-10-01 14:48:08 +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 {
|
2018-06-11 13:13:13 +00:00
|
|
|
|
2018-11-22 14:29:59 +00:00
|
|
|
class BackgroundSlicingProcess;
|
2018-06-11 13:13:13 +00:00
|
|
|
class DynamicPrintConfig;
|
|
|
|
class Model;
|
|
|
|
class ExPolygon;
|
|
|
|
typedef std::vector<ExPolygon> ExPolygons;
|
|
|
|
class ModelObject;
|
|
|
|
class PrintObject;
|
2018-10-03 09:34:39 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2018-06-11 13:13:13 +00:00
|
|
|
class GLCanvas3D;
|
2020-03-02 09:58:46 +00:00
|
|
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-03-07 10:49:00 +00:00
|
|
|
class Bed3D;
|
|
|
|
class GLToolbar;
|
|
|
|
struct Camera;
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-06-11 13:13:13 +00:00
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
class GLCanvas3DManager
|
|
|
|
{
|
2019-05-23 11:49:57 +00:00
|
|
|
public:
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
enum class EFramebufferType : unsigned char
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Arb,
|
|
|
|
Ext
|
|
|
|
};
|
|
|
|
#else
|
2019-11-05 13:50:58 +00:00
|
|
|
enum EFramebufferType : unsigned char
|
|
|
|
{
|
|
|
|
FB_None,
|
|
|
|
FB_Arb,
|
|
|
|
FB_Ext
|
|
|
|
};
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-11-05 13:50:58 +00:00
|
|
|
|
2019-05-23 11:49:57 +00:00
|
|
|
class GLInfo
|
|
|
|
{
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
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;
|
|
|
|
#else
|
2019-05-23 11:49:57 +00:00
|
|
|
mutable bool m_detected;
|
|
|
|
|
|
|
|
mutable std::string m_version;
|
|
|
|
mutable std::string m_glsl_version;
|
|
|
|
mutable std::string m_vendor;
|
|
|
|
mutable std::string m_renderer;
|
|
|
|
|
|
|
|
mutable int m_max_tex_size;
|
|
|
|
mutable float m_max_anisotropy;
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-05-23 11:49:57 +00:00
|
|
|
|
|
|
|
public:
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
GLInfo() = default;
|
|
|
|
#else
|
2019-05-23 11:49:57 +00:00
|
|
|
GLInfo();
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-05-23 11:49:57 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2020-03-02 11:13:39 +00:00
|
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
|
|
//#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
|
|
|
|
//#ifdef __APPLE__
|
|
|
|
// struct OSInfo
|
|
|
|
// {
|
|
|
|
// int major{ 0 };
|
|
|
|
// int minor{ 0 };
|
|
|
|
// int micro{ 0 };
|
|
|
|
// };
|
|
|
|
//#endif //__APPLE__
|
|
|
|
//#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
|
|
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
2020-02-27 13:55:27 +00:00
|
|
|
|
2019-05-23 11:49:57 +00:00
|
|
|
private:
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
enum class EMultisampleState : unsigned char
|
|
|
|
{
|
|
|
|
Unknown,
|
|
|
|
Enabled,
|
|
|
|
Disabled
|
|
|
|
};
|
|
|
|
#else
|
2018-10-02 12:01:22 +00:00
|
|
|
enum EMultisampleState : unsigned char
|
|
|
|
{
|
|
|
|
MS_Unknown,
|
|
|
|
MS_Enabled,
|
|
|
|
MS_Disabled
|
|
|
|
};
|
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
bool m_gl_initialized{ false };
|
|
|
|
wxGLContext* m_context{ nullptr };
|
|
|
|
#else
|
2018-10-04 08:41:11 +00:00
|
|
|
wxGLContext* m_context;
|
2020-03-02 11:13:39 +00:00
|
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
|
|
//#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
|
|
|
|
//#ifdef __APPLE__
|
|
|
|
// static OSInfo s_os_info;
|
|
|
|
//#endif //__APPLE__
|
|
|
|
//#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
|
|
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
2018-05-09 08:47:04 +00:00
|
|
|
bool m_gl_initialized;
|
2020-03-02 09:58:46 +00:00
|
|
|
CanvasesMap m_canvases;
|
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
static GLInfo s_gl_info;
|
2019-05-21 12:19:03 +00:00
|
|
|
static bool s_compressed_textures_supported;
|
2020-03-02 09:58:46 +00:00
|
|
|
static EMultisampleState s_multisample;
|
2019-11-05 13:50:58 +00:00
|
|
|
static EFramebufferType s_framebuffers_type;
|
2018-05-09 08:47:04 +00:00
|
|
|
|
|
|
|
public:
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
GLCanvas3DManager() = default;
|
|
|
|
#else
|
2018-05-09 08:47:04 +00:00
|
|
|
GLCanvas3DManager();
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-10-04 08:41:11 +00:00
|
|
|
~GLCanvas3DManager();
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-03-07 10:49:00 +00:00
|
|
|
bool add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
2018-05-09 08:47:04 +00:00
|
|
|
bool remove(wxGLCanvas* canvas);
|
|
|
|
void remove_all();
|
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
size_t count() const;
|
|
|
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
bool init_gl();
|
|
|
|
#else
|
2018-05-09 08:47:04 +00:00
|
|
|
void init_gl();
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-05-09 08:47:04 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
wxGLContext* init_glcontext(wxGLCanvas& canvas);
|
|
|
|
#else
|
2018-06-04 11:15:28 +00:00
|
|
|
bool init(wxGLCanvas* canvas);
|
2019-08-22 18:02:25 +00:00
|
|
|
void destroy();
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-05-23 07:57:44 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-10-11 08:24:19 +00:00
|
|
|
GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-05-18 12:08:59 +00:00
|
|
|
|
2019-05-21 12:19:03 +00:00
|
|
|
static bool are_compressed_textures_supported() { return s_compressed_textures_supported; }
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
static bool can_multisample() { return s_multisample == EMultisampleState::Enabled; }
|
|
|
|
static bool are_framebuffers_supported() { return (s_framebuffers_type != EFramebufferType::None); }
|
|
|
|
#else
|
|
|
|
static bool can_multisample() { return s_multisample == MS_Enabled; }
|
2019-11-05 13:50:58 +00:00
|
|
|
static bool are_framebuffers_supported() { return (s_framebuffers_type != FB_None); }
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-11-05 13:50:58 +00:00
|
|
|
static EFramebufferType get_framebuffers_type() { return s_framebuffers_type; }
|
2019-05-21 12:19:03 +00:00
|
|
|
|
2020-03-02 09:58:46 +00:00
|
|
|
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
|
|
|
static wxGLCanvas* create_wxglcanvas(wxWindow& parent);
|
|
|
|
#else
|
2018-10-01 14:48:08 +00:00
|
|
|
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
2018-10-02 12:01:22 +00:00
|
|
|
|
2019-05-23 11:49:57 +00:00
|
|
|
static const GLInfo& get_gl_info() { return s_gl_info; }
|
|
|
|
|
2018-05-09 08:47:04 +00:00
|
|
|
private:
|
2020-03-02 09:58:46 +00:00
|
|
|
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
2019-05-21 12:19:03 +00:00
|
|
|
CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);
|
|
|
|
CanvasesMap::const_iterator do_get_canvas(wxGLCanvas* canvas) const;
|
2018-06-04 11:15:28 +00:00
|
|
|
|
2019-05-21 12:19:03 +00:00
|
|
|
bool init(GLCanvas3D& canvas);
|
2020-03-02 09:58:46 +00:00
|
|
|
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
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_GLCanvas3DManager_hpp_
|