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
4#include <QImage>
5#include <QOpenGLFunctions>
6#include <QOpenGLShaderProgram>
7#include <xgl/Types.h>
8#include <xgl/global.h>
9
10namespace sf::xgl
11{
12
13// Forward declaration.
14class ShaderProgram;
15
16// Forward declaration.
17class Color;
18
36_XGL_FUNC QMatrix4x4 getPerspectiveMatrix(float fov_y, float aspect, float near_z, float far_z);
40_XGL_FUNC matrix4x4f getPerspectiveMatrixF(GLfloat fovY, GLfloat aspect, GLfloat nearZ, GLfloat farZ);
41
47_XGL_FUNC std::pair<GLsizei, std::string_view> getTypeInfo(GLenum type);
48
54template<typename T>
55constexpr GLenum getTypeEnum();
56
66template<size_t N = 3, typename T = GLfloat>
67std::array<T, N> array(const QVector3D vect, T value = 1);
68
76_XGL_FUNC QMatrix4x4 getRotationMatrix(const QVector3D& v1, const QVector3D& v2);
77
83_XGL_FUNC QImage getTransparentImage(const QImage& src_image, int alpha);
84
93template<typename VertexType, typename FieldType>
94void setVertexAttribPointer(QOpenGLShaderProgram* sp, GLuint attr_loc, size_t offset);
95
99_XGL_FUNC bool checkDrawMode(GLenum mode, size_t vertice_count, const std::string& src);
100
101}// namespace sf::xgl
102
103// Include all inlined functions and template implementations.
104#include <xgl/utils.hpp>
Definition DemoRenderer.h:6
_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 type enumerate.
std::array< GLfloat, 16 > matrix4x4f
Type which correspond 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 needed vertices are sufficient 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() in a smart way.
std::array< T, N > array(const QVector3D vect, T value=1)
Template function to gets a 'std::array' from a Vector3D. This function is to pass a 3D vector where ...
constexpr GLenum getTypeEnum()
Converts the template type into a 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 the 'v2' vector is...
#define _XGL_FUNC
Definition xgl/global.h:34