mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 05:26:02 +08:00
libvgcode - Precompiler definition of ENABLE_OPENGL_ES moved into CMakeLists.txt
This commit is contained in:
parent
c75c10e908
commit
dbeea5dd0e
@ -4,12 +4,9 @@ project(libvgcode)
|
|||||||
# glad library
|
# glad library
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
set(GLAD_SOURCES
|
set(GLAD_SOURCES
|
||||||
# glad/include/glad/egl.h
|
|
||||||
glad/include/glad/gles2.h
|
glad/include/glad/gles2.h
|
||||||
# glad/include/EGL/eglplatform.h
|
|
||||||
glad/include/KHR/khrplatform.h
|
glad/include/KHR/khrplatform.h
|
||||||
glad/src/gles2.c
|
glad/src/gles2.c
|
||||||
# glad/src/egl.c
|
|
||||||
)
|
)
|
||||||
else ()
|
else ()
|
||||||
set(GLAD_SOURCES
|
set(GLAD_SOURCES
|
||||||
@ -67,6 +64,10 @@ set(LIBVGCODE_SOURCES
|
|||||||
|
|
||||||
add_library(libvgcode STATIC ${LIBVGCODE_SOURCES})
|
add_library(libvgcode STATIC ${LIBVGCODE_SOURCES})
|
||||||
|
|
||||||
|
if (EMSCRIPTEN)
|
||||||
|
add_compile_definitions(ENABLE_OPENGL_ES)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
foreach(_source IN ITEMS ${LIBVGCODE_SOURCES})
|
foreach(_source IN ITEMS ${LIBVGCODE_SOURCES})
|
||||||
get_filename_component(_source_path "${_source}" PATH)
|
get_filename_component(_source_path "${_source}" PATH)
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#ifndef VGCODE_GCODEINPUTDATA_HPP
|
#ifndef VGCODE_GCODEINPUTDATA_HPP
|
||||||
#define VGCODE_GCODEINPUTDATA_HPP
|
#define VGCODE_GCODEINPUTDATA_HPP
|
||||||
|
|
||||||
#include "Types.hpp"
|
|
||||||
#include "PathVertex.hpp"
|
#include "PathVertex.hpp"
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef VGCODE_TYPES_HPP
|
#ifndef VGCODE_TYPES_HPP
|
||||||
#define VGCODE_TYPES_HPP
|
#define VGCODE_TYPES_HPP
|
||||||
|
|
||||||
#define VGCODE_ENABLE_OPENGL_ES 0
|
|
||||||
|
|
||||||
#define VGCODE_ENABLE_COG_AND_TOOL_MARKERS 0
|
#define VGCODE_ENABLE_COG_AND_TOOL_MARKERS 0
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
///|/
|
///|/
|
||||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||||
///|/
|
///|/
|
||||||
|
// needed for tech VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
||||||
|
#include "../include/Types.hpp"
|
||||||
#include "CogMarker.hpp"
|
#include "CogMarker.hpp"
|
||||||
#include "OpenGLUtils.hpp"
|
#include "OpenGLUtils.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef VGCODE_COGMARKER_HPP
|
#ifndef VGCODE_COGMARKER_HPP
|
||||||
#define VGCODE_COGMARKER_HPP
|
#define VGCODE_COGMARKER_HPP
|
||||||
|
|
||||||
#include "../include/Types.hpp"
|
|
||||||
|
|
||||||
#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||||
///|/
|
///|/
|
||||||
|
|
||||||
#include "../include/Types.hpp"
|
|
||||||
#include "OpenGLUtils.hpp"
|
#include "OpenGLUtils.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -28,10 +27,10 @@ void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char
|
|||||||
case GL_INVALID_OPERATION: { sErr = "Invalid Operation"; break; }
|
case GL_INVALID_OPERATION: { sErr = "Invalid Operation"; break; }
|
||||||
case GL_OUT_OF_MEMORY: { sErr = "Out Of Memory"; break; }
|
case GL_OUT_OF_MEMORY: { sErr = "Out Of Memory"; break; }
|
||||||
case GL_INVALID_FRAMEBUFFER_OPERATION: { sErr = "Invalid framebuffer operation"; break; }
|
case GL_INVALID_FRAMEBUFFER_OPERATION: { sErr = "Invalid framebuffer operation"; break; }
|
||||||
#if !VGCODE_ENABLE_OPENGL_ES
|
#if !defined(ENABLE_OPENGL_ES)
|
||||||
case GL_STACK_OVERFLOW: { sErr = "Stack Overflow"; break; }
|
case GL_STACK_OVERFLOW: { sErr = "Stack Overflow"; break; }
|
||||||
case GL_STACK_UNDERFLOW: { sErr = "Stack Underflow"; break; }
|
case GL_STACK_UNDERFLOW: { sErr = "Stack Underflow"; break; }
|
||||||
#endif // !VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
default: { sErr = "Unknown"; break; }
|
default: { sErr = "Unknown"; break; }
|
||||||
}
|
}
|
||||||
std::cout << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr << "\n";
|
std::cout << "OpenGL error in " << file_name << ":" << line << ", function " << function_name << "() : " << (int)err << " - " << sErr << "\n";
|
||||||
@ -42,9 +41,9 @@ void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char
|
|||||||
static const char* OPENGL_ES_PREFIXES[] = { "OpenGL ES-CM ", "OpenGL ES-CL ", "OpenGL ES ", nullptr };
|
static const char* OPENGL_ES_PREFIXES[] = { "OpenGL ES-CM ", "OpenGL ES-CL ", "OpenGL ES ", nullptr };
|
||||||
|
|
||||||
bool OpenGLWrapper::s_valid_context = false;
|
bool OpenGLWrapper::s_valid_context = false;
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
int OpenGLWrapper::s_max_texture_size = 0;
|
int OpenGLWrapper::s_max_texture_size = 0;
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
bool OpenGLWrapper::load_opengl(const std::string& context_version)
|
bool OpenGLWrapper::load_opengl(const std::string& context_version)
|
||||||
{
|
{
|
||||||
@ -69,31 +68,31 @@ bool OpenGLWrapper::load_opengl(const std::string& context_version)
|
|||||||
if (res != 2)
|
if (res != 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
s_valid_context = major > 3 || (major == 3 && minor >= 0);
|
s_valid_context = major > 3 || (major == 3 && minor >= 0);
|
||||||
const int glad_res = gladLoaderLoadGLES2();
|
const int glad_res = gladLoaderLoadGLES2();
|
||||||
#else
|
#else
|
||||||
s_valid_context = major > 3 || (major == 3 && minor >= 2);
|
s_valid_context = major > 3 || (major == 3 && minor >= 2);
|
||||||
const int glad_res = gladLoaderLoadGL();
|
const int glad_res = gladLoaderLoadGL();
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
if (glad_res == 0)
|
if (glad_res == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
glsafe(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &s_max_texture_size));
|
glsafe(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &s_max_texture_size));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
return s_valid_context;
|
return s_valid_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLWrapper::unload_opengl()
|
void OpenGLWrapper::unload_opengl()
|
||||||
{
|
{
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
gladLoaderUnloadGLES2();
|
gladLoaderUnloadGLES2();
|
||||||
#else
|
#else
|
||||||
gladLoaderUnloadGL();
|
gladLoaderUnloadGL();
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
#define VGCODE_OPENGLUTILS_HPP
|
#define VGCODE_OPENGLUTILS_HPP
|
||||||
|
|
||||||
// OpenGL loader
|
// OpenGL loader
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
#include "../glad/include/glad/gles2.h"
|
#include "../glad/include/glad/gles2.h"
|
||||||
#else
|
#else
|
||||||
#include "../glad/include/glad/gl.h"
|
#include "../glad/include/glad/gl.h"
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -36,15 +36,15 @@ public:
|
|||||||
static bool load_opengl(const std::string& context_version);
|
static bool load_opengl(const std::string& context_version);
|
||||||
static void unload_opengl();
|
static void unload_opengl();
|
||||||
static bool is_valid_context() { return s_valid_context; }
|
static bool is_valid_context() { return s_valid_context; }
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
static size_t max_texture_size() { return static_cast<size_t>(s_max_texture_size); }
|
static size_t max_texture_size() { return static_cast<size_t>(s_max_texture_size); }
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool s_valid_context;
|
static bool s_valid_context;
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
static int s_max_texture_size;
|
static int s_max_texture_size;
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace libvgcode
|
} // namespace libvgcode
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
///|/
|
///|/
|
||||||
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
///|/ libvgcode is released under the terms of the AGPLv3 or higher
|
||||||
///|/
|
///|/
|
||||||
#include "../include/Types.hpp"
|
|
||||||
#include "SegmentTemplate.hpp"
|
#include "SegmentTemplate.hpp"
|
||||||
#include "OpenGLUtils.hpp"
|
#include "OpenGLUtils.hpp"
|
||||||
|
|
||||||
@ -46,11 +45,11 @@ void SegmentTemplate::init()
|
|||||||
glsafe(glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id));
|
glsafe(glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id));
|
||||||
glsafe(glBufferData(GL_ARRAY_BUFFER, VERTEX_DATA.size() * sizeof(uint8_t), VERTEX_DATA.data(), GL_STATIC_DRAW));
|
glsafe(glBufferData(GL_ARRAY_BUFFER, VERTEX_DATA.size() * sizeof(uint8_t), VERTEX_DATA.data(), GL_STATIC_DRAW));
|
||||||
glsafe(glEnableVertexAttribArray(0));
|
glsafe(glEnableVertexAttribArray(0));
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
glsafe(glVertexAttribPointer(0, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, (const void*)0));
|
glsafe(glVertexAttribPointer(0, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, (const void*)0));
|
||||||
#else
|
#else
|
||||||
glsafe(glVertexAttribIPointer(0, 1, GL_UNSIGNED_BYTE, 0, (const void*)0));
|
glsafe(glVertexAttribIPointer(0, 1, GL_UNSIGNED_BYTE, 0, (const void*)0));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
glsafe(glBindBuffer(GL_ARRAY_BUFFER, curr_array_buffer));
|
glsafe(glBindBuffer(GL_ARRAY_BUFFER, curr_array_buffer));
|
||||||
glsafe(glBindVertexArray(curr_vertex_array));
|
glsafe(glBindVertexArray(curr_vertex_array));
|
||||||
|
@ -310,7 +310,7 @@ static const std::map<EOptionType, Color> DEFAULT_OPTIONS_COLORS{ {
|
|||||||
{ EOptionType::CustomGCodes, { 226, 210, 67 } }
|
{ EOptionType::CustomGCodes, { 226, 210, 67 } }
|
||||||
} };
|
} };
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
static std::pair<size_t, size_t> width_height(size_t count)
|
static std::pair<size_t, size_t> width_height(size_t count)
|
||||||
{
|
{
|
||||||
std::pair<size_t, size_t> ret;
|
std::pair<size_t, size_t> ret;
|
||||||
@ -718,7 +718,7 @@ size_t ViewerImpl::TextureData::get_used_gpu_memory() const
|
|||||||
ret += m_enabled_options_size;
|
ret += m_enabled_options_size;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
ViewerImpl::ViewerImpl()
|
ViewerImpl::ViewerImpl()
|
||||||
{
|
{
|
||||||
@ -735,20 +735,20 @@ void ViewerImpl::init(const std::string& opengl_context_version)
|
|||||||
if (OpenGLWrapper::is_valid_context())
|
if (OpenGLWrapper::is_valid_context())
|
||||||
throw std::runtime_error("LibVGCode was unable to initialize the GLAD library.\n");
|
throw std::runtime_error("LibVGCode was unable to initialize the GLAD library.\n");
|
||||||
else {
|
else {
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
throw std::runtime_error("LibVGCode requires an OpenGL ES context based on OpenGL ES 3.0 or higher.\n");
|
throw std::runtime_error("LibVGCode requires an OpenGL ES context based on OpenGL ES 3.0 or higher.\n");
|
||||||
#else
|
#else
|
||||||
throw std::runtime_error("LibVGCode requires an OpenGL context based on OpenGL 3.2 or higher.\n");
|
throw std::runtime_error("LibVGCode requires an OpenGL context based on OpenGL 3.2 or higher.\n");
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// segments shader
|
// segments shader
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_segments_shader_id = init_shader("segments", Segments_Vertex_Shader_ES, Segments_Fragment_Shader_ES);
|
m_segments_shader_id = init_shader("segments", Segments_Vertex_Shader_ES, Segments_Fragment_Shader_ES);
|
||||||
#else
|
#else
|
||||||
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);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
m_uni_segments_view_matrix_id = glGetUniformLocation(m_segments_shader_id, "view_matrix");
|
m_uni_segments_view_matrix_id = glGetUniformLocation(m_segments_shader_id, "view_matrix");
|
||||||
m_uni_segments_projection_matrix_id = glGetUniformLocation(m_segments_shader_id, "projection_matrix");
|
m_uni_segments_projection_matrix_id = glGetUniformLocation(m_segments_shader_id, "projection_matrix");
|
||||||
@ -769,11 +769,11 @@ void ViewerImpl::init(const std::string& opengl_context_version)
|
|||||||
m_segment_template.init();
|
m_segment_template.init();
|
||||||
|
|
||||||
// options shader
|
// options shader
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_options_shader_id = init_shader("options", Options_Vertex_Shader_ES, Options_Fragment_Shader_ES);
|
m_options_shader_id = init_shader("options", Options_Vertex_Shader_ES, Options_Fragment_Shader_ES);
|
||||||
#else
|
#else
|
||||||
m_options_shader_id = init_shader("options", Options_Vertex_Shader, Options_Fragment_Shader);
|
m_options_shader_id = init_shader("options", Options_Vertex_Shader, Options_Fragment_Shader);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
m_uni_options_view_matrix_id = glGetUniformLocation(m_options_shader_id, "view_matrix");
|
m_uni_options_view_matrix_id = glGetUniformLocation(m_options_shader_id, "view_matrix");
|
||||||
m_uni_options_projection_matrix_id = glGetUniformLocation(m_options_shader_id, "projection_matrix");
|
m_uni_options_projection_matrix_id = glGetUniformLocation(m_options_shader_id, "projection_matrix");
|
||||||
@ -793,11 +793,11 @@ void ViewerImpl::init(const std::string& opengl_context_version)
|
|||||||
|
|
||||||
#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
||||||
// cog marker shader
|
// cog marker shader
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader_ES, Cog_Marker_Fragment_Shader_ES);
|
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader_ES, Cog_Marker_Fragment_Shader_ES);
|
||||||
#else
|
#else
|
||||||
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader);
|
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
m_uni_cog_marker_world_center_position = glGetUniformLocation(m_cog_marker_shader_id, "world_center_position");
|
m_uni_cog_marker_world_center_position = glGetUniformLocation(m_cog_marker_shader_id, "world_center_position");
|
||||||
m_uni_cog_marker_scale_factor = glGetUniformLocation(m_cog_marker_shader_id, "scale_factor");
|
m_uni_cog_marker_scale_factor = glGetUniformLocation(m_cog_marker_shader_id, "scale_factor");
|
||||||
@ -812,11 +812,11 @@ void ViewerImpl::init(const std::string& opengl_context_version)
|
|||||||
m_cog_marker.init(32, 1.0f);
|
m_cog_marker.init(32, 1.0f);
|
||||||
|
|
||||||
// tool marker shader
|
// tool marker shader
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader_ES, Tool_Marker_Fragment_Shader_ES);
|
m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader_ES, Tool_Marker_Fragment_Shader_ES);
|
||||||
#else
|
#else
|
||||||
m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader, Tool_Marker_Fragment_Shader);
|
m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader, Tool_Marker_Fragment_Shader);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
m_uni_tool_marker_world_origin = glGetUniformLocation(m_tool_marker_shader_id, "world_origin");
|
m_uni_tool_marker_world_origin = glGetUniformLocation(m_tool_marker_shader_id, "world_origin");
|
||||||
m_uni_tool_marker_scale_factor = glGetUniformLocation(m_tool_marker_shader_id, "scale_factor");
|
m_uni_tool_marker_scale_factor = glGetUniformLocation(m_tool_marker_shader_id, "scale_factor");
|
||||||
@ -873,7 +873,7 @@ void ViewerImpl::reset()
|
|||||||
m_cog_marker.reset();
|
m_cog_marker.reset();
|
||||||
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_texture_data.reset();
|
m_texture_data.reset();
|
||||||
#else
|
#else
|
||||||
m_enabled_segments_count = 0;
|
m_enabled_segments_count = 0;
|
||||||
@ -889,7 +889,7 @@ void ViewerImpl::reset()
|
|||||||
delete_buffers(m_heights_widths_angles_buf_id);
|
delete_buffers(m_heights_widths_angles_buf_id);
|
||||||
delete_textures(m_positions_tex_id);
|
delete_textures(m_positions_tex_id);
|
||||||
delete_buffers(m_positions_buf_id);
|
delete_buffers(m_positions_buf_id);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
static void extract_pos_and_or_hwa(const std::vector<PathVertex>& vertices, float travels_radius, float wipes_radius, BitSet<>& valid_lines_bitset,
|
static void extract_pos_and_or_hwa(const std::vector<PathVertex>& vertices, float travels_radius, float wipes_radius, BitSet<>& valid_lines_bitset,
|
||||||
@ -1038,7 +1038,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
|||||||
extract_pos_and_or_hwa(m_vertices, m_travels_radius, m_wipes_radius, m_valid_lines_bitset, &positions, &heights_widths_angles, true);
|
extract_pos_and_or_hwa(m_vertices, m_travels_radius, m_wipes_radius, m_valid_lines_bitset, &positions, &heights_widths_angles, true);
|
||||||
|
|
||||||
if (!positions.empty()) {
|
if (!positions.empty()) {
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_texture_data.init(positions.size());
|
m_texture_data.init(positions.size());
|
||||||
// create and fill position textures
|
// create and fill position textures
|
||||||
m_texture_data.set_positions(positions);
|
m_texture_data.set_positions(positions);
|
||||||
@ -1085,7 +1085,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
|||||||
|
|
||||||
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
||||||
glsafe(glBindTexture(GL_TEXTURE_BUFFER, old_bound_texture));
|
glsafe(glBindTexture(GL_TEXTURE_BUFFER, old_bound_texture));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
update_view_full_range();
|
update_view_full_range();
|
||||||
@ -1152,7 +1152,7 @@ void ViewerImpl::update_enabled_entities()
|
|||||||
enabled_segments.push_back(static_cast<uint32_t>(i));
|
enabled_segments.push_back(static_cast<uint32_t>(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
m_texture_data.set_enabled_segments(enabled_segments);
|
m_texture_data.set_enabled_segments(enabled_segments);
|
||||||
m_texture_data.set_enabled_options(enabled_options);
|
m_texture_data.set_enabled_options(enabled_options);
|
||||||
#else
|
#else
|
||||||
@ -1179,7 +1179,7 @@ void ViewerImpl::update_enabled_entities()
|
|||||||
glsafe(glBufferData(GL_TEXTURE_BUFFER, 0, nullptr, GL_STATIC_DRAW));
|
glsafe(glBufferData(GL_TEXTURE_BUFFER, 0, nullptr, GL_STATIC_DRAW));
|
||||||
|
|
||||||
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
m_settings.update_enabled_entities = false;
|
m_settings.update_enabled_entities = false;
|
||||||
}
|
}
|
||||||
@ -1194,10 +1194,10 @@ static float encode_color(const Color& color) {
|
|||||||
|
|
||||||
void ViewerImpl::update_colors()
|
void ViewerImpl::update_colors()
|
||||||
{
|
{
|
||||||
#if !VGCODE_ENABLE_OPENGL_ES
|
#if !defined(ENABLE_OPENGL_ES)
|
||||||
if (m_colors_buf_id == 0)
|
if (m_colors_buf_id == 0)
|
||||||
return;
|
return;
|
||||||
#endif // !VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
if (!m_used_extruders.empty()) {
|
if (!m_used_extruders.empty()) {
|
||||||
// ensure that the number of defined tool colors matches the max id of the used extruders
|
// ensure that the number of defined tool colors matches the max id of the used extruders
|
||||||
@ -1221,7 +1221,7 @@ void ViewerImpl::update_colors()
|
|||||||
encode_color(DUMMY_COLOR) : encode_color(get_vertex_color(m_vertices[i]));
|
encode_color(DUMMY_COLOR) : encode_color(get_vertex_color(m_vertices[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
if (!colors.empty())
|
if (!colors.empty())
|
||||||
// update gpu buffer for colors
|
// update gpu buffer for colors
|
||||||
m_texture_data.set_colors(colors);
|
m_texture_data.set_colors(colors);
|
||||||
@ -1232,7 +1232,7 @@ void ViewerImpl::update_colors()
|
|||||||
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_colors_buf_id));
|
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, m_colors_buf_id));
|
||||||
glsafe(glBufferData(GL_TEXTURE_BUFFER, colors.size() * sizeof(float), colors.data(), GL_STATIC_DRAW));
|
glsafe(glBufferData(GL_TEXTURE_BUFFER, colors.size() * sizeof(float), colors.data(), GL_STATIC_DRAW));
|
||||||
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
m_settings.update_colors = false;
|
m_settings.update_colors = false;
|
||||||
}
|
}
|
||||||
@ -1628,7 +1628,7 @@ size_t ViewerImpl::get_used_gpu_memory() const
|
|||||||
ret += m_tool_marker.size_in_bytes_gpu();
|
ret += m_tool_marker.size_in_bytes_gpu();
|
||||||
ret += m_cog_marker.size_in_bytes_gpu();
|
ret += m_cog_marker.size_in_bytes_gpu();
|
||||||
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
ret += m_texture_data.get_used_gpu_memory();
|
ret += m_texture_data.get_used_gpu_memory();
|
||||||
#else
|
#else
|
||||||
ret += m_positions_tex_size;
|
ret += m_positions_tex_size;
|
||||||
@ -1636,7 +1636,7 @@ size_t ViewerImpl::get_used_gpu_memory() const
|
|||||||
ret += m_colors_tex_size;
|
ret += m_colors_tex_size;
|
||||||
ret += m_enabled_segments_tex_size;
|
ret += m_enabled_segments_tex_size;
|
||||||
ret += m_enabled_options_tex_size;
|
ret += m_enabled_options_tex_size;
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1787,7 +1787,7 @@ void ViewerImpl::update_color_ranges()
|
|||||||
|
|
||||||
void ViewerImpl::update_heights_widths()
|
void ViewerImpl::update_heights_widths()
|
||||||
{
|
{
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
std::vector<Vec3> heights_widths_angles;
|
std::vector<Vec3> heights_widths_angles;
|
||||||
heights_widths_angles.reserve(m_vertices.size());
|
heights_widths_angles.reserve(m_vertices.size());
|
||||||
extract_pos_and_or_hwa(m_vertices, m_travels_radius, m_wipes_radius, m_valid_lines_bitset, nullptr, &heights_widths_angles);
|
extract_pos_and_or_hwa(m_vertices, m_travels_radius, m_wipes_radius, m_valid_lines_bitset, nullptr, &heights_widths_angles);
|
||||||
@ -1815,7 +1815,7 @@ void ViewerImpl::update_heights_widths()
|
|||||||
|
|
||||||
glsafe(glUnmapBuffer(GL_TEXTURE_BUFFER));
|
glsafe(glUnmapBuffer(GL_TEXTURE_BUFFER));
|
||||||
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
glsafe(glBindBuffer(GL_TEXTURE_BUFFER, 0));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerImpl::render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position)
|
void ViewerImpl::render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position)
|
||||||
@ -1823,11 +1823,11 @@ void ViewerImpl::render_segments(const Mat4x4& view_matrix, const Mat4x4& projec
|
|||||||
if (m_segments_shader_id == 0)
|
if (m_segments_shader_id == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
if (m_texture_data.get_enabled_segments_count() == 0)
|
if (m_texture_data.get_enabled_segments_count() == 0)
|
||||||
#else
|
#else
|
||||||
if (m_enabled_segments_count == 0)
|
if (m_enabled_segments_count == 0)
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int curr_active_texture = 0;
|
int curr_active_texture = 0;
|
||||||
@ -1849,7 +1849,7 @@ void ViewerImpl::render_segments(const Mat4x4& view_matrix, const Mat4x4& projec
|
|||||||
|
|
||||||
glsafe(glDisable(GL_CULL_FACE));
|
glsafe(glDisable(GL_CULL_FACE));
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
int curr_bound_texture = 0;
|
int curr_bound_texture = 0;
|
||||||
glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_bound_texture));
|
glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_bound_texture));
|
||||||
|
|
||||||
@ -1885,17 +1885,17 @@ void ViewerImpl::render_segments(const Mat4x4& view_matrix, const Mat4x4& projec
|
|||||||
glsafe(glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, m_enabled_segments_buf_id));
|
glsafe(glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, m_enabled_segments_buf_id));
|
||||||
|
|
||||||
m_segment_template.render(m_enabled_segments_count);
|
m_segment_template.render(m_enabled_segments_count);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
if (curr_cull_face)
|
if (curr_cull_face)
|
||||||
glsafe(glEnable(GL_CULL_FACE));
|
glsafe(glEnable(GL_CULL_FACE));
|
||||||
|
|
||||||
glsafe(glUseProgram(curr_shader));
|
glsafe(glUseProgram(curr_shader));
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
glsafe(glBindTexture(GL_TEXTURE_2D, curr_bound_texture));
|
glsafe(glBindTexture(GL_TEXTURE_2D, curr_bound_texture));
|
||||||
#else
|
#else
|
||||||
glsafe(glBindTexture(GL_TEXTURE_BUFFER, curr_bound_texture));
|
glsafe(glBindTexture(GL_TEXTURE_BUFFER, curr_bound_texture));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
glsafe(glActiveTexture(curr_active_texture));
|
glsafe(glActiveTexture(curr_active_texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1904,11 +1904,11 @@ void ViewerImpl::render_options(const Mat4x4& view_matrix, const Mat4x4& project
|
|||||||
if (m_options_shader_id == 0)
|
if (m_options_shader_id == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
if (m_texture_data.get_enabled_options_count() == 0)
|
if (m_texture_data.get_enabled_options_count() == 0)
|
||||||
#else
|
#else
|
||||||
if (m_enabled_options_count == 0)
|
if (m_enabled_options_count == 0)
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int curr_active_texture = 0;
|
int curr_active_texture = 0;
|
||||||
@ -1929,7 +1929,7 @@ void ViewerImpl::render_options(const Mat4x4& view_matrix, const Mat4x4& project
|
|||||||
|
|
||||||
glsafe(glEnable(GL_CULL_FACE));
|
glsafe(glEnable(GL_CULL_FACE));
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
int curr_bound_texture = 0;
|
int curr_bound_texture = 0;
|
||||||
glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_bound_texture));
|
glsafe(glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_bound_texture));
|
||||||
|
|
||||||
@ -1965,17 +1965,17 @@ void ViewerImpl::render_options(const Mat4x4& view_matrix, const Mat4x4& project
|
|||||||
glsafe(glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, m_enabled_options_buf_id));
|
glsafe(glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, m_enabled_options_buf_id));
|
||||||
|
|
||||||
m_option_template.render(m_enabled_options_count);
|
m_option_template.render(m_enabled_options_count);
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
if (!curr_cull_face)
|
if (!curr_cull_face)
|
||||||
glsafe(glDisable(GL_CULL_FACE));
|
glsafe(glDisable(GL_CULL_FACE));
|
||||||
|
|
||||||
glsafe(glUseProgram(curr_shader));
|
glsafe(glUseProgram(curr_shader));
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
glsafe(glBindTexture(GL_TEXTURE_2D, curr_bound_texture));
|
glsafe(glBindTexture(GL_TEXTURE_2D, curr_bound_texture));
|
||||||
#else
|
#else
|
||||||
glsafe(glBindTexture(GL_TEXTURE_BUFFER, curr_bound_texture));
|
glsafe(glBindTexture(GL_TEXTURE_BUFFER, curr_bound_texture));
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
glsafe(glActiveTexture(curr_active_texture));
|
glsafe(glActiveTexture(curr_active_texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ private:
|
|||||||
int m_uni_tool_marker_color_base{ -1 };
|
int m_uni_tool_marker_color_base{ -1 };
|
||||||
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
|
||||||
|
|
||||||
#if VGCODE_ENABLE_OPENGL_ES
|
#ifdef ENABLE_OPENGL_ES
|
||||||
class TextureData
|
class TextureData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -442,7 +442,7 @@ private:
|
|||||||
size_t m_colors_tex_size{ 0 };
|
size_t m_colors_tex_size{ 0 };
|
||||||
size_t m_enabled_segments_tex_size{ 0 };
|
size_t m_enabled_segments_tex_size{ 0 };
|
||||||
size_t m_enabled_options_tex_size{ 0 };
|
size_t m_enabled_options_tex_size{ 0 };
|
||||||
#endif // VGCODE_ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|
||||||
void update_view_full_range();
|
void update_view_full_range();
|
||||||
void update_color_ranges();
|
void update_color_ranges();
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
#include <libvgcode/include/GCodeInputData.hpp>
|
#include <libvgcode/include/GCodeInputData.hpp>
|
||||||
#include <libvgcode/include/ColorRange.hpp>
|
#include <libvgcode/include/ColorRange.hpp>
|
||||||
|
|
||||||
static_assert(VGCODE_ENABLE_OPENGL_ES == ENABLE_OPENGL_ES,
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
#if ENABLE_OPENGL_ES
|
//static_assert(VGCODE_ENABLE_OPENGL_ES == ENABLE_OPENGL_ES,
|
||||||
"VGCODE_ENABLE_OPENGL_ES must be set to 1");
|
//#if ENABLE_OPENGL_ES
|
||||||
#else
|
// "VGCODE_ENABLE_OPENGL_ES must be set to 1");
|
||||||
"VGCODE_ENABLE_OPENGL_ES must be set to 0");
|
//#else
|
||||||
#endif // ENABLE_OPENGL_ES
|
// "VGCODE_ENABLE_OPENGL_ES must be set to 0");
|
||||||
|
//#endif // ENABLE_OPENGL_ES
|
||||||
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
class Print;
|
class Print;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user