mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 07:11:10 +00:00
* Add Missing Includes Across src/slic3r/GUI Every GUI source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, plus one hand edit making CalibrationPanel.hpp self-contained. * Drop the OS-Specific Includes Added Outside Their Platform Guards GLib, GTK, D-Bus and POSIX headers are only used inside platform #if blocks, which already include them. Added unconditionally at the top of the file they broke the Windows build. * Add the clang-tidy Configuration That Generated These Includes Only misc-include-cleaner's missing-include check, with the headers it must never suggest: per-platform, internal and OS-specific ones that would break other platforms or are not meant to be included directly. * Match Windows Paths in the clang-tidy Ignore List Header paths use backslashes on Windows, so every / in a pattern is now [/\\]. The Windows SDK headers are ignored alongside the other OS-specific ones, and the list is one pattern per line. Suggested by @raistlin7447 from a Windows clang-cl run.
113 lines
5.8 KiB
C++
113 lines
5.8 KiB
C++
#ifndef slic3r_GLShader_hpp_
|
|
#define slic3r_GLShader_hpp_
|
|
|
|
#include <array>
|
|
#include <cstddef>
|
|
#include <initializer_list>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
#include <utility>
|
|
|
|
#include "libslic3r/Point.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
class ColorRGB;
|
|
class ColorRGBA;
|
|
|
|
class GLShaderProgram
|
|
{
|
|
public:
|
|
enum class EShaderType
|
|
{
|
|
Vertex,
|
|
Fragment,
|
|
Geometry,
|
|
TessEvaluation,
|
|
TessControl,
|
|
Compute,
|
|
Count
|
|
};
|
|
|
|
typedef std::array<std::string, static_cast<size_t>(EShaderType::Count)> ShaderFilenames;
|
|
typedef std::array<std::string, static_cast<size_t>(EShaderType::Count)> ShaderSources;
|
|
|
|
private:
|
|
std::string m_name;
|
|
unsigned int m_id{ 0 };
|
|
std::vector<std::pair<std::string, int>> m_attrib_location_cache;
|
|
std::vector<std::pair<std::string, int>> m_uniform_location_cache;
|
|
|
|
public:
|
|
~GLShaderProgram();
|
|
|
|
bool init_from_files(const std::string& name, const ShaderFilenames& filenames, const std::initializer_list<std::string_view> &defines = {});
|
|
bool init_from_texts(const std::string& name, const ShaderSources& sources);
|
|
|
|
const std::string& get_name() const { return m_name; }
|
|
unsigned int get_id() const { return m_id; }
|
|
|
|
void start_using() const;
|
|
void stop_using() const;
|
|
|
|
void set_uniform(const char* name, int value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, bool value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, float value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, double value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<int, 2>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<int, 3>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<int, 4>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<float, 2>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<float, 3>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<float, 4>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const std::array<double, 4>& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const float* value, size_t size) const { set_uniform(get_uniform_location(name), value, size); }
|
|
void set_uniform(const char* name, const Transform3f& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Transform3d& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Matrix3f& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Matrix3d& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Matrix4f& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Matrix4d& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Vec2f& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Vec2d& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Vec3f& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const Vec3d& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const ColorRGB& value) const { set_uniform(get_uniform_location(name), value); }
|
|
void set_uniform(const char* name, const ColorRGBA& value) const { set_uniform(get_uniform_location(name), value); }
|
|
|
|
void set_uniform(int id, int value) const;
|
|
void set_uniform(int id, bool value) const;
|
|
void set_uniform(int id, float value) const;
|
|
void set_uniform(int id, double value) const;
|
|
void set_uniform(int id, const std::array<int, 2>& value) const;
|
|
void set_uniform(int id, const std::array<int, 3>& value) const;
|
|
void set_uniform(int id, const std::array<int, 4>& value) const;
|
|
void set_uniform(int id, const std::array<float, 2>& value) const;
|
|
void set_uniform(int id, const std::array<float, 3>& value) const;
|
|
void set_uniform(int id, const std::array<float, 4>& value) const;
|
|
void set_uniform(int id, const std::array<double, 4>& value) const;
|
|
void set_uniform(int id, const float* value, size_t size) const;
|
|
void set_uniform(int id, const Transform3f& value) const;
|
|
void set_uniform(int id, const Transform3d& value) const;
|
|
void set_uniform(int id, const Matrix3f& value) const;
|
|
void set_uniform(int id, const Matrix3d& value) const;
|
|
void set_uniform(int id, const Matrix4f& value) const;
|
|
void set_uniform(int id, const Matrix4d& value) const;
|
|
void set_uniform(int id, const Vec2f& value) const;
|
|
void set_uniform(int id, const Vec2d& value) const;
|
|
void set_uniform(int id, const Vec3f& value) const;
|
|
void set_uniform(int id, const Vec3d& value) const;
|
|
void set_uniform(int id, const ColorRGB& value) const;
|
|
void set_uniform(int id, const ColorRGBA& value) const;
|
|
|
|
// returns -1 if not found
|
|
int get_attrib_location(const char* name) const;
|
|
// returns -1 if not found
|
|
int get_uniform_location(const char* name) const;
|
|
};
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif /* slic3r_GLShader_hpp_ */
|