dust3d/application/sources/model_opengl_program.h

53 lines
2.1 KiB
C
Raw Normal View History

2022-09-19 13:30:03 +00:00
#ifndef DUST3D_APPLICATION_MODEL_OPENGL_PROGRAM_H_
#define DUST3D_APPLICATION_MODEL_OPENGL_PROGRAM_H_
#include <QMutex>
2022-09-20 12:48:22 +00:00
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
2022-09-23 17:33:55 +00:00
#include <QOpenGLTexture>
#include <memory>
2022-09-19 13:30:03 +00:00
class ModelOpenGLProgram : public QOpenGLShaderProgram {
2022-09-19 13:30:03 +00:00
public:
void load(bool isCoreProfile = false);
int getUniformLocationByName(const std::string& name);
bool isCoreProfile() const;
2022-09-24 13:31:49 +00:00
void bindMaps();
void releaseMaps();
void updateTextureImage(std::unique_ptr<QImage> image);
void updateNormalMapImage(std::unique_ptr<QImage> image);
void updateMetalnessRoughnessAmbientOcclusionMapImage(std::unique_ptr<QImage> image,
bool hasMetalnessMap = false,
bool hasRoughnessMap = false,
2022-09-24 13:31:49 +00:00
bool hasAmbientOcclusionMap = false);
2022-09-19 13:30:03 +00:00
private:
void addShaderFromResource(QOpenGLShader::ShaderType type, const char* resourceName);
void activeAndBindTexture(int location, QOpenGLTexture* texture);
2022-09-20 12:48:22 +00:00
2022-09-19 13:30:03 +00:00
bool m_isLoaded = false;
bool m_isCoreProfile = false;
2022-09-20 12:48:22 +00:00
std::map<std::string, int> m_uniformLocationMap;
2022-09-23 17:33:55 +00:00
std::unique_ptr<QOpenGLTexture> m_environmentIrradianceMap;
std::unique_ptr<QOpenGLTexture> m_environmentSpecularMap;
std::unique_ptr<std::vector<std::unique_ptr<QOpenGLTexture>>> m_environmentIrradianceMaps;
std::unique_ptr<std::vector<std::unique_ptr<QOpenGLTexture>>> m_environmentSpecularMaps;
2022-09-24 13:31:49 +00:00
std::unique_ptr<QImage> m_textureImage;
std::unique_ptr<QImage> m_normalMapImage;
std::unique_ptr<QImage> m_metalnessRoughnessAmbientOcclusionMapImage;
std::unique_ptr<QOpenGLTexture> m_texture;
std::unique_ptr<QOpenGLTexture> m_normalMap;
std::unique_ptr<QOpenGLTexture> m_metalnessRoughnessAmbientOcclusionMap;
bool m_hasMetalnessMap = false;
bool m_hasRoughnessMap = false;
bool m_hasAmbientOcclusionMap = false;
QMutex m_imageMutex;
bool m_imageIsDirty = false;
bool m_metalnessMapEnabled = false;
bool m_roughnessMapEnabled = false;
bool m_ambientOcclusionMapEnabled = false;
2022-09-19 13:30:03 +00:00
};
#endif