2022-09-19 13:30:03 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_MODEL_OPENGL_PROGRAM_H_
|
|
|
|
#define DUST3D_APPLICATION_MODEL_OPENGL_PROGRAM_H_
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QMutex>
|
2022-09-20 12:48:22 +00:00
|
|
|
#include <QOpenGLShader>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QOpenGLShaderProgram>
|
2022-09-23 17:33:55 +00:00
|
|
|
#include <QOpenGLTexture>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <memory>
|
2022-09-19 13:30:03 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
class ModelOpenGLProgram : public QOpenGLShaderProgram {
|
2022-09-19 13:30:03 +00:00
|
|
|
public:
|
2022-10-18 09:35:04 +00:00
|
|
|
void load(bool isCoreProfile = false);
|
|
|
|
int getUniformLocationByName(const std::string& name);
|
2022-09-23 11:03:35 +00:00
|
|
|
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,
|
2022-10-18 09:35:04 +00:00
|
|
|
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:
|
2022-10-18 09:35:04 +00:00
|
|
|
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
|