tahoma2d/toonz/sources/include/stdfx/shadingcontext.h

103 lines
2.9 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef SHADINGCONTEXT_H
#define SHADINGCONTEXT_H
2016-04-14 22:15:09 +12:00
#include <memory>
2016-03-19 06:57:51 +13:00
// Glew include
#include <GL/glew.h>
// TnzCore includes
#include "traster.h"
// Qt includes
#include <QDateTime>
#include <QGLFramebufferObjectFormat>
#undef DVAPI
#undef DVVAR
#ifdef TNZSTDFX_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//=========================================================
// Forward declarations
class QObject;
class QGLShaderProgram;
class QDateTime;
//=========================================================
2016-06-15 18:43:10 +12:00
class DVAPI ShadingContext {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
enum Support { OK, NO_PIXEL_BUFFER, NO_SHADERS };
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ShadingContext();
~ShadingContext();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Returns the status of OpenGL shading support.
static Support support();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool isValid() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void makeCurrent();
void doneCurrent();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*!
Resizes the output buffer to the specified size. Requires that
the contex is made current before invocation. In case lx or ly are 0,
the context's output buffer is destroyed.
*/
void resize(int lx, int ly, const QGLFramebufferObjectFormat &fmt =
QGLFramebufferObjectFormat());
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QGLFramebufferObjectFormat format() const;
TDimension size() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Surrenders ownership of the supplied shader program to the shading
//! context.
void addShaderProgram(const QString &shaderName, QGLShaderProgram *program);
void addShaderProgram(const QString &shaderName, QGLShaderProgram *program,
const QDateTime &lastModified);
bool removeShaderProgram(const QString &shaderName);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QGLShaderProgram *shaderProgram(const QString &shaderName) const;
QDateTime lastModified(const QString &shaderName) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
std::pair<QGLShaderProgram *, QDateTime> shaderData(
const QString &shaderName) const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
GLuint loadTexture(const TRasterP &src, GLuint texUnit); //!< Loads a texture
//!and binds it to
//!the specified
//!texture unit.
//! \return The OpenGL texture id of the loaded texture. \param src
//! Loaded texture. \param texUnit Unit the texture will be bound to.
void unloadTexture(GLuint texId); //!< Releases the specified texture id.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Renders the active shader program to the specified raster.
void draw(const TRasterP &dst);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Performs transform feedback with the specified varying variables
void transformFeedback(int varyingsCount, const GLsizeiptr *varyingSizes,
GLvoid **bufs);
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
struct Imp;
std::unique_ptr<Imp> m_imp;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// Not copyable
ShadingContext(const ShadingContext &);
ShadingContext &operator=(const ShadingContext &);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // SHADINGCONTEXT_H