Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
xgl/utils.h
Go to the documentation of this file.
1#pragma once
2#include "math/Types.h"
3#include <QOpenGLShaderProgram>
4#include <xgl/Types.h>
5#include <xgl/global.h>
6
7namespace sf::xgl
8{
9
10// Forward declaration.
11class ShaderProgram;
12
13// Forward declaration.
14class Color;
15
33_XGL_FUNC QMatrix4x4 getPerspectiveMatrix(float fov_y, float aspect, float near_z, float far_z);
37_XGL_FUNC matrix4x4f getPerspectiveMatrixF(GLfloat fovY, GLfloat aspect, GLfloat nearZ, GLfloat farZ);
38
44_XGL_FUNC std::pair<GLsizei, std::string_view> getTypeInfo(GLenum type);
45
51template<typename T>
52constexpr GLenum getTypeEnum();
53
63template<size_t N = 3, typename T = GLfloat>
64std::array<T, N> array(QVector3D vect, T value = 1);
65
73_XGL_FUNC QMatrix4x4 getRotationMatrix(const QVector3D& v1, const QVector3D& v2);
74
81_XGL_FUNC std::string asString(const QVector3D& v, int digits = 0);
82
89_XGL_FUNC std::string asString(const QMatrix4x4& mtx, int digits = 0);
90
94_XGL_FUNC void toMatrix44(Matrix44& trg, const QMatrix4x4& mtx);
95
99_XGL_FUNC Matrix44 toMatrix44(const QMatrix4x4& mtx);
100
104_XGL_FUNC void toQMatrix4x4(QMatrix4x4& trg, const Matrix44& mtx);
105
109_XGL_FUNC QMatrix4x4 toQMatrix4x4(const Matrix44& mtx);
110
114_XGL_FUNC QVector3D toQVector3D(const Vector3D& v);
115
121_XGL_FUNC QImage getTransparentImage(const QImage& src_image, int alpha);
122
131template<typename VertexType, typename FieldType>
132void setVertexAttribPointer(QOpenGLShaderProgram* sp, GLuint attr_loc, size_t offset);
133
137_XGL_FUNC bool checkDrawMode(GLenum mode, size_t vertice_count, const std::string& src);
138
139}// namespace sf::xgl
140
141#ifndef __JETBRAINS_IDE__
142 // Include all inlined functions and template implementations.
143 #include <xgl/utils.hpp>
144#endif
Definition DemoRenderer.h:6
_XGL_FUNC QVector3D toQVector3D(const Vector3D &v)
Converts the given sf::Vector3D into a Qt QVector3D.
_XGL_FUNC void toMatrix44(Matrix44 &trg, const QMatrix4x4 &mtx)
Converts the given Qt 4x4 matrix into a sf::Matrix44.
_XGL_FUNC QImage getTransparentImage(const QImage &src_image, int alpha)
Turms the given image into a transparent one.
_XGL_FUNC QMatrix4x4 getPerspectiveMatrix(float fov_y, float aspect, float near_z, float far_z)
createPerspectiveMatrix Generates a perspective projection matrix using QMatrix4x4....
_XGL_FUNC std::pair< GLsizei, std::string_view > getTypeInfo(GLenum type)
Gets the C++ type and GLSL type as a string, and the size in bytes of the given enumeration type.
_XGL_FUNC void toQMatrix4x4(QMatrix4x4 &trg, const Matrix44 &mtx)
Converts the given sf::Matrix44 into a Qt 4x4 matrix.
_XGL_FUNC std::string asString(const QVector3D &v, int digits=0)
Converts the given vector to a std::string.
std::array< T, N > array(QVector3D vect, T value=1)
Template function to get an 'std::array' type from a Vector3D. This function is to pass a 3D vector w...
std::array< GLfloat, 16 > matrix4x4f
Type which corresponds with a GLSL type and used to implement Vertex structures.
Definition Types.h:13
_XGL_FUNC bool checkDrawMode(GLenum mode, size_t vertice_count, const std::string &src)
Checks is the necessary vertices are enough and in range.
_XGL_FUNC matrix4x4f getPerspectiveMatrixF(GLfloat fovY, GLfloat aspect, GLfloat nearZ, GLfloat farZ)
Gets the perspective matrix similar to GLU gluPerspective() function.
void setVertexAttribPointer(QOpenGLShaderProgram *sp, GLuint attr_loc, size_t offset)
Makes a call to glVertexAttribPointer() and to glEnableVertexAttribArray() smartly.
constexpr GLenum getTypeEnum()
Converts the template type into an OpenGL type value like GL_INT, GL_FLOAT, Double.
_XGL_FUNC QMatrix4x4 getRotationMatrix(const QVector3D &v1, const QVector3D &v2)
Gets a 4x4 matrix from to vectors. When the 'v1' vector is mapped using the matrix,...
_MISC_FUNC int digits(double value)
Returns the amount of digits which are significant for the value. When the value is 12300....
#define _XGL_FUNC
Definition xgl/global.h:34