src/opengl/qglshaderprogram.h
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    52 
    52 
    53 QT_BEGIN_NAMESPACE
    53 QT_BEGIN_NAMESPACE
    54 
    54 
    55 QT_MODULE(OpenGL)
    55 QT_MODULE(OpenGL)
    56 
    56 
    57 #if !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
    57 #if !defined(QT_OPENGL_ES_1)
    58 
    58 
    59 class QGLShaderProgram;
    59 class QGLShaderProgram;
    60 class QGLShaderPrivate;
    60 class QGLShaderPrivate;
    61 
    61 
    62 class Q_OPENGL_EXPORT QGLShader : public QObject
    62 class Q_OPENGL_EXPORT QGLShader : public QObject
    64     Q_OBJECT
    64     Q_OBJECT
    65 public:
    65 public:
    66     enum ShaderTypeBit
    66     enum ShaderTypeBit
    67     {
    67     {
    68         Vertex          = 0x0001,
    68         Vertex          = 0x0001,
    69         Fragment        = 0x0002
    69         Fragment        = 0x0002,
       
    70         Geometry        = 0x0004
    70     };
    71     };
    71     Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)
    72     Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)
    72 
    73 
    73     explicit QGLShader(QGLShader::ShaderType type, QObject *parent = 0);
    74     explicit QGLShader(QGLShader::ShaderType type, QObject *parent = 0);
    74     QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent = 0);
    75     QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent = 0);
    86     bool isCompiled() const;
    87     bool isCompiled() const;
    87     QString log() const;
    88     QString log() const;
    88 
    89 
    89     GLuint shaderId() const;
    90     GLuint shaderId() const;
    90 
    91 
       
    92     static bool hasOpenGLShaders(ShaderType type, const QGLContext *context = 0);
       
    93 
    91 private:
    94 private:
    92     friend class QGLShaderProgram;
    95     friend class QGLShaderProgram;
    93 
    96 
    94     Q_DISABLE_COPY(QGLShader)
    97     Q_DISABLE_COPY(QGLShader)
    95     Q_DECLARE_PRIVATE(QGLShader)
    98     Q_DECLARE_PRIVATE(QGLShader)
    97 
   100 
    98 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType)
   101 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType)
    99 
   102 
   100 
   103 
   101 class QGLShaderProgramPrivate;
   104 class QGLShaderProgramPrivate;
       
   105 
       
   106 #ifndef GL_EXT_geometry_shader4
       
   107 #  define GL_LINES_ADJACENCY_EXT 0xA
       
   108 #  define GL_LINE_STRIP_ADJACENCY_EXT 0xB
       
   109 #  define GL_TRIANGLES_ADJACENCY_EXT 0xC
       
   110 #  define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD
       
   111 #endif
       
   112 
   102 
   113 
   103 class Q_OPENGL_EXPORT QGLShaderProgram : public QObject
   114 class Q_OPENGL_EXPORT QGLShaderProgram : public QObject
   104 {
   115 {
   105     Q_OBJECT
   116     Q_OBJECT
   106 public:
   117 public:
   125 
   136 
   126     bool bind();
   137     bool bind();
   127     void release();
   138     void release();
   128 
   139 
   129     GLuint programId() const;
   140     GLuint programId() const;
       
   141 
       
   142     int maxGeometryOutputVertices() const;
       
   143 
       
   144     void setGeometryOutputVertexCount(int count);
       
   145     int geometryOutputVertexCount() const;
       
   146 
       
   147     void setGeometryInputType(GLenum inputType);
       
   148     GLenum geometryInputType() const;
       
   149 
       
   150     void setGeometryOutputType(GLenum outputType);
       
   151     GLenum geometryOutputType() const;
   130 
   152 
   131     void bindAttributeLocation(const char *name, int location);
   153     void bindAttributeLocation(const char *name, int location);
   132     void bindAttributeLocation(const QByteArray& name, int location);
   154     void bindAttributeLocation(const QByteArray& name, int location);
   133     void bindAttributeLocation(const QString& name, int location);
   155     void bindAttributeLocation(const QString& name, int location);
   134 
   156 
   163     void setAttributeArray
   185     void setAttributeArray
   164         (int location, const QVector3D *values, int stride = 0);
   186         (int location, const QVector3D *values, int stride = 0);
   165     void setAttributeArray
   187     void setAttributeArray
   166         (int location, const QVector4D *values, int stride = 0);
   188         (int location, const QVector4D *values, int stride = 0);
   167     void setAttributeArray
   189     void setAttributeArray
       
   190         (int location, GLenum type, const void *values, int tupleSize, int stride = 0);
       
   191     void setAttributeArray
   168         (const char *name, const GLfloat *values, int tupleSize, int stride = 0);
   192         (const char *name, const GLfloat *values, int tupleSize, int stride = 0);
   169     void setAttributeArray
   193     void setAttributeArray
   170         (const char *name, const QVector2D *values, int stride = 0);
   194         (const char *name, const QVector2D *values, int stride = 0);
   171     void setAttributeArray
   195     void setAttributeArray
   172         (const char *name, const QVector3D *values, int stride = 0);
   196         (const char *name, const QVector3D *values, int stride = 0);
   173     void setAttributeArray
   197     void setAttributeArray
   174         (const char *name, const QVector4D *values, int stride = 0);
   198         (const char *name, const QVector4D *values, int stride = 0);
       
   199     void setAttributeArray
       
   200         (const char *name, GLenum type, const void *values, int tupleSize, int stride = 0);
       
   201 
       
   202     void setAttributeBuffer
       
   203         (int location, GLenum type, int offset, int tupleSize, int stride = 0);
       
   204     void setAttributeBuffer
       
   205         (const char *name, GLenum type, int offset, int tupleSize, int stride = 0);
       
   206 
       
   207 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
       
   208     void setAttributeArray
       
   209         (int location, QMacCompatGLenum type, const void *values, int tupleSize, int stride = 0);
       
   210     void setAttributeArray
       
   211         (const char *name, QMacCompatGLenum type, const void *values, int tupleSize, int stride = 0);
       
   212     void setAttributeBuffer
       
   213         (int location, QMacCompatGLenum type, int offset, int tupleSize, int stride = 0);
       
   214     void setAttributeBuffer
       
   215         (const char *name, QMacCompatGLenum type, int offset, int tupleSize, int stride = 0);
       
   216 #endif
   175 
   217 
   176     void enableAttributeArray(int location);
   218     void enableAttributeArray(int location);
   177     void enableAttributeArray(const char *name);
   219     void enableAttributeArray(const char *name);
   178     void disableAttributeArray(int location);
   220     void disableAttributeArray(int location);
   179     void disableAttributeArray(const char *name);
   221     void disableAttributeArray(const char *name);
   214     void setUniformValue(int location, const QMatrix3x3& value);
   256     void setUniformValue(int location, const QMatrix3x3& value);
   215     void setUniformValue(int location, const QMatrix3x4& value);
   257     void setUniformValue(int location, const QMatrix3x4& value);
   216     void setUniformValue(int location, const QMatrix4x2& value);
   258     void setUniformValue(int location, const QMatrix4x2& value);
   217     void setUniformValue(int location, const QMatrix4x3& value);
   259     void setUniformValue(int location, const QMatrix4x3& value);
   218     void setUniformValue(int location, const QMatrix4x4& value);
   260     void setUniformValue(int location, const QMatrix4x4& value);
       
   261     void setUniformValue(int location, const GLfloat value[2][2]);
       
   262     void setUniformValue(int location, const GLfloat value[3][3]);
   219     void setUniformValue(int location, const GLfloat value[4][4]);
   263     void setUniformValue(int location, const GLfloat value[4][4]);
   220     void setUniformValue(int location, const QTransform& value);
   264     void setUniformValue(int location, const QTransform& value);
   221 
   265 
   222     void setUniformValue(const char *name, GLfloat value);
   266     void setUniformValue(const char *name, GLfloat value);
   223     void setUniformValue(const char *name, GLint value);
   267     void setUniformValue(const char *name, GLint value);
   240     void setUniformValue(const char *name, const QMatrix3x3& value);
   284     void setUniformValue(const char *name, const QMatrix3x3& value);
   241     void setUniformValue(const char *name, const QMatrix3x4& value);
   285     void setUniformValue(const char *name, const QMatrix3x4& value);
   242     void setUniformValue(const char *name, const QMatrix4x2& value);
   286     void setUniformValue(const char *name, const QMatrix4x2& value);
   243     void setUniformValue(const char *name, const QMatrix4x3& value);
   287     void setUniformValue(const char *name, const QMatrix4x3& value);
   244     void setUniformValue(const char *name, const QMatrix4x4& value);
   288     void setUniformValue(const char *name, const QMatrix4x4& value);
       
   289     void setUniformValue(const char *name, const GLfloat value[2][2]);
       
   290     void setUniformValue(const char *name, const GLfloat value[3][3]);
   245     void setUniformValue(const char *name, const GLfloat value[4][4]);
   291     void setUniformValue(const char *name, const GLfloat value[4][4]);
   246     void setUniformValue(const char *name, const QTransform& value);
   292     void setUniformValue(const char *name, const QTransform& value);
   247 
   293 
   248     void setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize);
   294     void setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize);
   249     void setUniformValueArray(int location, const GLint *values, int count);
   295     void setUniformValueArray(int location, const GLint *values, int count);