2021-09-03 16:56:57 +00:00
|
|
|
/*##############################################################################
|
|
|
|
## Author: Shaun Reed ##
|
2022-03-06 16:54:05 +00:00
|
|
|
## Legal: All Content (c) 2022 Shaun Reed, all rights reserved ##
|
2021-09-03 16:56:57 +00:00
|
|
|
## About: Skybox class using QtOpenGL ##
|
|
|
|
## ##
|
|
|
|
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
|
|
|
|
##############################################################################*/
|
|
|
|
#ifndef QTK_SKYBOX_H
|
|
|
|
#define QTK_SKYBOX_H
|
|
|
|
|
|
|
|
#include <QImage>
|
|
|
|
#include <QOpenGLBuffer>
|
2022-08-07 17:12:12 +00:00
|
|
|
#include <QOpenGLFunctions>
|
2021-09-03 16:56:57 +00:00
|
|
|
#include <QOpenGLShaderProgram>
|
|
|
|
#include <QOpenGLTexture>
|
|
|
|
#include <QOpenGLVertexArrayObject>
|
|
|
|
|
|
|
|
#include <camera3d.h>
|
|
|
|
#include <mesh.h>
|
2022-08-07 17:12:12 +00:00
|
|
|
#include <qtkapi.h>
|
2022-11-24 22:26:53 +00:00
|
|
|
#include <texture.h>
|
2022-08-07 17:12:12 +00:00
|
|
|
|
|
|
|
namespace Qtk {
|
2022-11-25 19:36:12 +00:00
|
|
|
/**
|
|
|
|
* Skybox object for rendering a skybox within a Scene.
|
|
|
|
* A skybox is typically implemented using a cube map texture centered around
|
|
|
|
* the camera and projected outwards in all directions.
|
|
|
|
*/
|
2022-08-07 17:12:12 +00:00
|
|
|
class QTKAPI Skybox : protected QOpenGLFunctions {
|
2022-11-24 22:26:53 +00:00
|
|
|
public:
|
2022-11-25 19:36:12 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Constructors / Destructors
|
|
|
|
************************************************************************/
|
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
// Delegate this constructor to use default skybox images
|
|
|
|
explicit Skybox(const std::string & name = "Skybox");
|
2022-11-25 19:36:12 +00:00
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
explicit Skybox(
|
|
|
|
QOpenGLTexture * cubeMap, const std::string & name = "Skybox");
|
2022-11-25 19:36:12 +00:00
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
Skybox(
|
|
|
|
const std::string & right, const std::string & top,
|
|
|
|
const std::string & front, const std::string & left,
|
|
|
|
const std::string & bottom, const std::string & back,
|
|
|
|
const std::string & name = "Skybox");
|
|
|
|
|
|
|
|
~Skybox() = default;
|
|
|
|
|
2022-11-25 19:36:12 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Public Methods
|
|
|
|
************************************************************************/
|
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
void draw();
|
|
|
|
|
|
|
|
private:
|
2022-11-25 19:36:12 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Private Methods
|
|
|
|
************************************************************************/
|
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
void init();
|
|
|
|
|
2022-11-25 19:36:12 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* Private Members
|
|
|
|
************************************************************************/
|
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
Vertices mVertices {};
|
|
|
|
Indices mIndices {};
|
|
|
|
|
|
|
|
QOpenGLShaderProgram mProgram;
|
|
|
|
QOpenGLVertexArrayObject mVAO;
|
|
|
|
QOpenGLBuffer mVBO;
|
|
|
|
Texture mTexture;
|
2022-08-07 17:12:12 +00:00
|
|
|
};
|
2022-11-24 22:26:53 +00:00
|
|
|
} // namespace Qtk
|
2021-09-03 16:56:57 +00:00
|
|
|
|
2022-11-24 22:26:53 +00:00
|
|
|
#endif // QTK_SKYBOX_H
|