mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	ENABLE_COMPRESSED_TEXTURES set as default
This commit is contained in:
		
							parent
							
								
									301eda7369
								
							
						
					
					
						commit
						00b9a3ad32
					
				
					 13 changed files with 2 additions and 291 deletions
				
			
		|  | @ -46,7 +46,4 @@ | |||
| #define ENABLE_SVG_ICONS (1 && ENABLE_1_42_0_ALPHA8 && ENABLE_TEXTURES_FROM_SVG) | ||||
| 
 | ||||
| 
 | ||||
| // Enable saving textures on GPU in compressed format 
 | ||||
| #define ENABLE_COMPRESSED_TEXTURES 1 | ||||
| 
 | ||||
| #endif // _technologies_h_
 | ||||
|  |  | |||
|  | @ -9,9 +9,7 @@ | |||
| #include "GUI_App.hpp" | ||||
| #include "PresetBundle.hpp" | ||||
| #include "Gizmos/GLGizmoBase.hpp" | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| #include "GLCanvas3D.hpp" | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
| #include <GL/glew.h> | ||||
| 
 | ||||
|  | @ -276,9 +274,7 @@ void Bed3D::Axes::render_axis(double length) const | |||
| 
 | ||||
| Bed3D::Bed3D() | ||||
|     : m_type(Custom) | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     , m_requires_canvas_update(false) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| #if ENABLE_TEXTURES_FROM_SVG | ||||
|     , m_vbo_id(0) | ||||
| #endif // ENABLE_TEXTURES_FROM_SVG
 | ||||
|  | @ -334,18 +330,13 @@ Point Bed3D::point_projection(const Point& point) const | |||
| } | ||||
| 
 | ||||
| #if ENABLE_TEXTURES_FROM_SVG | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| void Bed3D::render(GLCanvas3D* canvas, float theta, bool useVBOs, float scale_factor) const | ||||
| #else | ||||
| void Bed3D::render(float theta, bool useVBOs, float scale_factor) const | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     m_scale_factor = scale_factor; | ||||
| 
 | ||||
|     EType type = useVBOs ? m_type : Custom; | ||||
|     switch (type) | ||||
|     { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     case MK2: | ||||
|     { | ||||
|         render_prusa(canvas, "mk2", theta > 90.0f); | ||||
|  | @ -361,23 +352,6 @@ void Bed3D::render(float theta, bool useVBOs, float scale_factor) const | |||
|         render_prusa(canvas, "sl1", theta > 90.0f); | ||||
|         break; | ||||
|     } | ||||
| #else | ||||
|     case MK2: | ||||
|     { | ||||
|         render_prusa("mk2", theta > 90.0f); | ||||
|         break; | ||||
|     } | ||||
|     case MK3: | ||||
|     { | ||||
|         render_prusa("mk3", theta > 90.0f); | ||||
|         break; | ||||
|     } | ||||
|     case SL1: | ||||
|     { | ||||
|         render_prusa("sl1", theta > 90.0f); | ||||
|         break; | ||||
|     } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     default: | ||||
|     case Custom: | ||||
|     { | ||||
|  | @ -387,11 +361,7 @@ void Bed3D::render(float theta, bool useVBOs, float scale_factor) const | |||
|     } | ||||
| } | ||||
| #else | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| void Bed3D::render(GLCanvas3D* canvas, float theta, bool useVBOs, float scale_factor) const | ||||
| #else | ||||
| void Bed3D::render(float theta, bool useVBOs, float scale_factor) const | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     m_scale_factor = scale_factor; | ||||
| 
 | ||||
|  | @ -400,7 +370,6 @@ void Bed3D::render(float theta, bool useVBOs, float scale_factor) const | |||
| 
 | ||||
|     switch (m_type) | ||||
|     { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     case MK2: | ||||
|     { | ||||
|         render_prusa(canvas, "mk2", theta, useVBOs); | ||||
|  | @ -416,23 +385,6 @@ void Bed3D::render(float theta, bool useVBOs, float scale_factor) const | |||
|         render_prusa(canvas, "sl1", theta, useVBOs); | ||||
|         break; | ||||
|     } | ||||
| #else | ||||
|     case MK2: | ||||
|     { | ||||
|         render_prusa("mk2", theta, useVBOs); | ||||
|         break; | ||||
|     } | ||||
|     case MK3: | ||||
|     { | ||||
|         render_prusa("mk3", theta, useVBOs); | ||||
|         break; | ||||
|     } | ||||
|     case SL1: | ||||
|     { | ||||
|         render_prusa("sl1", theta, useVBOs); | ||||
|         break; | ||||
|     }  | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     default: | ||||
|     case Custom: | ||||
|     { | ||||
|  | @ -536,21 +488,12 @@ Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const | |||
| } | ||||
| 
 | ||||
| #if ENABLE_TEXTURES_FROM_SVG | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| void Bed3D::render_prusa(GLCanvas3D* canvas, const std::string &key, bool bottom) const | ||||
| #else | ||||
| void Bed3D::render_prusa(const std::string &key, bool bottom) const | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     std::string tex_path = resources_dir() + "/icons/bed/" + key; | ||||
| 
 | ||||
|     std::string model_path = resources_dir() + "/models/" + key; | ||||
| 
 | ||||
| #if !ENABLE_COMPRESSED_TEXTURES | ||||
|     // use anisotropic filter if graphic card allows
 | ||||
|     GLfloat max_anisotropy = GLCanvas3DManager::get_gl_info().get_max_anisotropy(); | ||||
| #endif // !ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     // use higher resolution images if graphic card and opengl version allow
 | ||||
|     GLint max_tex_size = GLCanvas3DManager::get_gl_info().get_max_tex_size(); | ||||
| 
 | ||||
|  | @ -558,7 +501,6 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const | |||
| 
 | ||||
|     if ((m_texture.get_id() == 0) || (m_texture.get_source() != filename)) | ||||
|     { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         // generate a temporary lower resolution texture to show while no main texture levels have been compressed
 | ||||
|         if (!m_temp_texture.load_from_svg_file(filename, false, false, false, max_tex_size / 8)) | ||||
|         { | ||||
|  | @ -568,24 +510,11 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const | |||
| 
 | ||||
|         // starts generating the main texture, compression will run asynchronously
 | ||||
|         if (!m_texture.load_from_svg_file(filename, true, true, true, max_tex_size)) | ||||
| #else | ||||
|         if (!m_texture.load_from_svg_file(filename, true, max_tex_size)) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         { | ||||
|             render_custom(); | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
| #if !ENABLE_COMPRESSED_TEXTURES | ||||
|         if (max_anisotropy > 0.0f) | ||||
|         { | ||||
|             glsafe(::glBindTexture(GL_TEXTURE_2D, m_texture.get_id())); | ||||
|             glsafe(::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy)); | ||||
|             glsafe(::glBindTexture(GL_TEXTURE_2D, 0)); | ||||
|         } | ||||
| #endif // !ENABLE_COMPRESSED_TEXTURES
 | ||||
|     } | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     else if (m_texture.unsent_compressed_data_available()) | ||||
|     { | ||||
|         // sends to gpu the already available compressed levels of the main texture
 | ||||
|  | @ -604,7 +533,6 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const | |||
| 
 | ||||
|         m_requires_canvas_update = false; | ||||
|     } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     if (!bottom) | ||||
|     { | ||||
|  | @ -677,16 +605,12 @@ void Bed3D::render_prusa_shader(bool transparent) const | |||
|         GLint position_id = m_shader.get_attrib_location("v_position"); | ||||
|         GLint tex_coords_id = m_shader.get_attrib_location("v_tex_coords"); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         // show the temporary texture while no compressed data is available
 | ||||
|         GLuint tex_id = (GLuint)m_temp_texture.get_id(); | ||||
|         if (tex_id == 0) | ||||
|             tex_id = (GLuint)m_texture.get_id(); | ||||
| 
 | ||||
|         glsafe(::glBindTexture(GL_TEXTURE_2D, tex_id)); | ||||
| #else | ||||
|         glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)m_texture.get_id())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_vbo_id)); | ||||
| 
 | ||||
|         if (position_id != -1) | ||||
|  |  | |||
|  | @ -13,9 +13,7 @@ typedef class GLUquadric GLUquadricObj; | |||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| class GLCanvas3D; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
| class GeometryBuffer | ||||
| { | ||||
|  | @ -95,12 +93,10 @@ private: | |||
|     GeometryBuffer m_gridlines; | ||||
| #if ENABLE_TEXTURES_FROM_SVG | ||||
|     mutable GLTexture m_texture; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     // temporary texture shown until the main texture has still no levels compressed
 | ||||
|     mutable GLTexture m_temp_texture; | ||||
|     // used to trigger 3D scene update once all compressed textures have been sent to GPU
 | ||||
|     mutable bool m_requires_canvas_update; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     mutable Shader m_shader; | ||||
|     mutable unsigned int m_vbo_id; | ||||
| #else | ||||
|  | @ -131,11 +127,7 @@ public: | |||
|     bool contains(const Point& point) const; | ||||
|     Point point_projection(const Point& point) const; | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     void render(GLCanvas3D* canvas, float theta, bool useVBOs, float scale_factor) const; | ||||
| #else | ||||
|     void render(float theta, bool useVBOs, float scale_factor) const; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     void render_axes() const; | ||||
| 
 | ||||
| private: | ||||
|  | @ -144,11 +136,7 @@ private: | |||
|     void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); | ||||
|     EType detect_type(const Pointfs& shape) const; | ||||
| #if ENABLE_TEXTURES_FROM_SVG | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     void render_prusa(GLCanvas3D* canvas, const std::string& key, bool bottom) const; | ||||
| #else | ||||
|     void render_prusa(const std::string& key, bool bottom) const; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     void render_prusa_shader(bool transparent) const; | ||||
| #else | ||||
|     void render_prusa(const std::string &key, float theta, bool useVBOs) const; | ||||
|  |  | |||
|  | @ -401,11 +401,7 @@ void GLCanvas3D::LayersEditing::_render_tooltip_texture(const GLCanvas3D& canvas | |||
|     if (m_tooltip_texture.get_id() == 0) | ||||
|     { | ||||
|         std::string filename = resources_dir() + "/icons/variable_layer_height_tooltip.png"; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         if (!m_tooltip_texture.load_from_file(filename, false, true)) | ||||
| #else | ||||
|         if (!m_tooltip_texture.load_from_file(filename, false)) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|             return; | ||||
|     } | ||||
| 
 | ||||
|  | @ -437,11 +433,7 @@ void GLCanvas3D::LayersEditing::_render_reset_texture(const Rect& reset_rect) co | |||
|     if (m_reset_texture.get_id() == 0) | ||||
|     { | ||||
|         std::string filename = resources_dir() + "/icons/variable_layer_height_reset.png"; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         if (!m_reset_texture.load_from_file(filename, false, true)) | ||||
| #else | ||||
|         if (!m_reset_texture.load_from_file(filename, false)) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|             return; | ||||
|     } | ||||
| 
 | ||||
|  | @ -736,11 +728,7 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     generate(text, canvas, true, red_colored); // GUI::GLTexture::reset() is called at the beginning of generate(...)
 | ||||
| #else | ||||
|     _generate(text, canvas, red_colored); // GUI::GLTexture::reset() is called at the beginning of generate(...)
 | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     // save information for rescaling
 | ||||
|     m_msg_text = text; | ||||
|  | @ -801,11 +789,7 @@ static void msw_disable_cleartype(wxFont &font) | |||
| } | ||||
| #endif /* __WXMSW__ */ | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLCanvas3D::WarningTexture::generate(const std::string& msg_utf8, const GLCanvas3D& canvas, bool compress, bool red_colored/* = false*/) | ||||
| #else | ||||
| bool GLCanvas3D::WarningTexture::_generate(const std::string& msg_utf8, const GLCanvas3D& canvas, const bool red_colored/* = false*/) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     reset(); | ||||
| 
 | ||||
|  | @ -879,14 +863,10 @@ bool GLCanvas3D::WarningTexture::_generate(const std::string& msg_utf8, const GL | |||
|     glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); | ||||
|     glsafe(::glGenTextures(1, &m_id)); | ||||
|     glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)m_id)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compress && GLEW_EXT_texture_compression_s3tc) | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
|     else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|     glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); | ||||
|  | @ -937,11 +917,7 @@ void GLCanvas3D::WarningTexture::msw_rescale(const GLCanvas3D& canvas) | |||
|     if (m_msg_text.empty()) | ||||
|         return; | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     generate(m_msg_text, canvas, true, m_is_colored_red); | ||||
| #else | ||||
|     _generate(m_msg_text, canvas, m_is_colored_red); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| } | ||||
| 
 | ||||
| const unsigned char GLCanvas3D::LegendTexture::Squares_Border_Color[3] = { 64, 64, 64 }; | ||||
|  | @ -984,11 +960,7 @@ void GLCanvas3D::LegendTexture::fill_color_print_legend_values(const GCodePrevie | |||
|     } | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors, const GLCanvas3D& canvas, bool compress) | ||||
| #else | ||||
| bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors, const GLCanvas3D& canvas) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     reset(); | ||||
| 
 | ||||
|  | @ -1177,14 +1149,10 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c | |||
|     glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); | ||||
|     glsafe(::glGenTextures(1, &m_id)); | ||||
|     glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)m_id)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compress && GLEW_EXT_texture_compression_s3tc) | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
|     else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|     glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); | ||||
|  | @ -1267,9 +1235,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar | |||
| #endif // ENABLE_SVG_ICONS
 | ||||
|     , m_use_clipping_planes(false) | ||||
|     , m_sidebar_field("") | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     , m_keep_dirty(false) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     , m_config(nullptr) | ||||
|     , m_process(nullptr) | ||||
|     , m_model(nullptr) | ||||
|  | @ -1487,10 +1453,8 @@ void GLCanvas3D::bed_shape_changed() | |||
|     m_camera.set_scene_box(scene_bounding_box()); | ||||
|     m_camera.requires_zoom_to_bed = true; | ||||
|     m_dirty = true; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (m_bed.is_prusa()) | ||||
|         start_keeping_dirty(); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::set_color_by(const std::string& value) | ||||
|  | @ -1750,12 +1714,10 @@ void GLCanvas3D::render() | |||
|     imgui.text(std::to_string(m_render_stats.last_frame)); | ||||
|     ImGui::SameLine(); | ||||
|     imgui.text("  ms"); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     ImGui::Separator(); | ||||
|     imgui.text("Compressed textures: "); | ||||
|     ImGui::SameLine(); | ||||
|     imgui.text(GLCanvas3DManager::are_compressed_textures_supported() ? "supported" : "not supported"); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     imgui.text("Max texture size: "); | ||||
|     ImGui::SameLine(); | ||||
|     imgui.text(std::to_string(GLCanvas3DManager::get_gl_info().get_max_tex_size())); | ||||
|  | @ -2366,10 +2328,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) | |||
| 
 | ||||
|     _refresh_if_shown_on_screen(); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (m_keep_dirty) | ||||
|         m_dirty = true; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::on_char(wxKeyEvent& evt) | ||||
|  | @ -4002,11 +3962,7 @@ void GLCanvas3D::_render_bed(float theta) const | |||
| #if ENABLE_RETINA_GL | ||||
|     scale_factor = m_retina_helper->get_scale_factor(); | ||||
| #endif // ENABLE_RETINA_GL
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     m_bed.render(const_cast<GLCanvas3D*>(this), theta, m_use_VBOs, scale_factor); | ||||
| #else | ||||
|     m_bed.render(theta, m_use_VBOs, scale_factor); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_render_axes() const | ||||
|  | @ -5762,11 +5718,7 @@ std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& col | |||
| 
 | ||||
| void GLCanvas3D::_generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors) | ||||
| { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     m_legend_texture.generate(preview_data, tool_colors, *this, true); | ||||
| #else | ||||
|     m_legend_texture.generate(preview_data, tool_colors, *this); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_set_warning_texture(WarningTexture::Warning warning, bool state) | ||||
|  |  | |||
|  | @ -376,11 +376,7 @@ class GLCanvas3D | |||
|         std::vector<Warning> m_warnings; | ||||
| 
 | ||||
|         // Generates the texture with given text.
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         bool generate(const std::string& msg, const GLCanvas3D& canvas, bool compress, bool red_colored = false); | ||||
| #else | ||||
|         bool _generate(const std::string& msg, const GLCanvas3D& canvas, const bool red_colored = false); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     }; | ||||
| 
 | ||||
|     class LegendTexture : public GUI::GLTexture | ||||
|  | @ -403,11 +399,7 @@ class GLCanvas3D | |||
|         void fill_color_print_legend_values(const GCodePreviewData& preview_data, const GLCanvas3D& canvas, | ||||
|                                      std::vector<std::pair<double, double>>& cp_legend_values); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors, const GLCanvas3D& canvas, bool compress); | ||||
| #else | ||||
|         bool generate(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors, const GLCanvas3D& canvas); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|         void render(const GLCanvas3D& canvas) const; | ||||
|     }; | ||||
|  | @ -451,9 +443,7 @@ private: | |||
|     bool m_use_clipping_planes; | ||||
|     mutable SlaCap m_sla_caps[2]; | ||||
|     std::string m_sidebar_field; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     bool m_keep_dirty; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     mutable GLVolumeCollection m_volumes; | ||||
|     Selection m_selection; | ||||
|  | @ -640,10 +630,8 @@ public: | |||
|     void set_cursor(ECursorType type); | ||||
|     void msw_rescale(); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     void start_keeping_dirty() { m_keep_dirty = true; } | ||||
|     void stop_keeping_dirty() { m_keep_dirty = false; } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
| private: | ||||
|     bool _is_shown_on_screen() const; | ||||
|  |  | |||
|  | @ -186,9 +186,7 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten | |||
| } | ||||
| 
 | ||||
| GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas3DManager::MS_Unknown; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLCanvas3DManager::s_compressed_textures_supported = false; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info; | ||||
| 
 | ||||
| GLCanvas3DManager::GLCanvas3DManager() | ||||
|  | @ -273,12 +271,10 @@ void GLCanvas3DManager::init_gl() | |||
|         m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1"); | ||||
|         m_use_VBOs = !m_use_legacy_opengl && s_gl_info.is_version_greater_or_equal_to(2, 0); | ||||
|         m_gl_initialized = true; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         if (GLEW_EXT_texture_compression_s3tc) | ||||
|             s_compressed_textures_supported = true; | ||||
|         else | ||||
|             s_compressed_textures_supported = false; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -78,9 +78,7 @@ private: | |||
|     bool m_use_legacy_opengl; | ||||
|     bool m_use_VBOs; | ||||
|     static EMultisampleState s_multisample; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     static bool s_compressed_textures_supported; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
| public: | ||||
|     GLCanvas3DManager(); | ||||
|  | @ -99,9 +97,7 @@ public: | |||
|     GLCanvas3D* get_canvas(wxGLCanvas* canvas); | ||||
| 
 | ||||
|     static bool can_multisample() { return s_multisample == MS_Enabled; } | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     static bool are_compressed_textures_supported() { return s_compressed_textures_supported; } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     static wxGLCanvas* create_wxglcanvas(wxWindow *parent); | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,12 +12,10 @@ | |||
| 
 | ||||
| #include <vector> | ||||
| #include <algorithm> | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| #include <thread> | ||||
| 
 | ||||
| #define STB_DXT_IMPLEMENTATION | ||||
| #include "stb_dxt/stb_dxt.h" | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
| #include "nanosvg/nanosvg.h" | ||||
| #include "nanosvg/nanosvgrast.h" | ||||
|  | @ -27,7 +25,6 @@ | |||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| void GLTexture::Compressor::reset() | ||||
| { | ||||
|     // force compression completion, if any
 | ||||
|  | @ -120,7 +117,6 @@ void GLTexture::Compressor::compress() | |||
|     m_is_compressing = false; | ||||
|     m_abort_compressing = false; | ||||
| } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
| GLTexture::Quad_UVs GLTexture::FullTextureUVs = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } }; | ||||
| 
 | ||||
|  | @ -129,9 +125,7 @@ GLTexture::GLTexture() | |||
|     , m_width(0) | ||||
|     , m_height(0) | ||||
|     , m_source("") | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     , m_compressor(*this) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
| } | ||||
| 
 | ||||
|  | @ -140,11 +134,7 @@ GLTexture::~GLTexture() | |||
|     reset(); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLTexture::load_from_file(const std::string& filename, bool use_mipmaps, bool compress) | ||||
| #else | ||||
| bool GLTexture::load_from_file(const std::string& filename, bool use_mipmaps) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     reset(); | ||||
| 
 | ||||
|  | @ -152,20 +142,12 @@ bool GLTexture::load_from_file(const std::string& filename, bool use_mipmaps) | |||
|         return false; | ||||
| 
 | ||||
|     if (boost::algorithm::iends_with(filename, ".png")) | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         return load_from_png(filename, use_mipmaps, compress); | ||||
| #else | ||||
|         return load_from_png(filename, use_mipmaps); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     else | ||||
|         return false; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLTexture::load_from_svg_file(const std::string& filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px) | ||||
| #else | ||||
| bool GLTexture::load_from_svg_file(const std::string& filename, bool use_mipmaps, unsigned int max_size_px) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     reset(); | ||||
| 
 | ||||
|  | @ -173,20 +155,12 @@ bool GLTexture::load_from_svg_file(const std::string& filename, bool use_mipmaps | |||
|         return false; | ||||
| 
 | ||||
|     if (boost::algorithm::iends_with(filename, ".svg")) | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         return load_from_svg(filename, use_mipmaps, compress, apply_anisotropy, max_size_px); | ||||
| #else | ||||
|         return load_from_svg(filename, use_mipmaps, max_size_px); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     else | ||||
|         return false; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress) | ||||
| #else | ||||
| bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     reset(); | ||||
| 
 | ||||
|  | @ -302,14 +276,10 @@ bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::stri | |||
|     glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); | ||||
|     glsafe(::glGenTextures(1, &m_id)); | ||||
|     glsafe(::glBindTexture(GL_TEXTURE_2D, m_id)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compress && GLEW_EXT_texture_compression_s3tc) | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
|     else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|     glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | ||||
|  | @ -353,9 +323,7 @@ void GLTexture::reset() | |||
|     m_width = 0; | ||||
|     m_height = 0; | ||||
|     m_source = ""; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     m_compressor.reset(); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| } | ||||
| 
 | ||||
| void GLTexture::render_texture(unsigned int tex_id, float left, float right, float bottom, float top) | ||||
|  | @ -386,11 +354,7 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right, | |||
|     glsafe(::glDisable(GL_BLEND)); | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| unsigned int GLTexture::generate_mipmaps(wxImage& image, bool compress) | ||||
| #else | ||||
| unsigned int GLTexture::generate_mipmaps(wxImage& image) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     int w = image.GetWidth(); | ||||
|     int h = image.GetHeight(); | ||||
|  | @ -422,24 +386,16 @@ unsigned int GLTexture::generate_mipmaps(wxImage& image) | |||
|             data[data_id + 3] = (img_alpha != nullptr) ? img_alpha[i] : 255; | ||||
|         } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         if (compress && GLEW_EXT_texture_compression_s3tc) | ||||
|             glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
|         else | ||||
|             glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     } | ||||
| 
 | ||||
|     return (unsigned int)level; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLTexture::load_from_png(const std::string& filename, bool use_mipmaps, bool compress) | ||||
| #else | ||||
| bool GLTexture::load_from_png(const std::string& filename, bool use_mipmaps) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     // Load a PNG with an alpha channel.
 | ||||
|     wxImage image; | ||||
|  | @ -484,22 +440,14 @@ bool GLTexture::load_from_png(const std::string& filename, bool use_mipmaps) | |||
|     glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); | ||||
|     glsafe(::glGenTextures(1, &m_id)); | ||||
|     glsafe(::glBindTexture(GL_TEXTURE_2D, m_id)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compress && GLEW_EXT_texture_compression_s3tc) | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
|     else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|     glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     if (use_mipmaps) | ||||
|     { | ||||
|         // we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         unsigned int levels_count = generate_mipmaps(image, compress); | ||||
| #else | ||||
|         unsigned int levels_count = generate_mipmaps(image); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, levels_count)); | ||||
|         glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)); | ||||
|     } | ||||
|  | @ -517,15 +465,9 @@ bool GLTexture::load_from_png(const std::string& filename, bool use_mipmaps) | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px) | ||||
| #else | ||||
| bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, unsigned int max_size_px) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     bool compression_enabled = compress && GLEW_EXT_texture_compression_s3tc; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     NSVGimage* image = nsvgParseFromFile(filename.c_str(), "px", 96.0f); | ||||
|     if (image == nullptr) | ||||
|  | @ -540,7 +482,6 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
|     m_width = (int)(scale * image->width); | ||||
|     m_height = (int)(scale * image->height); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compression_enabled) | ||||
|     { | ||||
|         // the stb_dxt compression library seems to like only texture sizes which are a multiple of 4
 | ||||
|  | @ -553,7 +494,6 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
|         if (height_rem != 0) | ||||
|             m_height += (4 - height_rem); | ||||
|     } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     int n_pixels = m_width * m_height; | ||||
| 
 | ||||
|  | @ -581,7 +521,7 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
|     glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); | ||||
|     glsafe(::glGenTextures(1, &m_id)); | ||||
|     glsafe(::glBindTexture(GL_TEXTURE_2D, m_id)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| 
 | ||||
|     if (apply_anisotropy) | ||||
|     { | ||||
|         GLfloat max_anisotropy = GLCanvas3DManager::get_gl_info().get_max_anisotropy(); | ||||
|  | @ -598,9 +538,7 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
|     } | ||||
|     else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|     glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     if (use_mipmaps) | ||||
|     { | ||||
|         // we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
 | ||||
|  | @ -616,12 +554,9 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
|             lod_h = std::max(lod_h / 2, 1); | ||||
|             scale /= 2.0f; | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|             data.resize(lod_w * lod_h * 4); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|             nsvgRasterize(rast, image, 0, 0, scale, data.data(), lod_w, lod_h, lod_w * 4); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|             if (compression_enabled) | ||||
|             { | ||||
|                 // initializes the texture on GPU 
 | ||||
|  | @ -631,20 +566,13 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
|             } | ||||
|             else | ||||
|                 glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)lod_w, (GLsizei)lod_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #else | ||||
|             glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)lod_w, (GLsizei)lod_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data())); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         if (!compression_enabled) | ||||
|         { | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|             glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level)); | ||||
|             glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|  | @ -657,11 +585,9 @@ bool GLTexture::load_from_svg(const std::string& filename, bool use_mipmaps, uns | |||
| 
 | ||||
|     m_source = filename; | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compression_enabled) | ||||
|         // start asynchronous compression
 | ||||
|         m_compressor.start_compressing(); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     nsvgDeleteRasterizer(rast); | ||||
|     nsvgDelete(image); | ||||
|  |  | |||
|  | @ -11,7 +11,6 @@ namespace GUI { | |||
| 
 | ||||
|     class GLTexture | ||||
|     { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         class Compressor | ||||
|         { | ||||
|             struct Level | ||||
|  | @ -47,7 +46,6 @@ namespace GUI { | |||
|         private: | ||||
|             void compress(); | ||||
|         }; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     public: | ||||
|         struct UV | ||||
|  | @ -71,21 +69,14 @@ namespace GUI { | |||
|         int m_width; | ||||
|         int m_height; | ||||
|         std::string m_source; | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         Compressor m_compressor; | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     public: | ||||
|         GLTexture(); | ||||
|         virtual ~GLTexture(); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         bool load_from_file(const std::string& filename, bool use_mipmaps, bool compress); | ||||
|         bool load_from_svg_file(const std::string& filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px); | ||||
| #else | ||||
|         bool load_from_file(const std::string& filename, bool use_mipmaps); | ||||
|         bool load_from_svg_file(const std::string& filename, bool use_mipmaps, unsigned int max_size_px); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         // meanings of states: (std::pair<int, bool>)
 | ||||
|         // first field (int):
 | ||||
|         // 0 -> no changes
 | ||||
|  | @ -94,11 +85,7 @@ namespace GUI { | |||
|         // second field (bool):
 | ||||
|         // false -> no changes
 | ||||
|         // true -> add background color
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         bool load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress); | ||||
| #else | ||||
|         bool load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         void reset(); | ||||
| 
 | ||||
|         unsigned int get_id() const { return m_id; } | ||||
|  | @ -107,32 +94,21 @@ namespace GUI { | |||
| 
 | ||||
|         const std::string& get_source() const { return m_source; } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         bool unsent_compressed_data_available() const { return m_compressor.unsent_compressed_data_available(); } | ||||
|         void send_compressed_data_to_gpu() { m_compressor.send_compressed_data_to_gpu(); } | ||||
|         bool all_compressed_data_sent_to_gpu() const { return m_compressor.all_compressed_data_sent_to_gpu(); } | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|         static void render_texture(unsigned int tex_id, float left, float right, float bottom, float top); | ||||
|         static void render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const Quad_UVs& uvs); | ||||
| 
 | ||||
|     protected: | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         unsigned int generate_mipmaps(wxImage& image, bool compress); | ||||
| #else | ||||
|         unsigned int generate_mipmaps(wxImage& image); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     private: | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         bool load_from_png(const std::string& filename, bool use_mipmaps, bool compress); | ||||
|         bool load_from_svg(const std::string& filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px); | ||||
| 
 | ||||
|         friend class Compressor; | ||||
| #else | ||||
|         bool load_from_png(const std::string& filename, bool use_mipmaps); | ||||
|         bool load_from_svg(const std::string& filename, bool use_mipmaps, unsigned int max_size_px); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     }; | ||||
| 
 | ||||
| } // namespace GUI
 | ||||
|  |  | |||
|  | @ -194,11 +194,7 @@ bool GLToolbar::init(const ItemsIconsTexture::Metadata& icons_texture, const Bac | |||
| #endif // ENABLE_SVG_ICONS
 | ||||
| 
 | ||||
|     if (!background_texture.filename.empty()) | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         res = m_background_texture.texture.load_from_file(path + background_texture.filename, false, true); | ||||
| #else | ||||
|         res = m_background_texture.texture.load_from_file(path + background_texture.filename, false); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     if (res) | ||||
|         m_background_texture.metadata = background_texture; | ||||
|  | @ -1342,11 +1338,7 @@ bool GLToolbar::generate_icons_texture() const | |||
|         states.push_back(std::make_pair(1, true)); | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, (unsigned int)(m_layout.icons_size * m_layout.scale), true); | ||||
| #else | ||||
|     bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, (unsigned int)(m_layout.icons_size * m_layout.scale)); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     if (res) | ||||
|         m_icons_texture_dirty = false; | ||||
| 
 | ||||
|  |  | |||
|  | @ -65,11 +65,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent) | |||
| 
 | ||||
|     if (!m_background_texture.metadata.filename.empty()) | ||||
|     { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         if (!m_background_texture.texture.load_from_file(resources_dir() + "/icons/" + m_background_texture.metadata.filename, false, true)) | ||||
| #else | ||||
|         if (!m_background_texture.texture.load_from_file(resources_dir() + "/icons/" + m_background_texture.metadata.filename, false)) | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|         { | ||||
|             reset(); | ||||
|             return false; | ||||
|  | @ -1164,11 +1160,7 @@ bool GLGizmosManager::generate_icons_texture() const | |||
|     states.push_back(std::make_pair(0, false)); | ||||
|     states.push_back(std::make_pair(0, true)); | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, (unsigned int)(m_overlay_icons_size * m_overlay_scale), true); | ||||
| #else | ||||
|     bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, (unsigned int)(m_overlay_icons_size * m_overlay_scale)); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     if (res) | ||||
|         m_icons_texture_dirty = false; | ||||
| 
 | ||||
|  |  | |||
|  | @ -206,11 +206,7 @@ void ImGuiWrapper::new_frame() | |||
|     } | ||||
| 
 | ||||
|     if (m_font_texture == 0) { | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|         init_font(true); | ||||
| #else | ||||
|         init_font(); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     } | ||||
| 
 | ||||
|     ImGui::NewFrame(); | ||||
|  | @ -387,11 +383,7 @@ bool ImGuiWrapper::want_any_input() const | |||
|     return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
| void ImGuiWrapper::init_font(bool compress) | ||||
| #else | ||||
| void ImGuiWrapper::init_font() | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| { | ||||
|     destroy_font(); | ||||
| 
 | ||||
|  | @ -420,14 +412,10 @@ void ImGuiWrapper::init_font() | |||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | ||||
|     glsafe(::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)); | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     if (compress && GLEW_EXT_texture_compression_s3tc) | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); | ||||
|     else | ||||
|         glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); | ||||
| #else | ||||
|     glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
| 
 | ||||
|     // Store our identifier
 | ||||
|     io.Fonts->TexID = (ImTextureID)(intptr_t)m_font_texture; | ||||
|  |  | |||
|  | @ -77,11 +77,7 @@ public: | |||
|     bool want_any_input() const; | ||||
| 
 | ||||
| private: | ||||
| #if ENABLE_COMPRESSED_TEXTURES | ||||
|     void init_font(bool compress); | ||||
| #else | ||||
|     void init_font(); | ||||
| #endif // ENABLE_COMPRESSED_TEXTURES
 | ||||
|     void init_input(); | ||||
|     void init_style(); | ||||
|     void render_draw_data(ImDrawData *draw_data); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri