src/opengl/qglshaderprogram.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    95     This makes it possible to run most GLSL/ES shader programs
    95     This makes it possible to run most GLSL/ES shader programs
    96     on desktop systems.  The programmer should restrict themselves
    96     on desktop systems.  The programmer should restrict themselves
    97     to just features that are present in GLSL/ES, and avoid
    97     to just features that are present in GLSL/ES, and avoid
    98     standard variable names that only work on the desktop.
    98     standard variable names that only work on the desktop.
    99 
    99 
       
   100     If the \c{GL_ARB_ES2_compatibility} extension is present,
       
   101     then the above prefix is not added because the desktop OpenGL
       
   102     implementation supports precision qualifiers.
       
   103 
   100     \section1 Simple shader example
   104     \section1 Simple shader example
   101 
   105 
   102     \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 1
   106     \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 1
   103 
   107 
   104     With the above shader program active, we can draw a green triangle
   108     With the above shader program active, we can draw a green triangle
   392         if (headerLen > 0) {
   396         if (headerLen > 0) {
   393             src.append(source);
   397             src.append(source);
   394             srclen.append(GLint(headerLen));
   398             srclen.append(GLint(headerLen));
   395         }
   399         }
   396 #ifdef QGL_DEFINE_QUALIFIERS
   400 #ifdef QGL_DEFINE_QUALIFIERS
   397         src.append(qualifierDefines);
   401         if (!(QGLExtensions::glExtensions() & QGLExtensions::ES2Compatibility)) {
   398         srclen.append(GLint(sizeof(qualifierDefines) - 1));
   402             src.append(qualifierDefines);
       
   403             srclen.append(GLint(sizeof(qualifierDefines) - 1));
       
   404         }
   399 #endif
   405 #endif
   400 #ifdef QGL_REDEFINE_HIGHP
   406 #ifdef QGL_REDEFINE_HIGHP
   401         if (d->shaderType == Fragment) {
   407         if (d->shaderType == Fragment) {
   402             src.append(redefineHighp);
   408             src.append(redefineHighp);
   403             srclen.append(GLint(sizeof(redefineHighp) - 1));
   409             srclen.append(GLint(sizeof(redefineHighp) - 1));
  2119 void QGLShaderProgram::setUniformValue(int location, const QSize& size)
  2125 void QGLShaderProgram::setUniformValue(int location, const QSize& size)
  2120 {
  2126 {
  2121     Q_D(QGLShaderProgram);
  2127     Q_D(QGLShaderProgram);
  2122     Q_UNUSED(d);
  2128     Q_UNUSED(d);
  2123     if (location != -1) {
  2129     if (location != -1) {
  2124         GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.width())};
  2130         GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())};
  2125         glUniform2fv(location, 1, values);
  2131         glUniform2fv(location, 1, values);
  2126     }
  2132     }
  2127 }
  2133 }
  2128 
  2134 
  2129 /*!
  2135 /*!