mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
GLCanvas3DManager moved from being a static member of _3DScene to be a normal member of GUI_App
This commit is contained in:
parent
47604b6326
commit
0b629eb905
24 changed files with 738 additions and 24 deletions
|
@ -23,22 +23,43 @@ class PrintObject;
|
|||
namespace GUI {
|
||||
|
||||
class GLCanvas3D;
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
class Bed3D;
|
||||
class GLToolbar;
|
||||
struct Camera;
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
class GLCanvas3DManager
|
||||
{
|
||||
public:
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
enum class EFramebufferType : unsigned char
|
||||
{
|
||||
None,
|
||||
Arb,
|
||||
Ext
|
||||
};
|
||||
#else
|
||||
enum EFramebufferType : unsigned char
|
||||
{
|
||||
FB_None,
|
||||
FB_Arb,
|
||||
FB_Ext
|
||||
};
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
class GLInfo
|
||||
{
|
||||
#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
|
||||
mutable bool m_detected;
|
||||
|
||||
mutable std::string m_version;
|
||||
|
@ -48,9 +69,14 @@ public:
|
|||
|
||||
mutable int m_max_tex_size;
|
||||
mutable float m_max_anisotropy;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
public:
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
GLInfo() = default;
|
||||
#else
|
||||
GLInfo();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
const std::string& get_version() const;
|
||||
const std::string& get_glsl_version() const;
|
||||
|
@ -69,6 +95,14 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
enum class EMultisampleState : unsigned char
|
||||
{
|
||||
Unknown,
|
||||
Enabled,
|
||||
Disabled
|
||||
};
|
||||
#else
|
||||
enum EMultisampleState : unsigned char
|
||||
{
|
||||
MS_Unknown,
|
||||
|
@ -77,46 +111,79 @@ private:
|
|||
};
|
||||
|
||||
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
CanvasesMap m_canvases;
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
bool m_gl_initialized{ false };
|
||||
wxGLContext* m_context{ nullptr };
|
||||
#else
|
||||
wxGLContext* m_context;
|
||||
static GLInfo s_gl_info;
|
||||
bool m_gl_initialized;
|
||||
static EMultisampleState s_multisample;
|
||||
CanvasesMap m_canvases;
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
static GLInfo s_gl_info;
|
||||
static bool s_compressed_textures_supported;
|
||||
static EMultisampleState s_multisample;
|
||||
static EFramebufferType s_framebuffers_type;
|
||||
|
||||
public:
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
GLCanvas3DManager() = default;
|
||||
#else
|
||||
GLCanvas3DManager();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
~GLCanvas3DManager();
|
||||
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
bool add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar);
|
||||
bool remove(wxGLCanvas* canvas);
|
||||
void remove_all();
|
||||
|
||||
unsigned int count() const;
|
||||
size_t count() const;
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
bool init_gl();
|
||||
#else
|
||||
void init_gl();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
wxGLContext* init_glcontext(wxGLCanvas& canvas);
|
||||
#else
|
||||
bool init(wxGLCanvas* canvas);
|
||||
void destroy();
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
GLCanvas3D* get_canvas(wxGLCanvas* canvas);
|
||||
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
static bool can_multisample() { return s_multisample == MS_Enabled; }
|
||||
static bool are_compressed_textures_supported() { return s_compressed_textures_supported; }
|
||||
#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; }
|
||||
static bool are_framebuffers_supported() { return (s_framebuffers_type != FB_None); }
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
static EFramebufferType get_framebuffers_type() { return s_framebuffers_type; }
|
||||
|
||||
#if ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
static wxGLCanvas* create_wxglcanvas(wxWindow& parent);
|
||||
#else
|
||||
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
|
||||
static const GLInfo& get_gl_info() { return s_gl_info; }
|
||||
|
||||
private:
|
||||
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);
|
||||
CanvasesMap::const_iterator do_get_canvas(wxGLCanvas* canvas) const;
|
||||
|
||||
bool init(GLCanvas3D& canvas);
|
||||
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
|
||||
static void detect_multisample(int* attribList);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue