OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GLTexture Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLTexture.hpp>

Collaboration diagram for Slic3r::GUI::GLTexture:

Classes

class  Compressor
struct  UV
struct  Quad_UVs

Public Types

enum  ECompressionType : unsigned char { None , SingleThreaded , MultiThreaded }

Public Member Functions

 GLTexture ()
virtual ~GLTexture ()
bool load_from_file (const std::string &filename, bool use_mipmaps, ECompressionType compression_type, bool apply_anisotropy)
bool load_from_svg_file (const std::string &filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px)
bool load_from_raw_data (std::vector< unsigned char > data, unsigned int w, unsigned int h, bool apply_anisotropy=false, bool use_mipmaps=true)
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)
void reset ()
bool generate_texture_from_text (const std::string &text_str, wxFont &font, int &ww, int &hh, int &hl, wxColor background= *wxBLACK, wxColor foreground= *wxWHITE)
bool generate_from_text (const std::string &text_str, wxFont &font, wxColor background= *wxBLACK, wxColor foreground= *wxWHITE)
bool generate_from_text_string (const std::string &text_str, wxFont &font, wxColor background= *wxBLACK, wxColor foreground= *wxWHITE)
unsigned int get_id () const
int get_original_width () const
int get_width () const
int get_height () const
const std::string & get_source () const
bool unsent_compressed_data_available () const
void send_compressed_data_to_gpu ()
bool all_compressed_data_sent_to_gpu () const

Static Public Member Functions

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)
static void copy_from_framebuffer (unsigned int &tex_id, std::array< unsigned int, 2 > &tex_size, unsigned int width, unsigned int height, int filter)

Public Attributes

int m_original_width
int m_original_height

Static Public Attributes

static Quad_UVs FullTextureUVs = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } }

Protected Attributes

unsigned int m_id { 0 }
int m_width { 0 }
int m_height { 0 }
std::string m_source
Compressor m_compressor

Private Member Functions

bool load_from_png (const std::string &filename, bool use_mipmaps, ECompressionType compression_type, bool apply_anisotropy)
bool load_from_svg (const std::string &filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px)

Friends

class Compressor

Detailed Description


Class Documentation

◆ Slic3r::GUI::GLTexture::UV

struct Slic3r::GUI::GLTexture::UV
Class Members
float u { 0.0f }
float v { 0.0f }

◆ Slic3r::GUI::GLTexture::Quad_UVs

struct Slic3r::GUI::GLTexture::Quad_UVs
Collaboration diagram for Slic3r::GUI::GLTexture::Quad_UVs:
Class Members
UV left_bottom
UV left_top
UV right_bottom
UV right_top

Member Enumeration Documentation

◆ ECompressionType

Enumerator
None 
SingleThreaded 
MultiThreaded 
71 {
72 None,
75 };
@ None
Definition GLTexture.hpp:72
@ MultiThreaded
Definition GLTexture.hpp:74
@ SingleThreaded
Definition GLTexture.hpp:73

Constructor & Destructor Documentation

◆ GLTexture()

Slic3r::GUI::GLTexture::GLTexture ( )
156 : m_compressor(*this)
157{
158}
Compressor m_compressor
Definition GLTexture.hpp:98

References m_compressor.

Referenced by Slic3r::GUI::GLTexture::Compressor::Compressor().

Here is the caller graph for this function:

◆ ~GLTexture()

Slic3r::GUI::GLTexture::~GLTexture ( )
virtual
161{
162 reset();
163}
void reset()
Definition GLTexture.cpp:516

References reset().

Here is the call graph for this function:

Member Function Documentation

◆ all_compressed_data_sent_to_gpu()

bool Slic3r::GUI::GLTexture::all_compressed_data_sent_to_gpu ( ) const
inline
138{ return m_compressor.all_compressed_data_sent_to_gpu(); }

References m_compressor.

◆ copy_from_framebuffer()

void Slic3r::GUI::GLTexture::copy_from_framebuffer ( unsigned int & tex_id,
std::array< unsigned int, 2 > & tex_size,
unsigned int width,
unsigned int height,
int filter )
static
757{
758 if (tex_id == 0) {
759 glsafe(::glGenTextures(1, &tex_id));
765 }
766 else
768
769 if (tex_size[0] != width || tex_size[1] != height) {
770 glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr));
771 tex_size = { width, height };
772 }
773
774 // Copying from the default framebuffer resolves its multisampling.
775 glsafe(::glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height));
777}
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
#define GL_TEXTURE_MIN_FILTER
Definition gl.h:1828
#define GL_TEXTURE_WRAP_S
Definition gl.h:1854
#define glTexParameteri
Definition gl.h:4911
#define glCopyTexSubImage2D
Definition gl.h:3521
#define glTexImage2D
Definition gl.h:4895
#define GL_UNSIGNED_BYTE
Definition gl.h:1937
#define glGenTextures
Definition gl.h:3787
#define glBindTexture
Definition gl.h:3299
#define GL_RGBA
Definition gl.h:1493
#define GL_TEXTURE_WRAP_T
Definition gl.h:1855
#define GL_TEXTURE_MAG_FILTER
Definition gl.h:1822
#define GL_TEXTURE_2D
Definition gl.h:1739
#define GL_CLAMP_TO_EDGE
Definition gl.h:322
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References GL_CLAMP_TO_EDGE, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_UNSIGNED_BYTE, glBindTexture, glCopyTexSubImage2D, glGenTextures, glsafe, glTexImage2D, and glTexParameteri.

Referenced by Slic3r::GUI::GLCanvas3D::_render_fxaa_pass(), and Slic3r::GUI::SceneCache::capture().

Here is the caller graph for this function:

◆ generate_from_text()

bool Slic3r::GUI::GLTexture::generate_from_text ( const std::string & text_str,
wxFont & font,
wxColor background = *wxBLACK,
wxColor foreground = *wxWHITE )
537{
538 if (text_str.empty())
539 {
540 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":no text string, should not happen\n";
541 return false;
542 }
543
544 wxString msg = from_u8(text_str);
545 wxMemoryDC memDC;
546
547 memDC.SetFont(font);
548
549 // calculates texture size
550 wxCoord w, h;
551 memDC.GetMultiLineTextExtent(msg, &w, &h);
552
553 m_original_width = (int)w;
554 m_original_height = (int)h;
555 m_width = (int)next_highest_power_of_2((uint32_t)w);
556 m_height = (int)next_highest_power_of_2((uint32_t)h);
557
558 // generates bitmap
559 wxBitmap bitmap(m_width, m_height);
560
561 memDC.SelectObject(bitmap);
562 memDC.SetBackground(wxBrush(background));
563 memDC.Clear();
564
565 // draw message
566 memDC.SetTextForeground(*wxWHITE);
567 memDC.DrawLabel(msg, wxRect(0, 0, m_original_width, m_original_height), wxALIGN_CENTER);
568
569 memDC.SelectObject(wxNullBitmap);
570
571 // Convert the bitmap into a linear data ready to be loaded into the GPU.
572 wxImage image = bitmap.ConvertToImage();
573
574 // prepare buffer
575 std::vector<unsigned char> data(4 * m_width * m_height, 0);
576 const unsigned char* src = image.GetData();
577 /* for debug use
578 std::ofstream fout;
579 fout.open(text_str+std::to_string(m_width)+"_"+std::to_string(m_height)+".rgb", std::ios::out);
580 fout.write((const char*)src, 3 * m_width * m_height);
581 fout.close();*/
582 for (int h = 0; h < m_height; ++h) {
583 unsigned char* dst = data.data() + 4 * h * m_width;
584 for (int w = 0; w < m_width; ++w) {
585 *dst++ = foreground.Red();
586 *dst++ = foreground.Green();
587 *dst++ = foreground.Blue();
588 *dst++ = (unsigned char)std::min<int>(255, *src);
589 src += 3;
590 }
591 }
592
593 // sends buffer to gpu
599 else
605
606 return true;
607}
int m_height
Definition GLTexture.hpp:96
int m_original_height
Definition GLTexture.hpp:123
unsigned int m_id
Definition GLTexture.hpp:94
int m_width
Definition GLTexture.hpp:95
int m_original_width
Definition GLTexture.hpp:122
static bool are_compressed_textures_supported()
Definition OpenGLManager.hpp:99
#define glPixelStorei
Definition gl.h:4451
#define GL_TEXTURE_MAX_LEVEL
Definition gl.h:1826
#define GL_LINEAR
Definition gl.h:930
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
Definition gl.h:449
#define GL_UNPACK_ALIGNMENT
Definition gl.h:1924
int GLsizei
Definition gl.h:2065
unsigned int GLuint
Definition gl.h:2063
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
uint16_t next_highest_power_of_2(uint16_t v)
Definition Utils.hpp:376

References Slic3r::GUI::OpenGLManager::are_compressed_textures_supported(), Slic3r::GUI::from_u8(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glsafe, glTexImage2D, glTexParameteri, m_height, m_id, m_original_height, m_original_width, m_width, and Slic3r::next_highest_power_of_2().

Referenced by generate_from_text_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_from_text_string()

bool Slic3r::GUI::GLTexture::generate_from_text_string ( const std::string & text_str,
wxFont & font,
wxColor background = *wxBLACK,
wxColor foreground = *wxWHITE )
532{
533 return generate_from_text(text_str, font, background, foreground);
534}
bool generate_from_text(const std::string &text_str, wxFont &font, wxColor background= *wxBLACK, wxColor foreground= *wxWHITE)
Definition GLTexture.cpp:536

References generate_from_text().

Here is the call graph for this function:

◆ generate_texture_from_text()

bool Slic3r::GUI::GLTexture::generate_texture_from_text ( const std::string & text_str,
wxFont & font,
int & ww,
int & hh,
int & hl,
wxColor background = *wxBLACK,
wxColor foreground = *wxWHITE )
610{
611 if (text_str.empty())
612 {
613 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ":no text string, should not happen\n";
614 return false;
615 }
616
617 wxString msg = _(text_str);
618 wxMemoryDC memDC;
619
620 memDC.SetFont(font);
621
622 // calculates texture size
623 wxCoord w, h, ll;
624 wxClientDC dc(wxGetApp().GetTopWindow());
625 dc.SetFont(font);
626 dc.GetMultiLineTextExtent(msg, &w, &h, &ll, &font);
627
628
629 m_original_width = (int)w;
630 m_original_height = (int)h;
631 m_width = (int)next_highest_power_of_2((uint32_t)w);
632 m_height = (int)next_highest_power_of_2((uint32_t)h);
633 ww = m_width;
634 hh = m_height;
635 hl = ll;
636 // generates bitmap
637 wxBitmap bitmap(m_width, m_height);
638
639 memDC.SelectObject(bitmap);
640 memDC.SetBackground(wxBrush(background));
641 memDC.Clear();
642
643 // draw message
644 memDC.SetTextForeground(*wxWHITE);
645 memDC.DrawLabel(msg, wxRect(0, 0, m_width, m_height), wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
646
647 memDC.SelectObject(wxNullBitmap);
648
649 // Convert the bitmap into a linear data ready to be loaded into the GPU.
650 wxImage image = bitmap.ConvertToImage();
651
652 // prepare buffer
653 std::vector<unsigned char> data(4 * m_width * m_height, 0);
654 const unsigned char* src = image.GetData();
655 /* for debug use
656 std::ofstream fout;
657 fout.open(text_str+std::to_string(m_width)+"_"+std::to_string(m_height)+".rgb", std::ios::out);
658 fout.write((const char*)src, 3 * m_width * m_height);
659 fout.close();*/
660 bool found = false;
661 for (int h = 0; h < m_height; ++h) {
662 unsigned char* dst = data.data() + 4 * h * m_width;
663 for (int w = 0; w < m_width; ++w) {
664 *dst++ = foreground.Red();
665 *dst++ = foreground.Green();
666 *dst++ = foreground.Blue();
667 *dst++ = (unsigned char)std::min<int>(255, *src);
668 if ((*src) != background.Red() && !found) {
669 found = true;
670 if (m_height - h < font.GetPointSize())
671 return false;
672 }
673 src += 3;
674 }
675 }
676 if (!found)
677 return false;
678
679 found = false;
680 src -= 3;
681 for (int h = m_height; h > 0; --h) {
682 for (int w = m_width; w > 0; --w) {
683 if ((*src) != background.Red() && !found) {
684 found = true;
685 if (h < font.GetPointSize())
686 return false;
687 }
688 src -= 3;
689 }
690 }
691 if (!found)
692 return false;
693
694 // sends buffer to gpu
700 else
706
707 return true;
708}
#define _(s)
Definition 3mf.cpp:306

References _, Slic3r::GUI::OpenGLManager::are_compressed_textures_supported(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glsafe, glTexImage2D, glTexParameteri, m_height, m_id, m_original_height, m_original_width, m_width, and Slic3r::next_highest_power_of_2().

Here is the call graph for this function:

◆ get_height()

int Slic3r::GUI::GLTexture::get_height ( ) const
inline
132{ return m_height; }

References m_height.

Referenced by Slic3r::GUI::PartPlate::calc_vertex_for_plate_name_edit_icon(), Slic3r::GUI::GLGizmoTextureDisplacement::render_shaded_preview_mesh(), Slic3r::GUI::GLGizmoTextureDisplacement::render_texture_library_popup(), and Slic3r::GUI::GLGizmoTextureDisplacement::shaded_preview_ready().

Here is the caller graph for this function:

◆ get_id()

unsigned int Slic3r::GUI::GLTexture::get_id ( ) const
inline
129{ return m_id; }

References m_id.

Referenced by Slic3r::GUI::GLCanvas3D::_render_imgui_select_plate_toolbar(), Slic3r::GUI::PartPlate::render_icon_texture(), Slic3r::GUI::PartPlate::render_logo_texture(), Slic3r::GUI::GLGizmoTextureDisplacement::render_shaded_preview_mesh(), and Slic3r::GUI::GLGizmoTextureDisplacement::render_texture_library_popup().

Here is the caller graph for this function:

◆ get_original_width()

int Slic3r::GUI::GLTexture::get_original_width ( ) const
inline
130{ return m_original_width; }

References m_original_width.

◆ get_source()

const std::string & Slic3r::GUI::GLTexture::get_source ( ) const
inline
134{ return m_source; }
std::string m_source
Definition GLTexture.hpp:97

References m_source.

◆ get_width()

int Slic3r::GUI::GLTexture::get_width ( ) const
inline
131{ return m_width; }

References m_width.

Referenced by Slic3r::GUI::PartPlate::calc_vertex_for_plate_name_edit_icon(), Slic3r::GUI::GLGizmoTextureDisplacement::render_shaded_preview_mesh(), Slic3r::GUI::GLGizmoTextureDisplacement::render_texture_library_popup(), and Slic3r::GUI::GLGizmoTextureDisplacement::shaded_preview_ready().

Here is the caller graph for this function:

◆ load_from_file()

bool Slic3r::GUI::GLTexture::load_from_file ( const std::string & filename,
bool use_mipmaps,
ECompressionType compression_type,
bool apply_anisotropy )
166{
167 reset();
168
169 if (!boost::filesystem::exists(filename))
170 return false;
171
172 if (boost::algorithm::iends_with(filename, ".png"))
173 return load_from_png(filename, use_mipmaps, compression_type, apply_anisotropy);
174 else
175 return false;
176}
bool load_from_png(const std::string &filename, bool use_mipmaps, ECompressionType compression_type, bool apply_anisotropy)
Definition GLTexture.cpp:799

References load_from_png(), and reset().

Here is the call graph for this function:

◆ load_from_png()

bool Slic3r::GUI::GLTexture::load_from_png ( const std::string & filename,
bool use_mipmaps,
ECompressionType compression_type,
bool apply_anisotropy )
private
800{
801 const bool compression_enabled = (compression_type != None) && OpenGLManager::are_compressed_textures_supported();
802
803 // Load a PNG with an alpha channel.
804 wxImage image;
805 if (!image.LoadFile(wxString::FromUTF8(filename.c_str()), wxBITMAP_TYPE_PNG)) {
806 reset();
807 return false;
808 }
809
810 m_width = image.GetWidth();
811 m_height = image.GetHeight();
812
813 bool requires_rescale = false;
814
815 if (use_mipmaps && compression_enabled && OpenGLManager::force_power_of_two_textures()) {
816 if (to_squared_power_of_two(boost::filesystem::path(filename).filename().string(), OpenGLManager::get_gl_info().get_max_tex_size(), m_width, m_height))
817 requires_rescale = true;
818 }
819
820 if (compression_enabled && compression_type == MultiThreaded) {
821 // the stb_dxt compression library seems to like only texture sizes which are a multiple of 4
822 int width_rem = m_width % 4;
823 int height_rem = m_height % 4;
824
825 if (width_rem != 0) {
826 m_width += (4 - width_rem);
827 requires_rescale = true;
828 }
829
830 if (height_rem != 0) {
831 m_height += (4 - height_rem);
832 requires_rescale = true;
833 }
834 }
835
836 if (requires_rescale)
837 image = image.ResampleBicubic(m_width, m_height);
838
839 int n_pixels = m_width * m_height;
840 if (n_pixels <= 0) {
841 reset();
842 return false;
843 }
844
845 // Get RGB & alpha raw data from wxImage, pack them into an array.
846 unsigned char* img_rgb = image.GetData();
847 if (img_rgb == nullptr) {
848 reset();
849 return false;
850 }
851
852 unsigned char* img_alpha = image.GetAlpha();
853
854 std::vector<unsigned char> data(n_pixels * 4, 0);
855 for (int i = 0; i < n_pixels; ++i) {
856 int data_id = i * 4;
857 int img_id = i * 3;
858 data[data_id + 0] = img_rgb[img_id + 0];
859 data[data_id + 1] = img_rgb[img_id + 1];
860 data[data_id + 2] = img_rgb[img_id + 2];
861 data[data_id + 3] = (img_alpha != nullptr) ? img_alpha[i] : 255;
862 }
863
864 // sends data to gpu
868
869 if (apply_anisotropy) {
871 if (max_anisotropy > 1.0f)
873 }
874
875 if (compression_enabled) {
876 if (compression_type == SingleThreaded)
878 else {
879 // initializes the texture on GPU
881 // and send the uncompressed data to the compressor
882 m_compressor.add_level((unsigned int)m_width, (unsigned int)m_height, data);
883 }
884 }
885 else
887
888 if (use_mipmaps) {
889 // we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
890 int lod_w = m_width;
891 int lod_h = m_height;
892 GLint level = 0;
893 while (lod_w > 1 || lod_h > 1) {
894 ++level;
895
896 lod_w = std::max(lod_w / 2, 1);
897 lod_h = std::max(lod_h / 2, 1);
898 n_pixels = lod_w * lod_h;
899
900 image = image.ResampleBicubic(lod_w, lod_h);
901
902 data.resize(n_pixels * 4);
903
904 img_rgb = image.GetData();
905 img_alpha = image.GetAlpha();
906
907 for (int i = 0; i < n_pixels; ++i) {
908 int data_id = i * 4;
909 int img_id = i * 3;
910 data[data_id + 0] = img_rgb[img_id + 0];
911 data[data_id + 1] = img_rgb[img_id + 1];
912 data[data_id + 2] = img_rgb[img_id + 2];
913 data[data_id + 3] = (img_alpha != nullptr) ? img_alpha[i] : 255;
914 }
915
916 if (compression_enabled) {
917 if (compression_type == SingleThreaded)
919 else {
920 // initializes the texture on GPU
922 // and send the uncompressed data to the compressor
923 m_compressor.add_level((unsigned int)lod_w, (unsigned int)lod_h, data);
924 }
925 }
926 else
927 glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)lod_w, (GLsizei)lod_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data()));
928 }
929
930 if (!compression_enabled) {
933 }
934 }
935 else {
938 }
939
941
943
944 m_source = filename;
945
946 if (compression_type == MultiThreaded)
947 // start asynchronous compression
948 m_compressor.start_compressing();
949
950 return true;
951}
float get_max_anisotropy() const
Definition OpenGLManager.cpp:110
static const GLInfo & get_gl_info()
Definition OpenGLManager.hpp:106
static bool force_power_of_two_textures()
Definition OpenGLManager.hpp:107
#define GL_TEXTURE_MAX_ANISOTROPY_EXT
Definition gl.h:1825
int GLint
Definition gl.h:2062
#define glTexParameterf
Definition gl.h:4907
#define GL_LINEAR_MIPMAP_LINEAR
Definition gl.h:932
khronos_float_t GLfloat
Definition gl.h:2066
static bool to_squared_power_of_two(const std::string &filename, int max_size_px, int &w, int &h)
Definition GLTexture.cpp:779

References Slic3r::GUI::OpenGLManager::are_compressed_textures_supported(), Slic3r::GUI::OpenGLManager::force_power_of_two_textures(), Slic3r::GUI::OpenGLManager::get_gl_info(), Slic3r::GUI::OpenGLManager::GLInfo::get_max_anisotropy(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MAX_ANISOTROPY_EXT, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glsafe, glTexImage2D, glTexParameterf, glTexParameteri, m_compressor, m_height, m_id, m_source, m_width, MultiThreaded, None, reset(), SingleThreaded, and Slic3r::GUI::to_squared_power_of_two().

Referenced by load_from_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_raw_data()

bool Slic3r::GUI::GLTexture::load_from_raw_data ( std::vector< unsigned char > data,
unsigned int w,
unsigned int h,
bool apply_anisotropy = false,
bool use_mipmaps = true )
194{
195 m_width = w;
196 m_height = h;
197 int n_pixels = m_width * m_height;
198 if (n_pixels <= 0) {
199 reset();
200 return false;
201 }
202
203 // sends data to gpu
207
208 if (apply_anisotropy) {
210 if (max_anisotropy > 1.0f)
212 }
213
214
216
217 if (use_mipmaps) {
218 // We generate the mipmap chain ourselves rather than calling glGenerateMipmap(), which this
219 // codebase has historically considered unreliable on some graphics cards.
220 //
221 // Each level is a 2x2 box filter of the level above it. Note this used to re-upload the
222 // *level-0* buffer at every level instead, which does not downscale anything - it just
223 // reinterprets the image's first lod_w * lod_h texels as the whole smaller level, i.e. every
224 // level below 0 held a crop of the top-left corner. It went unnoticed for as long as every
225 // caller drew these textures at roughly their native size (where only level 0 is ever
226 // sampled); it shows up the moment one is drawn small enough to select a lower level, as a
227 // texture that visibly turns into something else as it shrinks.
228 std::vector<unsigned char> scratch;
229 const std::vector<unsigned char> *src = &data;
230 int src_w = m_width;
231 int src_h = m_height;
232 GLint level = 0;
233 while (src_w > 1 || src_h > 1) {
234 ++level;
235 const int lod_w = std::max(src_w / 2, 1);
236 const int lod_h = std::max(src_h / 2, 1);
237
238 std::vector<unsigned char> lod(size_t(lod_w) * size_t(lod_h) * 4);
239 for (int y = 0; y < lod_h; ++y) {
240 // min() rather than a plain 2*y+1: an odd source extent leaves the last output texel
241 // with only one source row/column to average, not two.
242 const int y0 = std::min(2 * y, src_h - 1);
243 const int y1 = std::min(2 * y + 1, src_h - 1);
244 for (int x = 0; x < lod_w; ++x) {
245 const int x0 = std::min(2 * x, src_w - 1);
246 const int x1 = std::min(2 * x + 1, src_w - 1);
247 for (int c = 0; c < 4; ++c) {
248 const unsigned int sum = (*src)[(size_t(y0) * size_t(src_w) + size_t(x0)) * 4 + size_t(c)] +
249 (*src)[(size_t(y0) * size_t(src_w) + size_t(x1)) * 4 + size_t(c)] +
250 (*src)[(size_t(y1) * size_t(src_w) + size_t(x0)) * 4 + size_t(c)] +
251 (*src)[(size_t(y1) * size_t(src_w) + size_t(x1)) * 4 + size_t(c)];
252 lod[(size_t(y) * size_t(lod_w) + size_t(x)) * 4 + size_t(c)] = (unsigned char)(sum / 4);
253 }
254 }
255 }
256 glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)lod_w, (GLsizei)lod_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)lod.data()));
257
258 scratch = std::move(lod);
259 src = &scratch;
260 src_w = lod_w;
261 src_h = lod_h;
262 }
263
266 }
267 else {
270 }
271
273
275
276#if 0
277 // debug output
278 static int pass = 0;
279 ++pass;
280
281 wxImage output(m_width, m_height);
282 output.InitAlpha();
283
284 for (int h = 0; h < m_height; ++h) {
285 int px_h = h * m_width;
286 for (int w = 0; w < m_width; ++w) {
287 int offset = (px_h + w) * 4;
288 output.SetRGB(w, h, data.data()[offset + 0], data.data()[offset + 1], data.data()[offset + 2]);
289 output.SetAlpha(w, h, data.data()[offset + 3]);
290 }
291 }
292
293 std::string out_filename = resources_dir() + "/images/test_" + std::to_string(pass) + ".png";
294 output.SaveFile(out_filename, wxBITMAP_TYPE_PNG);
295#endif // 0
296 return true;
297}
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
const std::string & resources_dir()
Definition utils.cpp:296

References Slic3r::GUI::OpenGLManager::get_gl_info(), Slic3r::GUI::OpenGLManager::GLInfo::get_max_anisotropy(), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MAX_ANISOTROPY_EXT, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glsafe, glTexImage2D, glTexParameterf, glTexParameteri, m_height, m_id, m_width, Slic3r::offset(), reset(), and Slic3r::resources_dir().

Here is the call graph for this function:

◆ load_from_svg()

bool Slic3r::GUI::GLTexture::load_from_svg ( const std::string & filename,
bool use_mipmaps,
bool compress,
bool apply_anisotropy,
unsigned int max_size_px )
private
954{
955 const bool compression_enabled = compress && OpenGLManager::are_compressed_textures_supported();
956
957 NSVGimage* image = nsvgParseFromFile(filename.c_str(), "px", 96.0f);
958 if (image == nullptr) {
959 reset();
960 return false;
961 }
962
963 const float scale = (float)max_size_px / std::max(image->width, image->height);
964
965 m_width = (int)(scale * image->width);
966 m_height = (int)(scale * image->height);
967
968 if (use_mipmaps && compression_enabled && OpenGLManager::force_power_of_two_textures())
969 to_squared_power_of_two(boost::filesystem::path(filename).filename().string(), max_size_px, m_width, m_height);
970
971 float scale_w = (float)m_width / image->width;
972 float scale_h = (float)m_height / image->height;
973
974 if (compression_enabled) {
975 // the stb_dxt compression library seems to like only texture sizes which are a multiple of 4
976 int width_rem = m_width % 4;
977 int height_rem = m_height % 4;
978
979 if (width_rem != 0)
980 m_width += (4 - width_rem);
981
982 if (height_rem != 0)
983 m_height += (4 - height_rem);
984 }
985
986 const int n_pixels = m_width * m_height;
987
988 if (n_pixels <= 0) {
989 reset();
990 nsvgDelete(image);
991 return false;
992 }
993
994 NSVGrasterizer* rast = nsvgCreateRasterizer();
995 if (rast == nullptr) {
996 nsvgDelete(image);
997 reset();
998 return false;
999 }
1000
1001 // creates the temporary buffer only once, with max size, and reuse it for all the levels, if generating mipmaps
1002 std::vector<unsigned char> data(n_pixels * 4, 0);
1003 nsvgRasterizeXY(rast, image, 0, 0, scale_w, scale_h, data.data(), m_width, m_height, m_width * 4);
1004
1005 // sends data to gpu
1009
1010 if (apply_anisotropy) {
1012 if (max_anisotropy > 1.0f)
1014 }
1015
1016 if (compression_enabled) {
1017 // initializes the texture on GPU
1019 // and send the uncompressed data to the compressor
1020 m_compressor.add_level((unsigned int)m_width, (unsigned int)m_height, data);
1021 }
1022 else
1024
1025 if (use_mipmaps) {
1026 // we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
1027 int lod_w = m_width;
1028 int lod_h = m_height;
1029 GLint level = 0;
1030 while (lod_w >= 4 && lod_h >= 4) {
1031 ++level;
1032
1033 lod_w = std::max(lod_w / 2, 1);
1034 lod_h = std::max(lod_h / 2, 1);
1035 scale_w /= 2.0f;
1036 scale_h /= 2.0f;
1037
1038 data.resize(lod_w * lod_h * 4);
1039
1040 nsvgRasterizeXY(rast, image, 0, 0, scale_w, scale_h, data.data(), lod_w, lod_h, lod_w * 4);
1041 if (compression_enabled) {
1042 // initializes the texture on GPU
1044 // and send the uncompressed data to the compressor
1045 m_compressor.add_level((unsigned int)lod_w, (unsigned int)lod_h, data);
1046 }
1047 else
1048 glsafe(::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)lod_w, (GLsizei)lod_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data()));
1049 }
1050
1051 if (!compression_enabled) {
1054 }
1055 }
1056 else {
1059 }
1060
1062
1064
1065 m_source = filename;
1066
1067 if (compression_enabled)
1068 // start asynchronous compression
1069 m_compressor.start_compressing();
1070
1071 nsvgDeleteRasterizer(rast);
1072 nsvgDelete(image);
1073
1074 return true;
1075}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
NSVGimage_ptr nsvgParseFromFile(const std::string &filename, const char *units, float dpi)
Definition NSVGUtils.cpp:106

References Slic3r::GUI::OpenGLManager::are_compressed_textures_supported(), Slic3r::GUI::OpenGLManager::force_power_of_two_textures(), Slic3r::GUI::OpenGLManager::get_gl_info(), Slic3r::GUI::OpenGLManager::GLInfo::get_max_anisotropy(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MAX_ANISOTROPY_EXT, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glsafe, glTexImage2D, glTexParameterf, glTexParameteri, m_compressor, m_height, m_id, m_source, m_width, Slic3r::nsvgParseFromFile(), reset(), scale(), and Slic3r::GUI::to_squared_power_of_two().

Referenced by load_from_svg_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_svg_file()

bool Slic3r::GUI::GLTexture::load_from_svg_file ( const std::string & filename,
bool use_mipmaps,
bool compress,
bool apply_anisotropy,
unsigned int max_size_px )
179{
180 reset();
181 auto svg_file = filename;
183 if (!boost::filesystem::exists(svg_file))
184 return false;
185
186 if (boost::algorithm::iends_with(svg_file, ".svg"))
187 return load_from_svg(svg_file, use_mipmaps, compress, apply_anisotropy, max_size_px);
188 else
189 return false;
190}
bool load_from_svg(const std::string &filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px)
Definition GLTexture.cpp:953
void slash_to_back_slash(std::string &file_path)
Definition FileHelp.cpp:26

References load_from_svg(), reset(), and Slic3r::Utils::slash_to_back_slash().

Referenced by Slic3r::GUI::GLCanvas3D::_init_select_plate_toolbar(), Slic3r::GUI::PartPlateList::generate_icon_textures(), and Slic3r::GUI::load_next_part_texture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_svg_files_as_sprites_array()

bool Slic3r::GUI::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 )
301{
302 reset();
303
304 if (filenames.empty() || states.empty() || sprite_size_px == 0)
305 return false;
306
307 bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
308
309 // every tile needs to have a 1px border around it to avoid artifacts when linear sampling on its edges
310 unsigned int sprite_size_px_ex = sprite_size_px + 1;
311
312 m_width = 1 + (int)(sprite_size_px_ex * states.size());
313 m_height = 1 + (int)(sprite_size_px_ex * filenames.size());
314
315 int n_pixels = m_width * m_height;
316 int sprite_n_pixels = sprite_size_px_ex * sprite_size_px_ex;
317 int sprite_stride = sprite_size_px_ex * 4;
318 int sprite_bytes = sprite_n_pixels * 4;
319
320 if (n_pixels <= 0) {
321 reset();
322 return false;
323 }
324
325 std::vector<unsigned char> data(n_pixels * 4, 0);
326 std::vector<unsigned char> sprite_data(sprite_bytes, 0);
327 std::vector<unsigned char> sprite_white_only_data(sprite_bytes, 0); // normal
328 std::vector<unsigned char> sprite_gray_only_data(sprite_bytes, 0); // disable
329 std::vector<unsigned char> output_data(sprite_bytes, 0);
330
331 //BBS
332 std::vector<unsigned char> pressed_data(sprite_bytes, 0); // (gizmo) pressed
333 std::vector<unsigned char> disable_data(sprite_bytes, 0);
334 std::vector<unsigned char> hover_data(sprite_bytes, 0); // hover
335
336 const unsigned char pressed_color[3] = {255, 255, 255};
337 const unsigned char hover_color[3] = {255, 255, 255};
338 const unsigned char normal_color[3] = {43, 52, 54};
339 const unsigned char disable_color[3] = {200, 200, 200};
340 const unsigned char pressed_color_dark[3] = {60, 60, 65};
341 const unsigned char hover_color_dark[3] = {60, 60, 65};
342 const unsigned char normal_color_dark[3] = {182, 182, 182};
343 const unsigned char disable_color_dark[3] = {76, 76, 85};
344
345 NSVGrasterizer* rast = nsvgCreateRasterizer();
346 if (rast == nullptr) {
347 reset();
348 return false;
349 }
350
351 int sprite_id = -1;
352 for (const std::string& filename : filenames) {
353 ++sprite_id;
354
355 if (!boost::filesystem::exists(filename))
356 continue;
357
358 if (!boost::algorithm::iends_with(filename, ".svg"))
359 continue;
360
361 NSVGimage* image = nsvgParseFromFile(filename.c_str(), "px", 96.0f);
362 if (image == nullptr)
363 continue;
364
365 float scale = (float)sprite_size_px / std::max(image->width, image->height);
366
367 // offset by 1 to leave the first pixel empty (both in x and y)
368 nsvgRasterize(rast, image, 1, 1, scale, sprite_data.data(), sprite_size_px, sprite_size_px, sprite_stride);
369
370 ::memcpy((void*)pressed_data.data(), (const void*)sprite_data.data(), sprite_bytes);
371 for (int i = 0; i < sprite_n_pixels; ++i) {
372 int offset = i * 4;
373 if (pressed_data.data()[offset + 0] == 0 &&
374 pressed_data.data()[offset + 1] == 0 &&
375 pressed_data.data()[offset + 2] == 0) {
376 hover_data.data()[offset + 0] = dark_mode ? pressed_color_dark[0] : pressed_color[0];
377 hover_data.data()[offset + 0] = dark_mode ? pressed_color_dark[1] : pressed_color[1];
378 hover_data.data()[offset + 0] = dark_mode ? pressed_color_dark[2] : pressed_color[2];
379 }
380 }
381
382 ::memcpy((void*)disable_data.data(), (const void*)sprite_data.data(), sprite_bytes);
383 for (int i = 0; i < sprite_n_pixels; ++i) {
384 int offset = i * 4;
385 if (disable_data.data()[offset] != 0)
386 ::memset((void*)&disable_data.data()[offset], 200, 3);
387 }
388
389 ::memcpy((void*)hover_data.data(), (const void*)sprite_data.data(), sprite_bytes);
390 for (int i = 0; i < sprite_n_pixels; ++i) {
391 int offset = i * 4;
392 if (hover_data.data()[offset + 0] == 0 &&
393 hover_data.data()[offset + 1] == 0 &&
394 hover_data.data()[offset + 2] == 0)
395 {
396 hover_data.data()[offset + 0] = dark_mode ? hover_color_dark[0] : hover_color[0];
397 hover_data.data()[offset + 1] = dark_mode ? hover_color_dark[1] : hover_color[1];
398 hover_data.data()[offset + 2] = dark_mode ? hover_color_dark[2] : hover_color[2];
399 }
400 }
401
402 ::memcpy((void*)sprite_white_only_data.data(), (const void*)sprite_data.data(), sprite_bytes);
403 for (int i = 0; i < sprite_n_pixels; ++i) {
404 int offset = i * 4;
405 if (sprite_white_only_data.data()[offset + 0] != 0 ||
406 sprite_white_only_data.data()[offset + 1] != 0 ||
407 sprite_white_only_data.data()[offset + 2] != 0) {
408 sprite_white_only_data.data()[offset + 0] = dark_mode ? normal_color_dark[0] : normal_color[0];
409 sprite_white_only_data.data()[offset + 1] = dark_mode ? normal_color_dark[1] : normal_color[1];
410 sprite_white_only_data.data()[offset + 2] = dark_mode ? normal_color_dark[2] : normal_color[2];
411 }
412 }
413
414 ::memcpy((void*)sprite_gray_only_data.data(), (const void*)sprite_data.data(), sprite_bytes);
415 for (int i = 0; i < sprite_n_pixels; ++i) {
416 int offset = i * 4;
417 if (sprite_gray_only_data.data()[offset + 0] != 0 ||
418 sprite_gray_only_data.data()[offset + 1] != 0 ||
419 sprite_gray_only_data.data()[offset + 2] != 0) {
420 sprite_gray_only_data.data()[offset + 0] = dark_mode ? disable_color_dark[0] : disable_color[0];
421 sprite_gray_only_data.data()[offset + 1] = dark_mode ? disable_color_dark[1] : disable_color[1];
422 sprite_gray_only_data.data()[offset + 2] = dark_mode ? disable_color_dark[2] : disable_color[2];
423 }
424 }
425
426
427 int sprite_offset_px = sprite_id * (int)sprite_size_px_ex * m_width;
428 int state_id = -1;
429 for (const std::pair<int, bool>& state : states) {
430 ++state_id;
431
432 // select the sprite variant
433 std::vector<unsigned char>* src = nullptr;
434 switch (state.first)
435 {
436 case 1: { src = &sprite_white_only_data; break; }
437 case 2: { src = &sprite_gray_only_data; break; }
438 default: { src = &hover_data; break; }
439 }
440
441 // applies background, if needed
442 if (state.second) {
443 src = &pressed_data;
444 }
445
446 ::memcpy((void*)output_data.data(), (const void*)src->data(), sprite_bytes);
447
448 //BBS use BBS pressed style
449 //if (state.second) {
450 // float inv_255 = 1.0f / 255.0f;
451 // // offset by 1 to leave the first pixel empty (both in x and y)
452 // for (unsigned int r = 1; r <= sprite_size_px; ++r) {
453 // unsigned int offset_r = r * sprite_size_px_ex;
454 // for (unsigned int c = 1; c <= sprite_size_px; ++c) {
455 // unsigned int offset = (offset_r + c) * 4;
456 // float alpha = (float)output_data.data()[offset + 3] * inv_255;
457 // output_data.data()[offset + 0] = (unsigned char)(output_data.data()[offset + 0] * alpha);
458 // output_data.data()[offset + 1] = (unsigned char)(output_data.data()[offset + 1] * alpha);
459 // output_data.data()[offset + 2] = (unsigned char)(output_data.data()[offset + 2] * alpha);
460 // output_data.data()[offset + 3] = (unsigned char)(128 * (1.0f - alpha) + output_data.data()[offset + 3] * alpha);
461 // }
462 // }
463 //}
464
465 int state_offset_px = sprite_offset_px + state_id * sprite_size_px_ex;
466 for (int j = 0; j < (int)sprite_size_px_ex; ++j) {
467 ::memcpy((void*)&data.data()[(state_offset_px + j * m_width) * 4], (const void*)&output_data.data()[j * sprite_stride], sprite_stride);
468 }
469 }
470
471 nsvgDelete(image);
472 }
473
474 nsvgDeleteRasterizer(rast);
475
476 // sends data to gpu
482 else
487
489
490 m_source = filenames.front();
491
492#if 0
493 // debug output
494 static int pass = 0;
495 ++pass;
496
497 wxImage output(m_width, m_height);
498 output.InitAlpha();
499
500 for (int h = 0; h < m_height; ++h) {
501 int px_h = h * m_width;
502 for (int w = 0; w < m_width; ++w) {
503 int offset = (px_h + w) * 4;
504 output.SetRGB(w, h, data.data()[offset + 0], data.data()[offset + 1], data.data()[offset + 2]);
505 output.SetAlpha(w, h, data.data()[offset + 3]);
506 }
507 }
508
509 std::string out_filename = resources_dir() + "/images/test_" + std::to_string(pass) + ".png";
510 output.SaveFile(out_filename, wxBITMAP_TYPE_PNG);
511#endif // 0
512
513 return true;
514}

References Slic3r::GUI::OpenGLManager::are_compressed_textures_supported(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glPixelStorei, glsafe, glTexImage2D, glTexParameteri, m_height, m_id, m_source, m_width, Slic3r::nsvgParseFromFile(), Slic3r::offset(), reset(), Slic3r::resources_dir(), and scale().

Here is the call graph for this function:

◆ render_sub_texture()

void Slic3r::GUI::GLTexture::render_sub_texture ( unsigned int tex_id,
float left,
float right,
float bottom,
float top,
const Quad_UVs & uvs )
static
716{
718 // Orca: fix washed-out toolbar icons on Wayland: keep destination alpha at 1.0 so the compositor
719 // does not treat anti-aliased icon edges as window transparency.
721
723
724 GLModel::Geometry init_data;
726 init_data.reserve_vertices(4);
727 init_data.reserve_indices(6);
728
729 // vertices
730 init_data.add_vertex(Vec2f(left, bottom), Vec2f(uvs.left_bottom.u, uvs.left_bottom.v));
731 init_data.add_vertex(Vec2f(right, bottom), Vec2f(uvs.right_bottom.u, uvs.right_bottom.v));
732 init_data.add_vertex(Vec2f(right, top), Vec2f(uvs.right_top.u, uvs.right_top.v));
733 init_data.add_vertex(Vec2f(left, top), Vec2f(uvs.left_top.u, uvs.left_top.v));
734
735 // indices
736 init_data.add_triangle(0, 1, 2);
737 init_data.add_triangle(2, 3, 0);
738
739 GLModel model;
740 model.init_from(std::move(init_data));
741
742 GLShaderProgram* shader = wxGetApp().get_shader("flat_texture");
743 if (shader != nullptr) {
744 shader->start_using();
745 shader->set_uniform("view_model_matrix", Transform3d::Identity());
746 shader->set_uniform("projection_matrix", Transform3d::Identity());
747 model.render();
748 shader->stop_using();
749 }
750
752
754}
#define glBlendFuncSeparate
Definition gl.h:3327
#define glEnable
Definition gl.h:3667
#define GL_SRC_ALPHA
Definition gl.h:1621
#define GL_BLEND
Definition gl.h:275
#define GL_ONE_MINUS_SRC_ALPHA
Definition gl.h:1239
#define GL_ONE
Definition gl.h:1232
#define glDisable
Definition gl.h:3607
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > Vec2f
Definition Point.hpp:64

References Slic3r::GUI::GLModel::Geometry::add_triangle(), Slic3r::GUI::GLModel::Geometry::add_vertex(), Slic3r::GUI::GLModel::Geometry::format, GL_BLEND, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_TEXTURE_2D, glBindTexture, glBlendFuncSeparate, glDisable, glEnable, glsafe, Slic3r::GUI::GLModel::init_from(), Slic3r::GUI::GLTexture::Quad_UVs::left_bottom, Slic3r::GUI::GLTexture::Quad_UVs::left_top, Slic3r::GUI::GLModel::Geometry::P2T2, Slic3r::GUI::GLModel::render(), Slic3r::GUI::GLModel::Geometry::reserve_indices(), Slic3r::GUI::GLModel::Geometry::reserve_vertices(), Slic3r::GUI::GLTexture::Quad_UVs::right_bottom, Slic3r::GUI::GLTexture::Quad_UVs::right_top, Slic3r::GLShaderProgram::set_uniform(), Slic3r::GLShaderProgram::start_using(), Slic3r::GLShaderProgram::stop_using(), Slic3r::GUI::GLModel::Geometry::Triangles, Slic3r::GUI::GLTexture::UV::u, and Slic3r::GUI::GLTexture::UV::v.

Referenced by Slic3r::GUI::GLGizmosManager::do_render_overlay(), Slic3r::GUI::GLToolbarItem::render(), Slic3r::GUI::GLGizmosManager::render_arrow(), Slic3r::GUI::GLToolbar::render_arrow(), Slic3r::GUI::GLGizmosManager::render_background(), Slic3r::GUI::GLToolbar::render_background(), Slic3r::GUI::GLToolbarItem::render_image(), Slic3r::GUI::GLToolbarItem::render_text(), and render_texture().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_texture()

void Slic3r::GUI::GLTexture::render_texture ( unsigned int tex_id,
float left,
float right,
float bottom,
float top )
static
711{
712 render_sub_texture(tex_id, left, right, bottom, top, FullTextureUVs);
713}
static void render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const Quad_UVs &uvs)
Definition GLTexture.cpp:715
static Quad_UVs FullTextureUVs
Definition GLTexture.hpp:91

References FullTextureUVs, and render_sub_texture().

Here is the call graph for this function:

◆ reset()

void Slic3r::GUI::GLTexture::reset ( )
517{
518 if (m_id != 0)
520
521 m_id = 0;
522 m_width = 0;
523 m_height = 0;
524 m_source = "";
525 m_compressor.reset();
526
527 //BBS: GUI refactor
529}
#define glDeleteTextures
Definition gl.h:3587

References glDeleteTextures, glsafe, m_compressor, m_height, m_id, m_original_height, m_original_width, m_source, and m_width.

Referenced by ~GLTexture(), load_from_file(), load_from_png(), load_from_raw_data(), load_from_svg(), load_from_svg_file(), load_from_svg_files_as_sprites_array(), and Slic3r::GUI::GLTexture::Compressor::send_compressed_data_to_gpu().

Here is the caller graph for this function:

◆ send_compressed_data_to_gpu()

void Slic3r::GUI::GLTexture::send_compressed_data_to_gpu ( )
inline
137{ m_compressor.send_compressed_data_to_gpu(); }

References m_compressor.

Referenced by Slic3r::GUI::PartPlate::render_logo_texture().

Here is the caller graph for this function:

◆ unsent_compressed_data_available()

bool Slic3r::GUI::GLTexture::unsent_compressed_data_available ( ) const
inline
136{ return m_compressor.unsent_compressed_data_available(); }

References m_compressor.

Referenced by Slic3r::GUI::PartPlate::render_logo_texture().

Here is the caller graph for this function:

◆ Compressor

friend class Compressor
friend

Member Data Documentation

◆ FullTextureUVs

GLTexture::Quad_UVs Slic3r::GUI::GLTexture::FullTextureUVs = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } }
static

Referenced by render_texture().

◆ m_compressor

◆ m_height

◆ m_id

unsigned int Slic3r::GUI::GLTexture::m_id { 0 }
protected

◆ m_original_height

int Slic3r::GUI::GLTexture::m_original_height

◆ m_original_width

◆ m_source

std::string Slic3r::GUI::GLTexture::m_source
protected

◆ m_width


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLTexture.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLTexture.cpp