GLCanvas3DManager replaced by OpenGLManager

This commit is contained in:
enricoturri1966 2020-05-06 14:38:53 +02:00
parent 0bb56736a1
commit 6f789aaee7
9 changed files with 57 additions and 77 deletions

View File

@ -27,8 +27,8 @@ set(SLIC3R_GUI_SOURCES
GUI/GLShader.hpp
GUI/GLCanvas3D.hpp
GUI/GLCanvas3D.cpp
GUI/GLCanvas3DManager.hpp
GUI/GLCanvas3DManager.cpp
GUI/OpenGLManager.hpp
GUI/OpenGLManager.cpp
GUI/Selection.hpp
GUI/Selection.cpp
GUI/Gizmos/GLGizmosManager.cpp

View File

@ -410,7 +410,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
if (boost::algorithm::iends_with(m_texture_filename, ".svg"))
{
// use higher resolution images if graphic card and opengl version allow
GLint max_tex_size = GLCanvas3DManager::get_gl_info().get_max_tex_size();
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
if ((m_temp_texture.get_id() == 0) || (m_temp_texture.get_source() != m_texture_filename))
{
// generate a temporary lower resolution texture to show while no main texture levels have been compressed

View File

@ -19,7 +19,7 @@
#include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Tab.hpp"
#include "slic3r/GUI/GUI_Preview.hpp"
#include "slic3r/GUI/GLCanvas3DManager.hpp"
#include "slic3r/GUI/OpenGLManager.hpp"
#include "slic3r/GUI/3DBed.hpp"
#include "slic3r/GUI/Camera.hpp"
@ -2070,10 +2070,10 @@ void GLCanvas3D::render()
ImGui::Separator();
imgui.text("Compressed textures: ");
ImGui::SameLine();
imgui.text(GLCanvas3DManager::are_compressed_textures_supported() ? "supported" : "not supported");
imgui.text(OpenGLManager::are_compressed_textures_supported() ? "supported" : "not supported");
imgui.text("Max texture size: ");
ImGui::SameLine();
imgui.text(std::to_string(GLCanvas3DManager::get_gl_info().get_max_tex_size()));
imgui.text(std::to_string(OpenGLManager::get_gl_info().get_max_tex_size()));
imgui.end();
#endif // ENABLE_RENDER_STATISTICS
@ -2150,10 +2150,10 @@ void GLCanvas3D::render()
void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, bool printable_only, bool parts_only, bool show_bed, bool transparent_background) const
{
switch (GLCanvas3DManager::get_framebuffers_type())
switch (OpenGLManager::get_framebuffers_type())
{
case GLCanvas3DManager::EFramebufferType::Arb: { _render_thumbnail_framebuffer(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
case GLCanvas3DManager::EFramebufferType::Ext: { _render_thumbnail_framebuffer_ext(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
case OpenGLManager::EFramebufferType::Arb: { _render_thumbnail_framebuffer(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
case OpenGLManager::EFramebufferType::Ext: { _render_thumbnail_framebuffer_ext(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
default: { _render_thumbnail_legacy(thumbnail_data, w, h, printable_only, parts_only, show_bed, transparent_background); break; }
}
}

View File

@ -2,7 +2,7 @@
#include "GLTexture.hpp"
#include "3DScene.hpp"
#include "GLCanvas3DManager.hpp"
#include "OpenGLManager.hpp"
#include <GL/glew.h>
@ -441,7 +441,7 @@ bool GLTexture::load_from_png(const std::string& filename, bool use_mipmaps, ECo
if (apply_anisotropy)
{
GLfloat max_anisotropy = GLCanvas3DManager::get_gl_info().get_max_anisotropy();
GLfloat max_anisotropy = OpenGLManager::get_gl_info().get_max_anisotropy();
if (max_anisotropy > 1.0f)
glsafe(::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy));
}
@ -590,7 +590,7 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, boo
if (apply_anisotropy)
{
GLfloat max_anisotropy = GLCanvas3DManager::get_gl_info().get_max_anisotropy();
GLfloat max_anisotropy = OpenGLManager::get_gl_info().get_max_anisotropy();
if (max_anisotropy > 1.0f)
glsafe(::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy));
}

View File

@ -285,17 +285,17 @@ GUI_App::~GUI_App()
std::string GUI_App::get_gl_info(bool format_as_html, bool extensions)
{
return GLCanvas3DManager::get_gl_info().to_string(format_as_html, extensions);
return OpenGLManager::get_gl_info().to_string(format_as_html, extensions);
}
wxGLContext* GUI_App::init_glcontext(wxGLCanvas& canvas)
{
return m_canvas_mgr.init_glcontext(canvas);
return m_opengl_mgr.init_glcontext(canvas);
}
bool GUI_App::init_opengl()
{
return m_canvas_mgr.init_gl();
return m_opengl_mgr.init_gl();
}
void GUI_App::init_app_config()
@ -322,6 +322,7 @@ void GUI_App::init_app_config()
app_config->load();
}
}
bool GUI_App::OnInit()
{
try {

View File

@ -7,7 +7,7 @@
#include "MainFrame.hpp"
#include "ImGuiWrapper.hpp"
#include "ConfigWizard.hpp"
#include "GLCanvas3DManager.hpp"
#include "OpenGLManager.hpp"
#include <wx/app.h>
#include <wx/colour.h>
@ -98,7 +98,7 @@ class GUI_App : public wxApp
// Best translation language, provided by Windows or OSX, owned by wxWidgets.
const wxLanguageInfo *m_language_info_best = nullptr;
GLCanvas3DManager m_canvas_mgr;
OpenGLManager m_opengl_mgr;
std::unique_ptr<RemovableDriveManager> m_removable_drive_manager;

View File

@ -7,7 +7,7 @@
#include "AppConfig.hpp"
#include "3DScene.hpp"
#include "BackgroundSlicingProcess.hpp"
#include "GLCanvas3DManager.hpp"
#include "OpenGLManager.hpp"
#include "GLCanvas3D.hpp"
#include "PresetBundle.hpp"
#include "DoubleSlider.hpp"
@ -48,7 +48,7 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
return false;
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(*this);
m_canvas_widget = OpenGLManager::create_wxglcanvas(*this);
if (m_canvas_widget == nullptr)
return false;
@ -56,7 +56,7 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba
m_canvas->set_context(wxGetApp().init_glcontext(*m_canvas_widget));
m_canvas->bind_event_handlers();
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
m_canvas->allow_multisample(OpenGLManager::can_multisample());
// XXX: If have OpenGL
m_canvas->enable_picking(true);
m_canvas->enable_moving(true);
@ -209,14 +209,14 @@ bool Preview::init(wxWindow* parent, Model* model)
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
return false;
m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(*this);
m_canvas_widget = OpenGLManager::create_wxglcanvas(*this);
if (m_canvas_widget == nullptr)
return false;
m_canvas = new GLCanvas3D(m_canvas_widget);
m_canvas->set_context(wxGetApp().init_glcontext(*m_canvas_widget));
m_canvas->bind_event_handlers();
m_canvas->allow_multisample(GLCanvas3DManager::can_multisample());
m_canvas->allow_multisample(OpenGLManager::can_multisample());
m_canvas->set_config(m_config);
m_canvas->set_model(model);
m_canvas->set_process(m_process);

View File

@ -1,21 +1,17 @@
#include "libslic3r/libslic3r.h"
#include "GLCanvas3DManager.hpp"
#include "../../slic3r/GUI/GUI.hpp"
#include "../../slic3r/GUI/AppConfig.hpp"
#include "../../slic3r/GUI/GLCanvas3D.hpp"
#include "OpenGLManager.hpp"
#include "GUI.hpp"
#include "I18N.hpp"
#include "3DScene.hpp"
#include <GL/glew.h>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/log/trivial.hpp>
#include <wx/glcanvas.h>
#include <wx/timer.h>
#include <wx/msgdlg.h>
#include <vector>
#include <string>
#include <iostream>
#include <wx/glcanvas.h>
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
@ -31,7 +27,7 @@
namespace Slic3r {
namespace GUI {
const std::string& GLCanvas3DManager::GLInfo::get_version() const
const std::string& OpenGLManager::GLInfo::get_version() const
{
if (!m_detected)
detect();
@ -39,7 +35,7 @@ const std::string& GLCanvas3DManager::GLInfo::get_version() const
return m_version;
}
const std::string& GLCanvas3DManager::GLInfo::get_glsl_version() const
const std::string& OpenGLManager::GLInfo::get_glsl_version() const
{
if (!m_detected)
detect();
@ -47,7 +43,7 @@ const std::string& GLCanvas3DManager::GLInfo::get_glsl_version() const
return m_glsl_version;
}
const std::string& GLCanvas3DManager::GLInfo::get_vendor() const
const std::string& OpenGLManager::GLInfo::get_vendor() const
{
if (!m_detected)
detect();
@ -55,7 +51,7 @@ const std::string& GLCanvas3DManager::GLInfo::get_vendor() const
return m_vendor;
}
const std::string& GLCanvas3DManager::GLInfo::get_renderer() const
const std::string& OpenGLManager::GLInfo::get_renderer() const
{
if (!m_detected)
detect();
@ -63,7 +59,7 @@ const std::string& GLCanvas3DManager::GLInfo::get_renderer() const
return m_renderer;
}
int GLCanvas3DManager::GLInfo::get_max_tex_size() const
int OpenGLManager::GLInfo::get_max_tex_size() const
{
if (!m_detected)
detect();
@ -78,7 +74,7 @@ int GLCanvas3DManager::GLInfo::get_max_tex_size() const
#endif // __APPLE__
}
float GLCanvas3DManager::GLInfo::get_max_anisotropy() const
float OpenGLManager::GLInfo::get_max_anisotropy() const
{
if (!m_detected)
detect();
@ -86,7 +82,7 @@ float GLCanvas3DManager::GLInfo::get_max_anisotropy() const
return m_max_anisotropy;
}
void GLCanvas3DManager::GLInfo::detect() const
void OpenGLManager::GLInfo::detect() const
{
const char* data = (const char*)::glGetString(GL_VERSION);
if (data != nullptr)
@ -117,7 +113,7 @@ void GLCanvas3DManager::GLInfo::detect() const
m_detected = true;
}
bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
bool OpenGLManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
{
if (!m_detected)
detect();
@ -148,7 +144,7 @@ bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int majo
return gl_minor >= minor;
}
std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool extensions) const
std::string OpenGLManager::GLInfo::to_string(bool format_as_html, bool extensions) const
{
if (!m_detected)
detect();
@ -188,19 +184,19 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten
return out.str();
}
GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info;
bool GLCanvas3DManager::s_compressed_textures_supported = false;
GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::EMultisampleState::Unknown;
GLCanvas3DManager::EFramebufferType GLCanvas3DManager::s_framebuffers_type = GLCanvas3DManager::EFramebufferType::Unknown;
OpenGLManager::GLInfo OpenGLManager::s_gl_info;
bool OpenGLManager::s_compressed_textures_supported = false;
OpenGLManager::EMultisampleState OpenGLManager::s_multisample = OpenGLManager::EMultisampleState::Unknown;
OpenGLManager::EFramebufferType OpenGLManager::s_framebuffers_type = OpenGLManager::EFramebufferType::Unknown;
#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
GLCanvas3DManager::OSInfo GLCanvas3DManager::s_os_info;
OpenGLManager::OSInfo OpenGLManager::s_os_info;
#endif // __APPLE__
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
GLCanvas3DManager::~GLCanvas3DManager()
OpenGLManager::~OpenGLManager()
{
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
@ -221,7 +217,7 @@ GLCanvas3DManager::~GLCanvas3DManager()
#endif // ENABLE_HACK_CLOSING_ON_OSX_10_9_5
}
bool GLCanvas3DManager::init_gl()
bool OpenGLManager::init_gl()
{
if (!m_gl_initialized)
{
@ -249,19 +245,19 @@ bool GLCanvas3DManager::init_gl()
_utf8(L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n"
"while OpenGL version %s, render %s, vendor %s was detected."))) % s_gl_info.get_version() % s_gl_info.get_renderer() % s_gl_info.get_vendor()).str());
message += "\n";
message += _(L("You may need to update your graphics card driver."));
message += _L("You may need to update your graphics card driver.");
#ifdef _WIN32
message += "\n";
message += _(L("As a workaround, you may run PrusaSlicer with a software rendered 3D graphics by running prusa-slicer.exe with the --sw_renderer parameter."));
message += _L("As a workaround, you may run PrusaSlicer with a software rendered 3D graphics by running prusa-slicer.exe with the --sw_renderer parameter.");
#endif
wxMessageBox(message, wxString("PrusaSlicer - ") + _(L("Unsupported OpenGL version")), wxOK | wxICON_ERROR);
wxMessageBox(message, wxString("PrusaSlicer - ") + _L("Unsupported OpenGL version"), wxOK | wxICON_ERROR);
}
}
return true;
}
wxGLContext* GLCanvas3DManager::init_glcontext(wxGLCanvas& canvas)
wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
{
if (m_context == nullptr)
{
@ -279,7 +275,7 @@ wxGLContext* GLCanvas3DManager::init_glcontext(wxGLCanvas& canvas)
return m_context;
}
wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow& parent)
wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
{
int attribList[] = {
WX_GL_RGBA,
@ -310,7 +306,7 @@ wxGLCanvas* GLCanvas3DManager::create_wxglcanvas(wxWindow& parent)
return new wxGLCanvas(&parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
}
void GLCanvas3DManager::detect_multisample(int* attribList)
void OpenGLManager::detect_multisample(int* attribList)
{
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
bool enable_multisample = wxVersion >= 30003;

View File

@ -1,30 +1,13 @@
#ifndef slic3r_GLCanvas3DManager_hpp_
#define slic3r_GLCanvas3DManager_hpp_
#ifndef slic3r_OpenGLManager_hpp_
#define slic3r_OpenGLManager_hpp_
#include "libslic3r/BoundingBox.hpp"
#include <map>
#include <vector>
class wxWindow;
class wxGLCanvas;
class wxGLContext;
namespace Slic3r {
class BackgroundSlicingProcess;
class DynamicPrintConfig;
class Model;
class ExPolygon;
typedef std::vector<ExPolygon> ExPolygons;
class ModelObject;
class PrintObject;
namespace GUI {
class GLCanvas3D;
class GLCanvas3DManager
class OpenGLManager
{
public:
enum class EFramebufferType : unsigned char
@ -98,8 +81,8 @@ private:
static EFramebufferType s_framebuffers_type;
public:
GLCanvas3DManager() = default;
~GLCanvas3DManager();
OpenGLManager() = default;
~OpenGLManager();
bool init_gl();
@ -119,4 +102,4 @@ private:
} // namespace GUI
} // namespace Slic3r
#endif // slic3r_GLCanvas3DManager_hpp_
#endif // slic3r_OpenGLManager_hpp_