Merge remote-tracking branch 'origin/master' into add_kinematics

This commit is contained in:
YuSanka 2018-06-22 09:22:29 +02:00
commit 9ba1af5834
13 changed files with 254 additions and 88 deletions

View file

@ -405,16 +405,27 @@ GLCanvas3D::Bed::EType GLCanvas3D::Bed::_detect_type() const
const PresetBundle* bundle = get_preset_bundle();
if (bundle != nullptr)
{
const Preset& curr = bundle->printers.get_selected_preset();
if (curr.config.has("bed_shape") && _are_equal(m_shape, dynamic_cast<const ConfigOptionPoints*>(curr.config.option("bed_shape"))->values))
const Preset* curr = &bundle->printers.get_selected_preset();
while (curr != nullptr)
{
if ((curr.vendor != nullptr) && (curr.vendor->name == "Prusa Research"))
if (curr->config.has("bed_shape") && _are_equal(m_shape, dynamic_cast<const ConfigOptionPoints*>(curr->config.option("bed_shape"))->values))
{
if (boost::contains(curr.name, "MK2"))
type = MK2;
else if (boost::contains(curr.name, "MK3"))
type = MK3;
if ((curr->vendor != nullptr) && (curr->vendor->name == "Prusa Research"))
{
if (boost::contains(curr->name, "MK2"))
{
type = MK2;
break;
}
else if (boost::contains(curr->name, "MK3"))
{
type = MK3;
break;
}
}
}
curr = bundle->printers.get_preset_parent(*curr);
}
}

View file

@ -26,33 +26,23 @@ GLCanvas3DManager::GLInfo::GLInfo()
{
}
bool GLCanvas3DManager::GLInfo::detect()
void GLCanvas3DManager::GLInfo::detect()
{
const char* data = (const char*)::glGetString(GL_VERSION);
if (data == nullptr)
return false;
version = data;
if (data != nullptr)
version = data;
data = (const char*)::glGetString(GL_SHADING_LANGUAGE_VERSION);
if (data == nullptr)
return false;
glsl_version = data;
if (data != nullptr)
glsl_version = data;
data = (const char*)::glGetString(GL_VENDOR);
if (data == nullptr)
return false;
vendor = data;
if (data != nullptr)
vendor = data;
data = (const char*)::glGetString(GL_RENDERER);
if (data == nullptr)
return false;
renderer = data;
return true;
if (data != nullptr)
renderer = data;
}
bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
@ -94,10 +84,10 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
std::string line_end = format_as_html ? "<br>" : "\n";
out << h2_start << "OpenGL installation" << h2_end << line_end;
out << b_start << "GL version: " << b_end << version << line_end;
out << b_start << "Vendor: " << b_end << vendor << line_end;
out << b_start << "Renderer: " << b_end << renderer << line_end;
out << b_start << "GLSL version: " << b_end << glsl_version << line_end;
out << b_start << "GL version: " << b_end << (version.empty() ? "N/A" : version) << line_end;
out << b_start << "Vendor: " << b_end << (vendor.empty() ? "N/A" : vendor) << line_end;
out << b_start << "Renderer: " << b_end << (renderer.empty() ? "N/A" : renderer) << line_end;
out << b_start << "GLSL version: " << b_end << (glsl_version.empty() ? "N/A" : glsl_version) << line_end;
if (extensions)
{
@ -195,15 +185,11 @@ void GLCanvas3DManager::init_gl()
if (!m_gl_initialized)
{
glewInit();
if (m_gl_info.detect())
{
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_info.is_version_greater_or_equal_to(2, 0);
m_gl_initialized = true;
}
else
throw std::runtime_error(std::string("Unable to initialize OpenGL driver\n"));
m_gl_info.detect();
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_info.is_version_greater_or_equal_to(2, 0);
m_gl_initialized = true;
}
}

View file

@ -35,7 +35,7 @@ class GLCanvas3DManager
GLInfo();
bool detect();
void detect();
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;

View file

@ -4,6 +4,8 @@
#include <wx/image.h>
#include <boost/filesystem.hpp>
#include <vector>
#include <algorithm>
@ -27,6 +29,9 @@ bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmap
{
reset();
if (!boost::filesystem::exists(filename))
return false;
// Load a PNG with an alpha channel.
wxImage image;
if (!image.LoadFile(filename, wxBITMAP_TYPE_PNG))

View file

@ -28,6 +28,8 @@ struct MsgDialog : wxDialog
MsgDialog &operator=(const MsgDialog &) = delete;
virtual ~MsgDialog();
// TODO: refactor with CreateStdDialogButtonSizer usage
protected:
enum {
CONTENT_WIDTH = 500,