<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qopenglshaderprogram.cpp --> <title>QOpenGLShader Class | Qt GUI 5.12.2</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QOpenGLShader</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.2 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-types">Public Types</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QOpenGLShader Class</h1> <!-- $$$QOpenGLShader-brief --> <p>The <a href="qopenglshader.html">QOpenGLShader</a> class allows OpenGL shaders to be compiled. <a href="#details">More...</a></p> <!-- @@@QOpenGLShader --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QOpenGLShader></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.0</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qobject.html">QObject</a></td></tr></table></div><ul> <li><a href="qopenglshader-members.html">List of all members, including inherited members</a></li> <li><a href="qopenglshader-obsolete.html">Obsolete members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#ShaderTypeBit-enum">ShaderType</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#ShaderTypeBit-enum">ShaderTypeBit</a></b> { Vertex, Fragment, Geometry, TessellationControl, TessellationEvaluation, Compute }</td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#QOpenGLShader">QOpenGLShader</a></b>(QOpenGLShader::ShaderType <i>type</i>, QObject *<i>parent</i> = nullptr)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#dtor.QOpenGLShader">~QOpenGLShader</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#compileSourceCode">compileSourceCode</a></b>(const char *<i>source</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#compileSourceCode-1">compileSourceCode</a></b>(const QByteArray &<i>source</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#compileSourceCode-2">compileSourceCode</a></b>(const QString &<i>source</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#compileSourceFile">compileSourceFile</a></b>(const QString &<i>fileName</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#isCompiled">isCompiled</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#log">log</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> GLuint </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#shaderId">shaderId</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QOpenGLShader::ShaderType </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#shaderType">shaderType</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#sourceCode">sourceCode</a></b>() const</td></tr> </table></div> <ul> <li class="fn">31 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li> </ul> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#hasOpenGLShaders">hasOpenGLShaders</a></b>(QOpenGLShader::ShaderType <i>type</i>, QOpenGLContext *<i>context</i> = nullptr)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qopenglshader.html#staticMetaObject-var">staticMetaObject</a></b></td></tr> </table></div> <ul> <li class="fn">9 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li> <li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li> <li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li> <li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li> </ul> <a name="details"></a> <!-- $$$QOpenGLShader-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qopenglshader.html">QOpenGLShader</a> class allows OpenGL shaders to be compiled.</p> <p>This class supports shaders written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES).</p> <p><a href="qopenglshader.html">QOpenGLShader</a> and <a href="qopenglshaderprogram.html">QOpenGLShaderProgram</a> shelter the programmer from the details of compiling and linking vertex and fragment shaders.</p> </div> <p><b>See also </b><a href="qopenglshaderprogram.html">QOpenGLShaderProgram</a>.</p> <!-- @@@QOpenGLShader --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$ShaderTypeBit$$$Vertex$$$Fragment$$$Geometry$$$TessellationControl$$$TessellationEvaluation$$$Compute --> <h3 class="flags" id="ShaderTypeBit-enum"><a name="ShaderTypeBit-enum"></a>enum QOpenGLShader::<span class="name">ShaderTypeBit</span><br/>flags QOpenGLShader::<span class="name">ShaderType</span></h3> <p>This enum specifies the type of <a href="qopenglshader.html">QOpenGLShader</a> that is being created.</p> <div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr> <tr><td class="topAlign"><code>QOpenGLShader::Vertex</code></td><td class="topAlign tblval"><code>0x0001</code></td><td class="topAlign">Vertex shader written in the OpenGL Shading Language (GLSL).</td></tr> <tr><td class="topAlign"><code>QOpenGLShader::Fragment</code></td><td class="topAlign tblval"><code>0x0002</code></td><td class="topAlign">Fragment shader written in the OpenGL Shading Language (GLSL).</td></tr> <tr><td class="topAlign"><code>QOpenGLShader::Geometry</code></td><td class="topAlign tblval"><code>0x0004</code></td><td class="topAlign">Geometry shaders written in the OpenGL Shading Language (GLSL) (requires OpenGL >= 3.2 or OpenGL ES >= 3.2).</td></tr> <tr><td class="topAlign"><code>QOpenGLShader::TessellationControl</code></td><td class="topAlign tblval"><code>0x0008</code></td><td class="topAlign">Tessellation control shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2).</td></tr> <tr><td class="topAlign"><code>QOpenGLShader::TessellationEvaluation</code></td><td class="topAlign tblval"><code>0x0010</code></td><td class="topAlign">Tessellation evaluation shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2).</td></tr> <tr><td class="topAlign"><code>QOpenGLShader::Compute</code></td><td class="topAlign tblval"><code>0x0020</code></td><td class="topAlign">Compute shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.3 or OpenGL ES >= 3.1).</td></tr> </table></div> <p>The ShaderType type is a typedef for <a href="../qtcore/qflags.html">QFlags</a><ShaderTypeBit>. It stores an OR combination of ShaderTypeBit values.</p> <!-- @@@ShaderTypeBit --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QOpenGLShader[overload1]$$$QOpenGLShaderQOpenGLShader::ShaderTypeQObject* --> <h3 class="fn" id="QOpenGLShader"><a name="QOpenGLShader"></a>QOpenGLShader::<span class="name">QOpenGLShader</span>(<span class="type"><a href="qopenglshader.html#ShaderTypeBit-enum">QOpenGLShader::ShaderType</a></span> <i>type</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3> <p>Constructs a new <a href="qopenglshader.html">QOpenGLShader</a> object of the specified <i>type</i> and attaches it to <i>parent</i>. If shader programs are not supported, <a href="qopenglshaderprogram.html#hasOpenGLShaderPrograms">QOpenGLShaderProgram::hasOpenGLShaderPrograms</a>() will return false.</p> <p>This constructor is normally followed by a call to <a href="qopenglshader.html#compileSourceCode">compileSourceCode</a>() or <a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <p>The shader will be associated with the current <a href="qopenglcontext.html">QOpenGLContext</a>.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceCode">compileSourceCode</a>() and <a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <!-- @@@QOpenGLShader --> <!-- $$$~QOpenGLShader[overload1]$$$~QOpenGLShader --> <h3 class="fn" id="dtor.QOpenGLShader"><a name="dtor.QOpenGLShader"></a><code>[virtual] </code>QOpenGLShader::<span class="name">~QOpenGLShader</span>()</h3> <p>Deletes this shader. If the shader has been attached to a <a href="qopenglshaderprogram.html">QOpenGLShaderProgram</a> object, then the actual shader will stay around until the <a href="qopenglshaderprogram.html">QOpenGLShaderProgram</a> is destroyed.</p> <!-- @@@~QOpenGLShader --> <!-- $$$compileSourceCode[overload1]$$$compileSourceCodeconstchar* --> <h3 class="fn" id="compileSourceCode"><a name="compileSourceCode"></a><span class="type">bool</span> QOpenGLShader::<span class="name">compileSourceCode</span>(const <span class="type">char</span> *<i>source</i>)</h3> <p>Sets the <i>source</i> code for this shader and compiles it. Returns <code>true</code> if the source was successfully compiled, false otherwise.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <!-- @@@compileSourceCode --> <!-- $$$compileSourceCode$$$compileSourceCodeconstQByteArray& --> <h3 class="fn" id="compileSourceCode-1"><a name="compileSourceCode-1"></a><span class="type">bool</span> QOpenGLShader::<span class="name">compileSourceCode</span>(const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &<i>source</i>)</h3> <p>This is an overloaded function.</p> <p>Sets the <i>source</i> code for this shader and compiles it. Returns <code>true</code> if the source was successfully compiled, false otherwise.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <!-- @@@compileSourceCode --> <!-- $$$compileSourceCode$$$compileSourceCodeconstQString& --> <h3 class="fn" id="compileSourceCode-2"><a name="compileSourceCode-2"></a><span class="type">bool</span> QOpenGLShader::<span class="name">compileSourceCode</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>source</i>)</h3> <p>This is an overloaded function.</p> <p>Sets the <i>source</i> code for this shader and compiles it. Returns <code>true</code> if the source was successfully compiled, false otherwise.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <!-- @@@compileSourceCode --> <!-- $$$compileSourceFile[overload1]$$$compileSourceFileconstQString& --> <h3 class="fn" id="compileSourceFile"><a name="compileSourceFile"></a><span class="type">bool</span> QOpenGLShader::<span class="name">compileSourceFile</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>fileName</i>)</h3> <p>Sets the source code for this shader to the contents of <i>fileName</i> and compiles it. Returns <code>true</code> if the file could be opened and the source compiled, false otherwise.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceCode">compileSourceCode</a>().</p> <!-- @@@compileSourceFile --> <!-- $$$hasOpenGLShaders[overload1]$$$hasOpenGLShadersQOpenGLShader::ShaderTypeQOpenGLContext* --> <h3 class="fn" id="hasOpenGLShaders"><a name="hasOpenGLShaders"></a><code>[static] </code><span class="type">bool</span> QOpenGLShader::<span class="name">hasOpenGLShaders</span>(<span class="type"><a href="qopenglshader.html#ShaderTypeBit-enum">QOpenGLShader::ShaderType</a></span> <i>type</i>, <span class="type"><a href="qopenglcontext.html">QOpenGLContext</a></span> *<i>context</i> = nullptr)</h3> <p>Returns <code>true</code> if shader programs of type <i>type</i> are supported on this system; false otherwise.</p> <p>The <i>context</i> is used to resolve the GLSL extensions. If <i>context</i> is null, then <a href="qopenglcontext.html#currentContext">QOpenGLContext::currentContext</a>() is used.</p> <!-- @@@hasOpenGLShaders --> <!-- $$$isCompiled[overload1]$$$isCompiled --> <h3 class="fn" id="isCompiled"><a name="isCompiled"></a><span class="type">bool</span> QOpenGLShader::<span class="name">isCompiled</span>() const</h3> <p>Returns <code>true</code> if this shader has been compiled; false otherwise.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceCode">compileSourceCode</a>() and <a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <!-- @@@isCompiled --> <!-- $$$log[overload1]$$$log --> <h3 class="fn" id="log"><a name="log"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QOpenGLShader::<span class="name">log</span>() const</h3> <p>Returns the errors and warnings that occurred during the last compile.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceCode">compileSourceCode</a>() and <a href="qopenglshader.html#compileSourceFile">compileSourceFile</a>().</p> <!-- @@@log --> <!-- $$$shaderId[overload1]$$$shaderId --> <h3 class="fn" id="shaderId"><a name="shaderId"></a><span class="type">GLuint</span> QOpenGLShader::<span class="name">shaderId</span>() const</h3> <p>Returns the OpenGL identifier associated with this shader.</p> <p><b>See also </b><a href="qopenglshaderprogram.html#programId">QOpenGLShaderProgram::programId</a>().</p> <!-- @@@shaderId --> <!-- $$$shaderType[overload1]$$$shaderType --> <h3 class="fn" id="shaderType"><a name="shaderType"></a><span class="type"><a href="qopenglshader.html#ShaderTypeBit-enum">QOpenGLShader::ShaderType</a></span> QOpenGLShader::<span class="name">shaderType</span>() const</h3> <p>Returns the type of this shader.</p> <!-- @@@shaderType --> <!-- $$$sourceCode[overload1]$$$sourceCode --> <h3 class="fn" id="sourceCode"><a name="sourceCode"></a><span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> QOpenGLShader::<span class="name">sourceCode</span>() const</h3> <p>Returns the source code for this shader.</p> <p><b>See also </b><a href="qopenglshader.html#compileSourceCode">compileSourceCode</a>().</p> <!-- @@@sourceCode --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>