|
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>
|
|
Toshihiro Shimizu |
890ddd |
#include <qglframebufferobjectformat></qglframebufferobjectformat>
|
|
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;
|
|
Toshihiro Shimizu |
890ddd |
class QGLShaderProgram;
|
|
Toshihiro Shimizu |
890ddd |
class QDateTime;
|
|
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:
|
|
Shinya Kitaoka |
120a6e |
ShadingContext();
|
|
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
|
|
Shinya Kitaoka |
120a6e |
the contex 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 |
*/
|
|
Shinya Kitaoka |
120a6e |
void resize(int lx, int ly, const QGLFramebufferObjectFormat &fmt =
|
|
Shinya Kitaoka |
120a6e |
QGLFramebufferObjectFormat());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QGLFramebufferObjectFormat 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.
|
|
Shinya Kitaoka |
120a6e |
void addShaderProgram(const QString &shaderName, QGLShaderProgram *program);
|
|
Shinya Kitaoka |
120a6e |
void addShaderProgram(const QString &shaderName, QGLShaderProgram *program,
|
|
Shinya Kitaoka |
120a6e |
const QDateTime &lastModified);
|
|
Shinya Kitaoka |
120a6e |
bool removeShaderProgram(const QString &shaderName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QGLShaderProgram *shaderProgram(const QString &shaderName) const;
|
|
Shinya Kitaoka |
120a6e |
QDateTime lastModified(const QString &shaderName) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<qglshaderprogram *,="" qdatetime=""> shaderData(</qglshaderprogram>
|
|
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 |
|
|
Shinya Kitaoka |
120a6e |
#endif // SHADINGCONTEXT_H
|