mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-17 05:52:39 +00:00
* Fix OpenGL framebuffer object support on macOS this enables the outline on macOS * Revert "Fix OpenGL framebuffer object support on macOS" This reverts commit 9872708954e785a86209613bbab7cc770d636b7a. * Enable ARB framebuffer if OpenGL >= 3.0 (OrcaSlicer/OrcaSlicer#14770) * FIX: plater toolbar image update jira: STUDIO-12457 Change-Id: Ia855b4bd9bec884d52202f5d8f5cfad9efce0f2f (cherry picked from commit 474691813b497654ef701fe7073992db366e81a9) * FIX: thumbinal regen jira: STUDIO-16732 Change-Id: I4cc4e76b36caf1a41793c1f84ee5e88a44ebdd42 (cherry picked from commit 53f33b7db260005e477842d6459b1b28aa8aa0d8) * FIX: force update thumbinal once dirty jira: STUDIO-13041 Change-Id: I770743b53c51351cb3b8a7133140974c75c05364 (cherry picked from commit 96198a12712f21d2b4521b6e3d1caff50bed21ff) * FIX:thumbnail update jira: STUDIO-13041 / STUDIO-13304 Change-Id: I9dec25f12454fc8485195cf5dc3feb421b6347c4 (cherry picked from commit cf778dc90f805d3f46e28f8f1d1d5814d3fb4d51) --------- Co-authored-by: jun.zhang <jun.zhang@bambulab.com>
104 lines
2.9 KiB
C++
104 lines
2.9 KiB
C++
#include "IMToolbar.hpp"
|
|
|
|
#include "3DScene.hpp"
|
|
#include <glad/gl.h>
|
|
#include <imgui/imgui_internal.h>
|
|
#include <imgui/imgui.h>
|
|
|
|
#include "nanosvg/nanosvg.h"
|
|
#include "nanosvg/nanosvgrast.h"
|
|
#include "libslic3r/GCode/ThumbnailData.hpp"
|
|
#include "ImGuiWrapper.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
IMToolbarItem::~IMToolbarItem()
|
|
{
|
|
GLuint id = (GLuint)(int64_t)texture_id;
|
|
if (id != 0)
|
|
glsafe(::glDeleteTextures(1, &id));
|
|
}
|
|
|
|
|
|
bool IMToolbarItem::generate_texture()
|
|
{
|
|
GLint last_texture;
|
|
unsigned m_image_texture{ 0 };
|
|
unsigned char* pixels = (unsigned char*)(&image_data[0]);
|
|
|
|
glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
|
glsafe(::glGenTextures(1, &m_image_texture));
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, m_image_texture));
|
|
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));
|
|
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
|
|
// Store our identifier
|
|
texture_id = (ImTextureID)(intptr_t)m_image_texture;
|
|
|
|
// Restore state
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
|
|
|
|
return true;
|
|
}
|
|
|
|
void IMToolbar::del_all_item()
|
|
{
|
|
for (int i = 0; i < m_items.size(); i++) {
|
|
delete m_items[i];
|
|
m_items[i] = nullptr;
|
|
}
|
|
m_items.clear();
|
|
}
|
|
|
|
void IMToolbar::del_stats_item()
|
|
{
|
|
delete m_all_plates_stats_item;
|
|
m_all_plates_stats_item = nullptr;
|
|
}
|
|
|
|
void IMToolbar::set_enabled(bool enable)
|
|
{
|
|
m_enabled = enable;
|
|
}
|
|
|
|
bool IMReturnToolbar::init()
|
|
{
|
|
bool compress = false;
|
|
GLint last_texture;
|
|
unsigned m_image_texture{ 0 };
|
|
|
|
std::string path = resources_dir() + "/images/";
|
|
std::string file_name;
|
|
|
|
file_name = path + "assemble_return.svg";
|
|
|
|
ThumbnailData data;
|
|
if (!get_data_from_svg(file_name, 20, data))
|
|
return false;
|
|
|
|
unsigned char* pixels = (unsigned char*)(&data.pixels[0]);
|
|
glsafe(::glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture));
|
|
glsafe(::glGenTextures(1, &m_image_texture));
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, m_image_texture));
|
|
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 (compress && GLAD_GL_EXT_texture_compression_s3tc)
|
|
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, data.width, data.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
else
|
|
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data.width, data.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
|
|
|
|
// Store our identifier
|
|
texture_id = (ImTextureID)(intptr_t)m_image_texture;
|
|
|
|
// Restore state
|
|
glsafe(::glBindTexture(GL_TEXTURE_2D, last_texture));
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace GUI
|
|
} // namespace Slic3r
|