mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-09 14:55:08 -06:00
Layers editing shader moved to c++
This commit is contained in:
parent
bdbc86167c
commit
455076231b
10 changed files with 387 additions and 211 deletions
|
@ -282,6 +282,7 @@ for my $class (qw(
|
|||
Slic3r::Geometry::BoundingBox
|
||||
Slic3r::Geometry::BoundingBoxf
|
||||
Slic3r::Geometry::BoundingBoxf3
|
||||
Slic3r::GUI::_3DScene::GLShader
|
||||
Slic3r::GUI::_3DScene::GLVolume
|
||||
Slic3r::GUI::Preset
|
||||
Slic3r::GUI::PresetCollection
|
||||
|
|
|
@ -1939,16 +1939,16 @@ bool _3DScene::is_picking_enabled(wxGLCanvas* canvas)
|
|||
return s_canvas_mgr.is_picking_enabled(canvas);
|
||||
}
|
||||
|
||||
bool _3DScene::is_shader_enabled(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.is_shader_enabled(canvas);
|
||||
}
|
||||
|
||||
bool _3DScene::is_multisample_allowed(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.is_multisample_allowed(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::enable_layers_editing(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
s_canvas_mgr.enable_layers_editing(canvas, enable);
|
||||
}
|
||||
|
||||
void _3DScene::enable_warning_texture(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
s_canvas_mgr.enable_warning_texture(canvas, enable);
|
||||
|
@ -2005,6 +2005,16 @@ void _3DScene::set_hover_volume_id(wxGLCanvas* canvas, int id)
|
|||
s_canvas_mgr.set_hover_volume_id(canvas, id);
|
||||
}
|
||||
|
||||
unsigned int _3DScene::get_layers_editing_z_texture_id(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_layers_editing_z_texture_id(canvas);
|
||||
}
|
||||
|
||||
GLShader* _3DScene::get_layers_editing_shader(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_layers_editing_shader(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.zoom_to_bed(canvas);
|
||||
|
|
|
@ -598,9 +598,9 @@ public:
|
|||
|
||||
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
||||
static bool is_picking_enabled(wxGLCanvas* canvas);
|
||||
static bool is_shader_enabled(wxGLCanvas* canvas);
|
||||
static bool is_multisample_allowed(wxGLCanvas* canvas);
|
||||
|
||||
static void enable_layers_editing(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_warning_texture(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_legend_texture(wxGLCanvas* canvas, bool enable);
|
||||
static void enable_picking(wxGLCanvas* canvas, bool enable);
|
||||
|
@ -616,6 +616,9 @@ public:
|
|||
static int get_hover_volume_id(wxGLCanvas* canvas);
|
||||
static void set_hover_volume_id(wxGLCanvas* canvas, int id);
|
||||
|
||||
static unsigned int get_layers_editing_z_texture_id(wxGLCanvas* canvas);
|
||||
static GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||
|
||||
static void zoom_to_bed(wxGLCanvas* canvas);
|
||||
static void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
static void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||
|
|
|
@ -501,6 +501,73 @@ void GLCanvas3D::CuttingPlane::_render_contour() const
|
|||
::glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
GLCanvas3D::Shader::Shader()
|
||||
: m_shader(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLCanvas3D::Shader::~Shader()
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Shader::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
|
||||
{
|
||||
if (is_initialized())
|
||||
return true;
|
||||
|
||||
m_shader = new GLShader();
|
||||
if (m_shader != nullptr)
|
||||
{
|
||||
if (!m_shader->load_from_file(fragment_shader_filename.c_str(), vertex_shader_filename.c_str()))
|
||||
{
|
||||
std::cout << "Compilaton of shader failed:" << std::endl;
|
||||
std::cout << m_shader->last_error << std::endl;
|
||||
_reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Shader::is_initialized() const
|
||||
{
|
||||
return (m_shader != nullptr);
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Shader::start_using() const
|
||||
{
|
||||
if (is_initialized())
|
||||
{
|
||||
m_shader->enable();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Shader::stop_using() const
|
||||
{
|
||||
if (m_shader != nullptr)
|
||||
m_shader->disable();
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3D::Shader::get_shader()
|
||||
{
|
||||
return m_shader;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Shader::_reset()
|
||||
{
|
||||
if (m_shader != nullptr)
|
||||
{
|
||||
m_shader->release();
|
||||
delete m_shader;
|
||||
m_shader = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::GLTextureData::GLTextureData()
|
||||
: id(0)
|
||||
, width(0)
|
||||
|
@ -516,7 +583,9 @@ GLCanvas3D::LayersEditing::GLTextureData::GLTextureData(unsigned int id, int wid
|
|||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::LayersEditing()
|
||||
: m_enabled(false)
|
||||
: m_allowed(false)
|
||||
, m_enabled(false)
|
||||
, m_z_texture_id(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -533,6 +602,39 @@ GLCanvas3D::LayersEditing::~LayersEditing()
|
|||
::glDeleteTextures(1, &m_reset_texture.id);
|
||||
m_reset_texture = GLTextureData();
|
||||
}
|
||||
|
||||
if (m_z_texture_id != 0)
|
||||
{
|
||||
::glDeleteTextures(1, &m_z_texture_id);
|
||||
m_z_texture_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
|
||||
{
|
||||
if (!m_shader.init(vertex_shader_filename, fragment_shader_filename))
|
||||
return false;
|
||||
|
||||
::glGenTextures(1, (GLuint*)&m_z_texture_id);
|
||||
::glBindTexture(GL_TEXTURE_2D, m_z_texture_id);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
::glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_allowed() const
|
||||
{
|
||||
return m_allowed;
|
||||
}
|
||||
|
||||
void GLCanvas3D::LayersEditing::set_allowed(bool allowed)
|
||||
{
|
||||
m_allowed = allowed;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_enabled() const
|
||||
|
@ -540,6 +642,16 @@ bool GLCanvas3D::LayersEditing::is_enabled() const
|
|||
return m_enabled;
|
||||
}
|
||||
|
||||
void GLCanvas3D::LayersEditing::set_enabled(bool enabled)
|
||||
{
|
||||
m_enabled = m_allowed && m_shader.is_initialized() && enabled;
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3D::LayersEditing::get_z_texture_id() const
|
||||
{
|
||||
return m_z_texture_id;
|
||||
}
|
||||
|
||||
void GLCanvas3D::LayersEditing::render(const GLCanvas3D& canvas, const PrintObject& print_object) const
|
||||
{
|
||||
const Rect& bar_rect = _get_bar_rect_viewport(canvas);
|
||||
|
@ -549,6 +661,16 @@ void GLCanvas3D::LayersEditing::render(const GLCanvas3D& canvas, const PrintObje
|
|||
_render_profile(print_object, bar_rect);
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3D::LayersEditing::get_shader()
|
||||
{
|
||||
return m_shader.get_shader();
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::_is_initialized() const
|
||||
{
|
||||
return m_shader.is_initialized();
|
||||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::GLTextureData GLCanvas3D::LayersEditing::_load_texture_from_file(const std::string& filename) const
|
||||
{
|
||||
const std::string& path = resources_dir() + "/icons/";
|
||||
|
@ -729,65 +851,6 @@ Rect GLCanvas3D::LayersEditing::_get_reset_rect_viewport(const GLCanvas3D& canva
|
|||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
||||
}
|
||||
|
||||
GLCanvas3D::Shader::Shader()
|
||||
: m_enabled(false)
|
||||
, m_shader(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Shader::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
|
||||
{
|
||||
m_shader = new GLShader();
|
||||
if (m_shader != nullptr)
|
||||
{
|
||||
if (!m_shader->load_from_file(fragment_shader_filename.c_str(), vertex_shader_filename.c_str()))
|
||||
{
|
||||
std::cout << "Compilaton of path shader failed:" << std::endl;
|
||||
std::cout << m_shader->last_error << std::endl;
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Shader::reset()
|
||||
{
|
||||
if (m_shader != nullptr)
|
||||
{
|
||||
delete m_shader;
|
||||
m_shader = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Shader::is_enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Shader::set_enabled(bool enabled)
|
||||
{
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::Shader::start() const
|
||||
{
|
||||
if (m_enabled && (m_shader != nullptr))
|
||||
{
|
||||
m_shader->enable();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLCanvas3D::Shader::stop() const
|
||||
{
|
||||
if (m_shader != nullptr)
|
||||
m_shader->disable();
|
||||
}
|
||||
|
||||
GLCanvas3D::Mouse::Mouse()
|
||||
: m_dragging(false)
|
||||
{
|
||||
|
@ -824,6 +887,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
|||
, m_warning_texture_enabled(false)
|
||||
, m_legend_texture_enabled(false)
|
||||
, m_picking_enabled(false)
|
||||
, m_shader_enabled(false)
|
||||
, m_multisample_allowed(false)
|
||||
{
|
||||
}
|
||||
|
@ -831,10 +895,9 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
|||
GLCanvas3D::~GLCanvas3D()
|
||||
{
|
||||
_deregister_callbacks();
|
||||
m_shader.reset();
|
||||
}
|
||||
|
||||
bool GLCanvas3D::init(bool useVBOs)
|
||||
bool GLCanvas3D::init(bool useVBOs, bool use_legacy_opengl)
|
||||
{
|
||||
::glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
|
@ -876,6 +939,11 @@ bool GLCanvas3D::init(bool useVBOs)
|
|||
if (useVBOs && !m_shader.init("gouraud.vs", "gouraud.fs"))
|
||||
return false;
|
||||
|
||||
if (useVBOs && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
|
||||
return false;
|
||||
|
||||
m_layers_editing.set_allowed(!use_legacy_opengl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1179,16 +1247,16 @@ bool GLCanvas3D::is_picking_enabled() const
|
|||
return m_picking_enabled;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_shader_enabled() const
|
||||
{
|
||||
return m_shader.is_enabled();
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_multisample_allowed() const
|
||||
{
|
||||
return m_multisample_allowed;
|
||||
}
|
||||
|
||||
void GLCanvas3D::enable_layers_editing(bool enable)
|
||||
{
|
||||
m_layers_editing.set_enabled(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3D::enable_warning_texture(bool enable)
|
||||
{
|
||||
m_warning_texture_enabled = enable;
|
||||
|
@ -1206,9 +1274,8 @@ void GLCanvas3D::enable_picking(bool enable)
|
|||
|
||||
void GLCanvas3D::enable_shader(bool enable)
|
||||
{
|
||||
m_shader.set_enabled(enable);
|
||||
m_shader_enabled = enable;
|
||||
}
|
||||
|
||||
void GLCanvas3D::allow_multisample(bool allow)
|
||||
{
|
||||
m_multisample_allowed = allow;
|
||||
|
@ -1289,12 +1356,12 @@ void GLCanvas3D::select_view(const std::string& direction)
|
|||
|
||||
bool GLCanvas3D::start_using_shader() const
|
||||
{
|
||||
return m_shader.start();
|
||||
return m_shader.start_using();
|
||||
}
|
||||
|
||||
void GLCanvas3D::stop_using_shader() const
|
||||
{
|
||||
m_shader.stop();
|
||||
m_shader.stop_using();
|
||||
}
|
||||
|
||||
void GLCanvas3D::picking_pass()
|
||||
|
@ -1384,6 +1451,16 @@ void GLCanvas3D::render_background() const
|
|||
::glPopMatrix();
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3D::get_layers_editing_z_texture_id() const
|
||||
{
|
||||
return m_layers_editing.get_z_texture_id();
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3D::get_layers_editing_shader()
|
||||
{
|
||||
return m_layers_editing.get_shader();
|
||||
}
|
||||
|
||||
void GLCanvas3D::render_bed() const
|
||||
{
|
||||
m_bed.render();
|
||||
|
@ -1445,12 +1522,12 @@ void GLCanvas3D::render_volumes(bool fake_colors) const
|
|||
|
||||
void GLCanvas3D::render_objects(bool useVBOs)
|
||||
{
|
||||
if (m_volumes == nullptr)
|
||||
if ((m_volumes == nullptr) || m_volumes->empty())
|
||||
return;
|
||||
|
||||
::glEnable(GL_LIGHTING);
|
||||
|
||||
if (!is_shader_enabled())
|
||||
if (!m_shader_enabled)
|
||||
render_volumes(false);
|
||||
else if (useVBOs)
|
||||
{
|
||||
|
|
|
@ -174,6 +174,27 @@ public:
|
|||
void _render_contour() const;
|
||||
};
|
||||
|
||||
class Shader
|
||||
{
|
||||
GLShader* m_shader;
|
||||
|
||||
public:
|
||||
Shader();
|
||||
~Shader();
|
||||
|
||||
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
|
||||
|
||||
bool is_initialized() const;
|
||||
|
||||
bool start_using() const;
|
||||
void stop_using() const;
|
||||
|
||||
GLShader* get_shader();
|
||||
|
||||
private:
|
||||
void _reset();
|
||||
};
|
||||
|
||||
class LayersEditing
|
||||
{
|
||||
struct GLTextureData
|
||||
|
@ -186,7 +207,10 @@ public:
|
|||
GLTextureData(unsigned int id, int width, int height);
|
||||
};
|
||||
|
||||
bool m_allowed;
|
||||
bool m_enabled;
|
||||
Shader m_shader;
|
||||
unsigned int m_z_texture_id;
|
||||
mutable GLTextureData m_tooltip_texture;
|
||||
mutable GLTextureData m_reset_texture;
|
||||
|
||||
|
@ -194,11 +218,22 @@ public:
|
|||
LayersEditing();
|
||||
~LayersEditing();
|
||||
|
||||
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
|
||||
|
||||
bool is_allowed() const;
|
||||
void set_allowed(bool allowed);
|
||||
|
||||
bool is_enabled() const;
|
||||
void set_enabled(bool enabled);
|
||||
|
||||
unsigned int get_z_texture_id() const;
|
||||
|
||||
void render(const GLCanvas3D& canvas, const PrintObject& print_object) const;
|
||||
|
||||
GLShader* get_shader();
|
||||
|
||||
private:
|
||||
bool _is_initialized() const;
|
||||
GLTextureData _load_texture_from_file(const std::string& filename) const;
|
||||
void _render_tooltip_texture(const GLCanvas3D& canvas, const Rect& bar_rect, const Rect& reset_rect) const;
|
||||
void _render_reset_texture(const GLCanvas3D& canvas, const Rect& reset_rect) const;
|
||||
|
@ -209,24 +244,6 @@ public:
|
|||
Rect _get_reset_rect_viewport(const GLCanvas3D& canvas) const;
|
||||
};
|
||||
|
||||
class Shader
|
||||
{
|
||||
bool m_enabled;
|
||||
GLShader* m_shader;
|
||||
|
||||
public:
|
||||
Shader();
|
||||
|
||||
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
|
||||
void reset();
|
||||
|
||||
bool is_enabled() const;
|
||||
void set_enabled(bool enabled);
|
||||
|
||||
bool start() const;
|
||||
void stop() const;
|
||||
};
|
||||
|
||||
class Mouse
|
||||
{
|
||||
bool m_dragging;
|
||||
|
@ -262,6 +279,7 @@ private:
|
|||
bool m_warning_texture_enabled;
|
||||
bool m_legend_texture_enabled;
|
||||
bool m_picking_enabled;
|
||||
bool m_shader_enabled;
|
||||
bool m_multisample_allowed;
|
||||
|
||||
PerlCallback m_on_viewport_changed_callback;
|
||||
|
@ -271,7 +289,7 @@ public:
|
|||
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
||||
~GLCanvas3D();
|
||||
|
||||
bool init(bool useVBOs);
|
||||
bool init(bool useVBOs, bool use_legacy_opengl);
|
||||
|
||||
bool set_current();
|
||||
|
||||
|
@ -332,9 +350,9 @@ public:
|
|||
|
||||
bool is_layers_editing_enabled() const;
|
||||
bool is_picking_enabled() const;
|
||||
bool is_shader_enabled() const;
|
||||
bool is_multisample_allowed() const;
|
||||
|
||||
void enable_layers_editing(bool enable);
|
||||
void enable_warning_texture(bool enable);
|
||||
void enable_legend_texture(bool enable);
|
||||
void enable_picking(bool enable);
|
||||
|
@ -350,6 +368,9 @@ public:
|
|||
int get_hover_volume_id() const;
|
||||
void set_hover_volume_id(int id);
|
||||
|
||||
unsigned int get_layers_editing_z_texture_id() const;
|
||||
GLShader* get_layers_editing_shader();
|
||||
|
||||
void zoom_to_bed();
|
||||
void zoom_to_volumes();
|
||||
void select_view(const std::string& direction);
|
||||
|
|
|
@ -56,11 +56,6 @@ bool GLCanvas3DManager::GLVersion::is_greater_or_equal_to(unsigned int major, un
|
|||
return vn_minor >= minor;
|
||||
}
|
||||
|
||||
GLCanvas3DManager::LayerEditing::LayerEditing()
|
||||
: allowed(false)
|
||||
{
|
||||
}
|
||||
|
||||
GLCanvas3DManager::GLCanvas3DManager()
|
||||
: m_gl_initialized(false)
|
||||
, m_use_legacy_opengl(false)
|
||||
|
@ -129,12 +124,11 @@ void GLCanvas3DManager::init_gl()
|
|||
const AppConfig* config = GUI::get_app_config();
|
||||
m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1");
|
||||
m_use_VBOs = !m_use_legacy_opengl && m_gl_version.is_greater_or_equal_to(2, 0);
|
||||
m_layer_editing.allowed = !m_use_legacy_opengl;
|
||||
m_gl_initialized = true;
|
||||
|
||||
std::cout << "DETECTED OPENGL: " << m_gl_version.vn_major << "." << m_gl_version.vn_minor << std::endl;
|
||||
std::cout << "USE VBOS = " << (m_use_VBOs ? "YES" : "NO") << std::endl;
|
||||
std::cout << "LAYER EDITING ALLOWED = " << (m_layer_editing.allowed ? "YES" : "NO") << std::endl;
|
||||
std::cout << "LAYER EDITING ALLOWED = " << (!m_use_legacy_opengl ? "YES" : "NO") << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,15 +137,10 @@ bool GLCanvas3DManager::use_VBOs() const
|
|||
return m_use_VBOs;
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::layer_editing_allowed() const
|
||||
{
|
||||
return m_layer_editing.allowed;
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::init(wxGLCanvas* canvas, bool useVBOs)
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->init(useVBOs) : false;
|
||||
return (it != m_canvases.end()) ? it->second->init(useVBOs, m_use_legacy_opengl) : false;
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::is_dirty(wxGLCanvas* canvas) const
|
||||
|
@ -391,18 +380,19 @@ bool GLCanvas3DManager::is_picking_enabled(wxGLCanvas* canvas) const
|
|||
return (it != m_canvases.end()) ? it->second->is_picking_enabled() : false;
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::is_shader_enabled(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->is_shader_enabled() : false;
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::is_multisample_allowed(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->is_multisample_allowed() : false;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::enable_layers_editing(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->enable_layers_editing(enable);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::enable_warning_texture(wxGLCanvas* canvas, bool enable)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
@ -477,6 +467,18 @@ void GLCanvas3DManager::set_hover_volume_id(wxGLCanvas* canvas, int id)
|
|||
it->second->set_hover_volume_id(id);
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3DManager::get_layers_editing_z_texture_id(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_layers_editing_z_texture_id() : 0;
|
||||
}
|
||||
|
||||
GLShader* GLCanvas3DManager::get_layers_editing_shader(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_layers_editing_shader() : nullptr;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
|
@ -21,18 +21,10 @@ class GLCanvas3DManager
|
|||
bool is_greater_or_equal_to(unsigned int major, unsigned int minor) const;
|
||||
};
|
||||
|
||||
struct LayerEditing
|
||||
{
|
||||
bool allowed;
|
||||
|
||||
LayerEditing();
|
||||
};
|
||||
|
||||
typedef std::map<wxGLCanvas*, GLCanvas3D*> CanvasesMap;
|
||||
|
||||
CanvasesMap m_canvases;
|
||||
GLVersion m_gl_version;
|
||||
LayerEditing m_layer_editing;
|
||||
bool m_gl_initialized;
|
||||
bool m_use_legacy_opengl;
|
||||
bool m_use_VBOs;
|
||||
|
@ -106,9 +98,9 @@ public:
|
|||
|
||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||
bool is_picking_enabled(wxGLCanvas* canvas) const;
|
||||
bool is_shader_enabled(wxGLCanvas* canvas) const;
|
||||
bool is_multisample_allowed(wxGLCanvas* canvas) const;
|
||||
|
||||
void enable_layers_editing(wxGLCanvas* canvas, bool enable);
|
||||
void enable_warning_texture(wxGLCanvas* canvas, bool enable);
|
||||
void enable_legend_texture(wxGLCanvas* canvas, bool enable);
|
||||
void enable_picking(wxGLCanvas* canvas, bool enable);
|
||||
|
@ -124,6 +116,9 @@ public:
|
|||
int get_hover_volume_id(wxGLCanvas* canvas) const;
|
||||
void set_hover_volume_id(wxGLCanvas* canvas, int id);
|
||||
|
||||
unsigned int get_layers_editing_z_texture_id(wxGLCanvas* canvas) const;
|
||||
GLShader* get_layers_editing_shader(wxGLCanvas* canvas);
|
||||
|
||||
void zoom_to_bed(wxGLCanvas* canvas);
|
||||
void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||
|
|
|
@ -451,7 +451,15 @@ set_camera_target(canvas, target)
|
|||
Pointf3 *target;
|
||||
CODE:
|
||||
_3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target);
|
||||
|
||||
|
||||
bool
|
||||
is_layers_editing_enabled(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
RETVAL = _3DScene::is_layers_editing_enabled((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
bool
|
||||
is_picking_enabled(canvas)
|
||||
SV *canvas;
|
||||
|
@ -460,14 +468,6 @@ is_picking_enabled(canvas)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
bool
|
||||
is_shader_enabled(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
RETVAL = _3DScene::is_shader_enabled((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
bool
|
||||
is_multisample_allowed(canvas)
|
||||
SV *canvas;
|
||||
|
@ -476,6 +476,13 @@ is_multisample_allowed(canvas)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
enable_layers_editing(canvas, enable)
|
||||
SV *canvas;
|
||||
bool enable;
|
||||
CODE:
|
||||
_3DScene::enable_layers_editing((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), enable);
|
||||
|
||||
void
|
||||
enable_warning_texture(canvas, enable)
|
||||
SV *canvas;
|
||||
|
@ -556,6 +563,22 @@ set_hover_volume_id(canvas, id)
|
|||
CODE:
|
||||
_3DScene::set_hover_volume_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id);
|
||||
|
||||
unsigned int
|
||||
get_layers_editing_z_texture_id(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
RETVAL = _3DScene::get_layers_editing_z_texture_id((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Ref<GLShader>
|
||||
get_layers_editing_shader(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
RETVAL = _3DScene::get_layers_editing_shader((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
zoom_to_bed(canvas)
|
||||
SV *canvas;
|
||||
|
@ -679,7 +702,6 @@ register_on_mark_volumes_for_layer_height_callback(canvas, callback)
|
|||
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
finalize_legend_texture()
|
||||
CODE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue