|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef SHADINGCONTEXT_H
|
|
Toshihiro Shimizu |
890ddd |
#define SHADINGCONTEXT_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
262a92 |
#include <memory></memory>
|
|
Shinya Kitaoka |
262a92 |
|
|
Toshihiro Shimizu |
890ddd |
// Glew include
|
|
Toshihiro Shimizu |
890ddd |
#include <gl glew.h=""></gl>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qdatetime></qdatetime>
|
|
Jeremy Bullock |
1ef2a2 |
#include <qopenglframebufferobjectformat></qopenglframebufferobjectformat>
|
|
Jeremy Bullock |
1ef2a2 |
#include <qopenglwidget></qopenglwidget>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZSTDFX_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class QObject;
|
|
Jeremy Bullock |
1ef2a2 |
class QOpenGLShaderProgram;
|
|
Toshihiro Shimizu |
890ddd |
class QDateTime;
|
|
shun_iwasawa |
339330 |
class QOffscreenSurface;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI ShadingContext {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
enum Support { OK, NO_PIXEL_BUFFER, NO_SHADERS };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
shun_iwasawa |
339330 |
ShadingContext(QOffscreenSurface *);
|
|
Shinya Kitaoka |
120a6e |
~ShadingContext();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Returns the status of OpenGL shading support.
|
|
Shinya Kitaoka |
120a6e |
static Support support();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isValid() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void makeCurrent();
|
|
Shinya Kitaoka |
120a6e |
void doneCurrent();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Resizes the output buffer to the specified size. Requires that
|
|
luz paz |
6454c4 |
the context is made current before invocation. In case lx or ly are 0,
|
|
Shinya Kitaoka |
120a6e |
the context's output buffer is destroyed.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Jeremy Bullock |
1ef2a2 |
void resize(int lx, int ly, const QOpenGLFramebufferObjectFormat &fmt =
|
|
Jeremy Bullock |
1ef2a2 |
QOpenGLFramebufferObjectFormat());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
QOpenGLFramebufferObjectFormat format() const;
|
|
Shinya Kitaoka |
120a6e |
TDimension size() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Surrenders ownership of the supplied shader program to the shading
|
|
Shinya Kitaoka |
120a6e |
//! context.
|
|
shun_iwasawa |
339330 |
void addShaderProgram(const QString &shaderName,
|
|
shun_iwasawa |
339330 |
QOpenGLShaderProgram *program);
|
|
shun_iwasawa |
339330 |
void addShaderProgram(const QString &shaderName,
|
|
shun_iwasawa |
339330 |
QOpenGLShaderProgram *program,
|
|
Shinya Kitaoka |
120a6e |
const QDateTime &lastModified);
|
|
Shinya Kitaoka |
120a6e |
bool removeShaderProgram(const QString &shaderName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
QOpenGLShaderProgram *shaderProgram(const QString &shaderName) const;
|
|
Shinya Kitaoka |
120a6e |
QDateTime lastModified(const QString &shaderName) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
std::pair<qopenglshaderprogram *,="" qdatetime=""> shaderData(</qopenglshaderprogram>
|
|
Shinya Kitaoka |
120a6e |
const QString &shaderName) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
GLuint loadTexture(const TRasterP &src, GLuint texUnit); //!< Loads a texture
|
|
Shinya Kitaoka |
38fd86 |
//! and binds it to
|
|
Shinya Kitaoka |
38fd86 |
//! the specified
|
|
Shinya Kitaoka |
38fd86 |
//! texture unit.
|
|
Shinya Kitaoka |
120a6e |
//! \return The OpenGL texture id of the loaded texture. \param src
|
|
Shinya Kitaoka |
120a6e |
//! Loaded texture. \param texUnit Unit the texture will be bound to.
|
|
Shinya Kitaoka |
120a6e |
void unloadTexture(GLuint texId); //!< Releases the specified texture id.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Renders the active shader program to the specified raster.
|
|
Shinya Kitaoka |
120a6e |
void draw(const TRasterP &dst);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Performs transform feedback with the specified varying variables
|
|
Shinya Kitaoka |
120a6e |
void transformFeedback(int varyingsCount, const GLsizeiptr *varyingSizes,
|
|
Shinya Kitaoka |
120a6e |
GLvoid **bufs);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
struct Imp;
|
|
Shinya Kitaoka |
120a6e |
std::unique_ptr<imp> m_imp;</imp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Not copyable
|
|
Shinya Kitaoka |
120a6e |
ShadingContext(const ShadingContext &);
|
|
Shinya Kitaoka |
120a6e |
ShadingContext &operator=(const ShadingContext &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
1ef2a2 |
class TQOpenGLWidget : public QOpenGLWidget {
|
|
Jeremy Bullock |
1ef2a2 |
public:
|
|
shun_iwasawa |
339330 |
TQOpenGLWidget();
|
|
shun_iwasawa |
339330 |
void initializeGL() override;
|
|
Jeremy Bullock |
1ef2a2 |
};
|
|
Jeremy Bullock |
1ef2a2 |
|
|
Shinya Kitaoka |
120a6e |
#endif // SHADINGCONTEXT_H
|