mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 00:45:57 +08:00
New gcode visualization integration - Added check of OpenGL version
This commit is contained in:
parent
08b6369ae4
commit
f20f5cc153
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
#ifdef HAS_GLSAFE
|
#ifdef HAS_GLSAFE
|
||||||
void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name)
|
void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char* function_name)
|
||||||
{
|
{
|
||||||
@ -40,6 +42,21 @@ void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char
|
|||||||
}
|
}
|
||||||
#endif // HAS_GLSAFE
|
#endif // HAS_GLSAFE
|
||||||
|
|
||||||
|
bool check_opengl_version()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
const GLubyte* version = glGetString(GL_VERSION);
|
||||||
|
if (version != nullptr) {
|
||||||
|
const std::string version_str(reinterpret_cast<const char*>(version));
|
||||||
|
if (version_str.length() > 4 && isdigit(version_str[0]) && isdigit(version_str[2])) {
|
||||||
|
const int major = version_str[0] - '0';
|
||||||
|
const int minor = version_str[2] - '0';
|
||||||
|
ret = major > 3 || (major == 3 && minor >= 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
|
||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
|
@ -31,6 +31,8 @@ inline void glAssertRecentCall() { }
|
|||||||
#define glcheck()
|
#define glcheck()
|
||||||
#endif // HAS_GLSAFE
|
#endif // HAS_GLSAFE
|
||||||
|
|
||||||
|
extern bool check_opengl_version();
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
|
||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
|
@ -298,9 +298,14 @@ ViewerImpl::~ViewerImpl()
|
|||||||
|
|
||||||
void ViewerImpl::init()
|
void ViewerImpl::init()
|
||||||
{
|
{
|
||||||
if (m_segments_shader_id != 0)
|
if (m_initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const bool is_valid_opengl_version = check_opengl_version();
|
||||||
|
assert(is_valid_opengl_version);
|
||||||
|
if (!is_valid_opengl_version)
|
||||||
|
throw std::runtime_error("LibVGCode requires an active OpenGL context based on OpenGL 3.2 or higher:\n");
|
||||||
|
|
||||||
// segments shader
|
// segments shader
|
||||||
m_segments_shader_id = init_shader("segments", Segments_Vertex_Shader, Segments_Fragment_Shader);
|
m_segments_shader_id = init_shader("segments", Segments_Vertex_Shader, Segments_Fragment_Shader);
|
||||||
|
|
||||||
@ -375,6 +380,8 @@ void ViewerImpl::init()
|
|||||||
|
|
||||||
m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f);
|
m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f);
|
||||||
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
|
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerImpl::reset()
|
void ViewerImpl::reset()
|
||||||
|
@ -171,6 +171,7 @@ private:
|
|||||||
std::array<float, Time_Modes_Count> m_travels_time{ 0.0f, 0.0f };
|
std::array<float, Time_Modes_Count> m_travels_time{ 0.0f, 0.0f };
|
||||||
std::vector<uint8_t> m_used_extruders_ids;
|
std::vector<uint8_t> m_used_extruders_ids;
|
||||||
|
|
||||||
|
bool m_initialized{ false };
|
||||||
bool m_loading{ false };
|
bool m_loading{ false };
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user