|
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 |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI ShadingContext
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
enum Support {
|
|
Toshihiro Shimizu |
890ddd |
OK,
|
|
Toshihiro Shimizu |
890ddd |
NO_PIXEL_BUFFER,
|
|
Toshihiro Shimizu |
890ddd |
NO_SHADERS
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ShadingContext();
|
|
Toshihiro Shimizu |
890ddd |
~ShadingContext();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns the status of OpenGL shading support.
|
|
Toshihiro Shimizu |
890ddd |
static Support support();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isValid() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void makeCurrent();
|
|
Toshihiro Shimizu |
890ddd |
void doneCurrent();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
Resizes the output buffer to the specified size. Requires that
|
|
Toshihiro Shimizu |
890ddd |
the contex is made current before invocation. In case lx or ly are 0,
|
|
Toshihiro Shimizu |
890ddd |
the context's output buffer is destroyed.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void resize(int lx, int ly,
|
|
Toshihiro Shimizu |
890ddd |
const QGLFramebufferObjectFormat &fmt = QGLFramebufferObjectFormat());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QGLFramebufferObjectFormat format() const;
|
|
Toshihiro Shimizu |
890ddd |
TDimension size() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Surrenders ownership of the supplied shader program to the shading context.
|
|
Toshihiro Shimizu |
890ddd |
void addShaderProgram(const QString &shaderName, QGLShaderProgram *program);
|
|
Toshihiro Shimizu |
890ddd |
void addShaderProgram(const QString &shaderName, QGLShaderProgram *program,
|
|
Toshihiro Shimizu |
890ddd |
const QDateTime &lastModified);
|
|
Toshihiro Shimizu |
890ddd |
bool removeShaderProgram(const QString &shaderName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QGLShaderProgram *shaderProgram(const QString &shaderName) const;
|
|
Toshihiro Shimizu |
890ddd |
QDateTime lastModified(const QString &shaderName) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::pair<qglshaderprogram *,="" qdatetime=""> shaderData(const QString &shaderName) const;</qglshaderprogram>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
GLuint loadTexture(const TRasterP &src, GLuint texUnit); //!< Loads a texture and binds it to the specified texture unit.
|
|
Toshihiro Shimizu |
890ddd |
//! \return The OpenGL texture id of the loaded texture. \param src Loaded texture. \param texUnit Unit the texture will be bound to.
|
|
Toshihiro Shimizu |
890ddd |
void unloadTexture(GLuint texId); //!< Releases the specified texture id.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Renders the active shader program to the specified raster.
|
|
Toshihiro Shimizu |
890ddd |
void draw(const TRasterP &dst);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Performs transform feedback with the specified varying variables
|
|
Toshihiro Shimizu |
890ddd |
void transformFeedback(int varyingsCount, const GLsizeiptr *varyingSizes,
|
|
Toshihiro Shimizu |
890ddd |
GLvoid **bufs);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
struct Imp;
|
|
Shinya Kitaoka |
262a92 |
std::unique_ptr<imp> m_imp;</imp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Not copyable
|
|
Toshihiro Shimizu |
890ddd |
ShadingContext(const ShadingContext &);
|
|
Toshihiro Shimizu |
890ddd |
ShadingContext &operator=(const ShadingContext &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // SHADINGCONTEXT_H
|