1 #ifndef INCLUDE_ONCE_E28E88C6_7992_4205_828C_8E04CC339B83 2 #define INCLUDE_ONCE_E28E88C6_7992_4205_828C_8E04CC339B83 9 #include <QGenericMatrix> 10 #include <QOpenGLFunctions_3_3_Core> 11 #include "../ShowMySky/api/ShowMySky/Exception.hpp" 13 #define DEFINE_EXPLICIT_BOOL(Type) \ 17 explicit Type()=default; \ 18 explicit Type(bool on) : on(on) {} \ 19 operator bool() const { return on; } \ 22 template<
typename T>
auto sqr(T
const& x) {
return x*x; }
23 inline QVector3D toQVector(glm::dvec3
const& v) {
return QVector3D(v.x, v.y, v.z); }
24 inline QVector3D toQVector(glm::vec3
const& v) {
return QVector3D(v.x, v.y, v.z); }
25 inline QVector4D toQVector(glm::dvec4
const& v) {
return QVector4D(v.x, v.y, v.z, v.w); }
26 inline QVector4D toQVector(glm::vec4
const& v) {
return QVector4D(v.x, v.y, v.z, v.w); }
27 inline QMatrix3x3 toQMatrix(glm::mat3
const& m) {
return QMatrix3x3(&transpose(m)[0][0]); }
36 QString
errorType()
const override {
return QObject::tr(
"Initialization error"); }
37 QString
what()
const override {
return message; }
44 OpenGLError(QString
const& message) : message(message) {}
45 QString
errorType()
const override {
return QObject::tr(
"OpenGL error"); }
46 QString
what()
const override {
return message; }
54 QString
errorType()
const override {
return QObject::tr(
"Error loading data"); }
55 QString
what()
const override {
return message; }
63 QString
errorType()
const override {
return QObject::tr(
"Bad command line"); }
64 QString
what()
const override {
return message; }
73 ParsingError(QString
const& filename,
int lineNumber, QString
const& message)
74 : message(message), filename(filename), lineNumber(lineNumber) {}
75 QString
errorType()
const override {
return QObject::tr(
"Parsing error"); }
76 QString
what()
const override {
return QString(
"%1:%2: %3").arg(filename).arg(lineNumber).arg(message); }
79 inline std::ostream& operator<<(std::ostream& os, QString
const& s)
81 os << s.toStdString();
85 void checkFramebufferStatus(QOpenGLFunctions_3_3_Core& gl,
const char* fboDescription);
88 void dumpActiveUniforms(QOpenGLFunctions_3_3_Core& gl, GLuint program);
90 std::string openglErrorString(GLenum error);
98 : oldConsoleCP(GetConsoleOutputCP())
100 SetConsoleOutputCP(65001);
108 SetConsoleOutputCP(oldConsoleCP);
116 inline float unitRangeToTexCoord(
const float u,
const int texSize)
118 return (0.5+(texSize-1)*u)/texSize;
122 inline float texCoordToUnitRange(
const float texCoord,
const float texSize)
124 return (texSize*texCoord-0.5)/(texSize-1);
128 template<
typename Number>
129 Number clampCosine(
const Number x)
131 return std::clamp(x, Number(-1), Number(1));
134 glm::mat4 radianceToLuminance(
unsigned texIndex, std::vector<glm::vec4>
const& allWavelengths);
137 void roundTexData(GLfloat* data,
size_t size,
int precision);
139 inline int roundDownToClosestPowerOfTwo(
const int x)
143 for(
auto v=x;v;v>>=1)
An error that ShowMySky classes may throw.
Definition: Exception.hpp:25
QString errorType() const override
A string suitable for use as a title of a message box.
Definition: util.hpp:36
QString what() const override
A description of the error.
Definition: util.hpp:37
QString errorType() const override
A string suitable for use as a title of a message box.
Definition: util.hpp:75
QString errorType() const override
A string suitable for use as a title of a message box.
Definition: util.hpp:63
QString errorType() const override
A string suitable for use as a title of a message box.
Definition: util.hpp:45
QString what() const override
A description of the error.
Definition: util.hpp:46
QString what() const override
A description of the error.
Definition: util.hpp:64
QString what() const override
A description of the error.
Definition: util.hpp:55
QString what() const override
A description of the error.
Definition: util.hpp:76
QString errorType() const override
A string suitable for use as a title of a message box.
Definition: util.hpp:54