mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 12:58:59 +08:00
Technology ENABLE_OPENGL_AUTO_AA_SAMPLES set as default
This commit is contained in:
parent
69bb0d87e7
commit
2eeca737ea
@ -182,7 +182,6 @@ int CLI::run(int argc, char **argv)
|
||||
|
||||
#ifdef SLIC3R_GUI
|
||||
std::vector<std::string>::iterator it;
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
bool opengl_aa = false;
|
||||
it = std::find(m_actions.begin(), m_actions.end(), "opengl-aa");
|
||||
if (it != m_actions.end()) {
|
||||
@ -190,7 +189,6 @@ int CLI::run(int argc, char **argv)
|
||||
opengl_aa = true;
|
||||
m_actions.erase(it);
|
||||
}
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
#if SLIC3R_OPENGL_ES
|
||||
// are we starting as gcodeviewer ?
|
||||
for (auto it = m_actions.begin(); it != m_actions.end(); ++it) {
|
||||
@ -252,11 +250,7 @@ int CLI::run(int argc, char **argv)
|
||||
#endif // SLIC3R_OPENGL_ES
|
||||
#else // SLIC3R_GUI
|
||||
// If there is no GUI, we shall ignore the parameters. Remove them from the list.
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
for (const std::string& s : { "opengl-version", "opengl-compatibility", "opengl-debug", "opengl-aa", "gcodeviewer" }) {
|
||||
#else
|
||||
for (const std::string& s : { "opengl-version", "opengl-compatibility", "opengl-debug", "gcodeviewer" }) {
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
auto it = std::find(m_actions.cbegin(), m_actions.cend(), s);
|
||||
if (it != m_actions.end()) {
|
||||
boost::nowide::cerr << "Parameter '" << s << "' is ignored, this PrusaSlicer build is CLI only." << std::endl;
|
||||
@ -757,9 +751,7 @@ int CLI::run(int argc, char **argv)
|
||||
params.start_downloader = start_downloader;
|
||||
params.download_url = download_url;
|
||||
params.delete_after_load = delete_after_load;
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
params.opengl_aa = opengl_aa;
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
#if !SLIC3R_OPENGL_ES
|
||||
params.opengl_version = opengl_version;
|
||||
params.opengl_debug = opengl_debug;
|
||||
|
@ -5014,13 +5014,11 @@ CLIActionsConfigDef::CLIActionsConfigDef()
|
||||
def->cli = "gcodeviewer";
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
def = this->add("opengl-aa", coBool);
|
||||
def->label = L("Automatic OpenGL antialising samples number selection");
|
||||
def->tooltip = L("Automatically select the highest number of samples for OpenGL antialising.");
|
||||
def->cli = "opengl-aa";
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
|
||||
#if !SLIC3R_OPENGL_ES
|
||||
def = this->add("opengl-version", coString);
|
||||
|
@ -47,9 +47,6 @@
|
||||
// Enable smoothing of objects normals
|
||||
#define ENABLE_SMOOTH_NORMALS 0
|
||||
|
||||
// Enable automatic detection of highest number of samples supported for OpenGL antialising
|
||||
#define ENABLE_OPENGL_AUTO_AA_SAMPLES 1
|
||||
|
||||
// Enable imgui dialog which allows to set the parameters used to export binarized gcode
|
||||
#define ENABLE_BINARIZED_GCODE_DEBUG_WINDOW 0
|
||||
|
||||
|
@ -38,9 +38,7 @@ struct GUI_InitParams
|
||||
bool opengl_debug;
|
||||
bool opengl_compatibiity_profile;
|
||||
#endif // !SLIC3R_OPENGL_ES
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
bool opengl_aa;
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
};
|
||||
|
||||
int GUI_Run(GUI_InitParams ¶ms);
|
||||
|
@ -10,9 +10,7 @@
|
||||
#include "GUI_Preview.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI.hpp"
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
#include "GUI_Init.hpp"
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
#include "I18N.hpp"
|
||||
#include "3DScene.hpp"
|
||||
#include "BackgroundSlicingProcess.hpp"
|
||||
@ -68,12 +66,8 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig
|
||||
if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */))
|
||||
return false;
|
||||
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
const GUI_InitParams* const init_params = wxGetApp().init_params;
|
||||
m_canvas_widget = OpenGLManager::create_wxglcanvas(*this, (init_params != nullptr) ? init_params->opengl_aa : false);
|
||||
#else
|
||||
m_canvas_widget = OpenGLManager::create_wxglcanvas(*this);
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
if (m_canvas_widget == nullptr)
|
||||
return false;
|
||||
|
||||
@ -217,12 +211,8 @@ bool Preview::init(wxWindow* parent, Bed3D& bed, Model* model)
|
||||
SetBackgroundColour(GetParent()->GetBackgroundColour());
|
||||
#endif // _WIN32
|
||||
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
const GUI_InitParams* const init_params = wxGetApp().init_params;
|
||||
m_canvas_widget = OpenGLManager::create_wxglcanvas(*this, (init_params != nullptr) ? init_params->opengl_aa : false);
|
||||
#else
|
||||
m_canvas_widget = OpenGLManager::create_wxglcanvas(*this);
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
if (m_canvas_widget == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -131,10 +131,8 @@ void OpenGLManager::GLInfo::detect() const
|
||||
if (!GLEW_ARB_compatibility)
|
||||
*const_cast<bool*>(&m_core_profile) = true;
|
||||
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
int* samples = const_cast<int*>(&m_samples);
|
||||
glsafe(::glGetIntegerv(GL_SAMPLES, samples));
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
|
||||
*const_cast<bool*>(&m_detected) = true;
|
||||
}
|
||||
@ -214,9 +212,7 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
|
||||
out << b_start << "Renderer: " << b_end << m_renderer << line_end;
|
||||
out << b_start << "GLSL version: " << b_end << m_glsl_version << line_end;
|
||||
out << b_start << "Textures compression: " << b_end << (are_compressed_textures_supported() ? "Enabled" : "Disabled") << line_end;
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
out << b_start << "Mutisampling: " << b_end << (can_multisample() ? "Enabled (" + std::to_string(m_samples) + " samples)" : "Disabled") << line_end;
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
|
||||
{
|
||||
#if SLIC3R_OPENGL_ES
|
||||
@ -534,14 +530,9 @@ wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas, const std::pair<i
|
||||
return m_context;
|
||||
}
|
||||
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent, bool enable_auto_aa_samples)
|
||||
#else
|
||||
wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
{
|
||||
wxGLAttributes attribList;
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
s_multisample = EMultisampleState::Disabled;
|
||||
// Disable multi-sampling on ChromeOS, as the OpenGL virtualization swaps Red/Blue channels with multi-sampling enabled,
|
||||
// at least on some platforms.
|
||||
@ -555,23 +546,12 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
attribList.PlatformDefaults().RGBA().DoubleBuffer().MinRGBA(8, 8, 8, 8).Depth(24).SampleBuffers(1).Samplers(4).EndList();
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
#ifdef __APPLE__
|
||||
// on MAC the method RGBA() has no effect
|
||||
attribList.SetNeedsARB(true);
|
||||
#endif // __APPLE__
|
||||
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
if (s_multisample != EMultisampleState::Enabled)
|
||||
#else
|
||||
if (s_multisample == EMultisampleState::Unknown)
|
||||
detect_multisample(attribList);
|
||||
|
||||
if (!can_multisample())
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
{
|
||||
if (s_multisample != EMultisampleState::Enabled) {
|
||||
attribList.Reset();
|
||||
attribList.PlatformDefaults().RGBA().DoubleBuffer().MinRGBA(8, 8, 8, 8).Depth(24).EndList();
|
||||
#ifdef __APPLE__
|
||||
@ -583,22 +563,5 @@ wxGLCanvas* OpenGLManager::create_wxglcanvas(wxWindow& parent)
|
||||
return new wxGLCanvas(&parent, attribList, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS);
|
||||
}
|
||||
|
||||
#if !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
void OpenGLManager::detect_multisample(const wxGLAttributes& attribList)
|
||||
{
|
||||
int wxVersion = wxMAJOR_VERSION * 10000 + wxMINOR_VERSION * 100 + wxRELEASE_NUMBER;
|
||||
bool enable_multisample = wxVersion >= 30003;
|
||||
s_multisample =
|
||||
enable_multisample &&
|
||||
// Disable multi-sampling on ChromeOS, as the OpenGL virtualization swaps Red/Blue channels with multi-sampling enabled,
|
||||
// at least on some platforms.
|
||||
platform_flavor() != PlatformFlavor::LinuxOnChromium &&
|
||||
wxGLCanvas::IsDisplaySupported(attribList)
|
||||
? EMultisampleState::Enabled : EMultisampleState::Disabled;
|
||||
// Alternative method: it was working on previous version of wxWidgets but not with the latest, at least on Windows
|
||||
// s_multisample = enable_multisample && wxGLCanvas::IsExtensionSupported("WGL_ARB_multisample");
|
||||
}
|
||||
#endif // !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
@ -32,9 +32,7 @@ public:
|
||||
bool m_core_profile{ false };
|
||||
int m_max_tex_size{ 0 };
|
||||
float m_max_anisotropy{ 0.0f };
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
int m_samples{ 0 };
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
|
||||
std::string m_version_string;
|
||||
Semver m_version = Semver::invalid();
|
||||
@ -134,18 +132,9 @@ public:
|
||||
static bool can_multisample() { return s_multisample == EMultisampleState::Enabled; }
|
||||
static bool are_framebuffers_supported() { return (s_framebuffers_type != EFramebufferType::Unknown); }
|
||||
static EFramebufferType get_framebuffers_type() { return s_framebuffers_type; }
|
||||
#if ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
static wxGLCanvas* create_wxglcanvas(wxWindow& parent, bool enable_auto_aa_samples);
|
||||
#else
|
||||
static wxGLCanvas* create_wxglcanvas(wxWindow& parent);
|
||||
#endif // ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
static const GLInfo& get_gl_info() { return s_gl_info; }
|
||||
static bool force_power_of_two_textures() { return s_force_power_of_two_textures; }
|
||||
|
||||
private:
|
||||
#if !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
static void detect_multisample(const wxGLAttributes& attribList);
|
||||
#endif // !ENABLE_OPENGL_AUTO_AA_SAMPLES
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
Loading…
x
Reference in New Issue
Block a user