Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 2147

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qwglnativecontext.qdoc -->
  <title>QWGLNativeContext Class | Qt Platform Headers 5.9</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.9</td><td ><a href="qtplatformheaders-index.html">Qt Platform Headers</a></td><td ><a href="qtplatformheaders-module.html">C++ Classes</a></td><td >QWGLNativeContext</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</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-functions">Public Functions</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">QWGLNativeContext Class</h1>
<!-- $$$QWGLNativeContext-brief -->
<p>A class encapsulating a WGL context on Windows with desktop OpenGL (opengl32.dll) <a href="#details">More...</a></p>
<!-- @@@QWGLNativeContext -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QWGLNativeContext&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.4</td></tr></table></div><ul>
<li><a href="qwglnativecontext-members.html">List of all members, including inherited members</a></li>
</ul>
<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="qwglnativecontext.html#QWGLNativeContext">QWGLNativeContext</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qwglnativecontext.html#QWGLNativeContext-1">QWGLNativeContext</a></b>(HGLRC <i>ctx</i>, HWND <i>wnd</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> HGLRC </td><td class="memItemRight bottomAlign"><b><a href="qwglnativecontext.html#context">context</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> HWND </td><td class="memItemRight bottomAlign"><b><a href="qwglnativecontext.html#window">window</a></b>() const</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QWGLNativeContext-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>A class encapsulating a WGL context on Windows with desktop OpenGL (opengl32.dll)</p>
<p><b>Note: </b>There is no binary compatibility guarantee for this class, meaning that an application using it is only guaranteed to work with the Qt version it was developed against.</p><p><a href="qwglnativecontext.html">QWGLNativeContext</a> is a value class that can be passed to <a href="../qtgui/qopenglcontext.html#setNativeHandle">QOpenGLContext::setNativeHandle</a>(). When creating a <a href="../qtgui/qopenglcontext.html">QOpenGLContext</a> with the native handle set, no new context will get created. Instead, the provided handles are used, without taking ownership. This allows wrapping a context created by an external framework or rendering engine. The typical usage will be similar to the following snippet:</p>
<pre class="cpp">

  <span class="preprocessor">#include &lt;QtPlatformSupport/QWGLNativeContext&gt;</span>
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>create and retrieve the WGL context and the corresponding window<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="../qtgui/qopenglcontext.html">QOpenGLContext</a></span> <span class="operator">*</span>context <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtgui/qopenglcontext.html">QOpenGLContext</a></span>;
  <span class="type"><a href="qwglnativecontext.html#QWGLNativeContext">QWGLNativeContext</a></span> nativeContext(hglrc<span class="operator">,</span> hwnd);
  context<span class="operator">-</span><span class="operator">&gt;</span>setNativeHandle(<span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span><span class="operator">::</span>fromValue(nativeContext));
  context<span class="operator">-</span><span class="operator">&gt;</span>create();
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

</pre>
<p>The window is needed because the its pixel format will be queried. When the adoption is successful, <a href="../qtgui/qopenglcontext.html#format">QOpenGLContext::format</a>() will return a <a href="../qtgui/qsurfaceformat.html">QSurfaceFormat</a> describing this pixel format.</p>
<p>It is recommended to restrict the usage of QOpenGLContexts created this way. Various platform-specific behavior and issues may prevent such contexts to be made current with windows (surfaces) created by Qt due to non-matching pixel formats for example. A potentially safer solution is to use the wrapped context only to set up sharing and perform Qt-based rendering offscreen, using a separate, dedicated <a href="../qtgui/qopenglcontext.html">QOpenGLContext</a>. The resulting textures are then accessible in the foreign context too.</p>
<pre class="cpp">

  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>like above<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="../qtgui/qopenglcontext.html">QOpenGLContext</a></span> <span class="operator">*</span>qtcontext <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtgui/qopenglcontext.html">QOpenGLContext</a></span>;
  qtcontext<span class="operator">-</span><span class="operator">&gt;</span>setShareContext(context);
  qtcontext<span class="operator">-</span><span class="operator">&gt;</span>setFormat(context<span class="operator">-</span><span class="operator">&gt;</span>format());
  qtcontext<span class="operator">-</span><span class="operator">&gt;</span>create();
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>use qtcontext <span class="keyword">for</span> rendering with <span class="type"><a href="../qtcore/qt.html">Qt</a></span><span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

</pre>
<p>In addition to being used with <a href="../qtgui/qopenglcontext.html#setNativeHandle">QOpenGLContext::setNativeHandle</a>(), this class is used also to retrieve the native context handle, that is, a HGLRC value, from a <a href="../qtgui/qopenglcontext.html">QOpenGLContext</a>. Calling <a href="../qtgui/qopenglcontext.html#nativeHandle">QOpenGLContext::nativeHandle</a>() returns a <a href="../qtcore/qvariant.html">QVariant</a> which, on Windows with opengl32.dll at least, will contain a <a href="qwglnativecontext.html">QWGLNativeContext</a>:</p>
<pre class="cpp">

  <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> nativeHandle <span class="operator">=</span> context<span class="operator">-</span><span class="operator">&gt;</span>nativeHandle();
  <span class="keyword">if</span> (<span class="operator">!</span>nativeHandle<span class="operator">.</span>isNull() <span class="operator">&amp;</span><span class="operator">&amp;</span> nativeHandle<span class="operator">.</span>canConvert<span class="operator">&lt;</span><span class="type"><a href="qwglnativecontext.html#QWGLNativeContext">QWGLNativeContext</a></span><span class="operator">&gt;</span>()) {
      <span class="type"><a href="qwglnativecontext.html#QWGLNativeContext">QWGLNativeContext</a></span> nativeContext <span class="operator">=</span> nativeHandle<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qwglnativecontext.html#QWGLNativeContext">QWGLNativeContext</a></span><span class="operator">&gt;</span>();
      HGLRC hglrc <span class="operator">=</span> nativeContext<span class="operator">.</span>context();
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  }

</pre>
</div>
<p><b>See also </b><a href="../qtgui/qopenglcontext.html#setNativeHandle">QOpenGLContext::setNativeHandle</a>() and <a href="../qtgui/qopenglcontext.html#nativeHandle">QOpenGLContext::nativeHandle</a>().</p>
<!-- @@@QWGLNativeContext -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QWGLNativeContext[overload1]$$$QWGLNativeContext -->
<h3 class="fn" id="QWGLNativeContext"><a name="QWGLNativeContext"></a>QWGLNativeContext::<span class="name">QWGLNativeContext</span>()</h3>
<p>Construct a new instance with no handles.</p>
<!-- @@@QWGLNativeContext -->
<!-- $$$QWGLNativeContext$$$QWGLNativeContextHGLRCHWND -->
<h3 class="fn" id="QWGLNativeContext-1"><a name="QWGLNativeContext-1"></a>QWGLNativeContext::<span class="name">QWGLNativeContext</span>(<span class="type">HGLRC</span> <i>ctx</i>, <span class="type">HWND</span> <i>wnd</i>)</h3>
<p>Constructs a new instance with the provided <i>ctx</i> context handle and <i>wnd</i> window handle.</p>
<p><b>Note: </b>The window specified by <i>wnd</i> must have its pixel format set to a format compatible with the context's. If no SetPixelFormat() call was made on any device context belonging to the window, adopting the context will fail.</p><!-- @@@QWGLNativeContext -->
<!-- $$$context[overload1]$$$context -->
<h3 class="fn" id="context"><a name="context"></a><span class="type">HGLRC</span> QWGLNativeContext::<span class="name">context</span>() const</h3>
<p>Returns the WGL context.</p>
<!-- @@@context -->
<!-- $$$window[overload1]$$$window -->
<h3 class="fn" id="window"><a name="window"></a><span class="type">HWND</span> QWGLNativeContext::<span class="name">window</span>() const</h3>
<p><b>Note: </b>The window handle is not available when the <a href="qwglnativecontext.html">QWGLNativeContext</a> is queried from a regular, non-adopted <a href="../qtgui/qopenglcontext.html">QOpenGLContext</a> using <a href="../qtgui/qopenglcontext.html#nativeHandle">QOpenGLContext::nativeHandle</a>(). This is because the <i>windows</i> platform plugin creates WGL contexts using a dummy window that is not available afterwards. Instead, the native window handle (HWND) is queriable from a <a href="../qtgui/qwindow.html">QWindow</a> via <a href="../qtgui/qplatformnativeinterface.html#nativeResourceForWindow">QPlatformNativeInterface::nativeResourceForWindow</a>() using the <i>&quot;handle&quot;</i> resource key. Note however that the window will not have its pixel format set until it is first associated with a context via <a href="../qtgui/qopenglcontext.html#makeCurrent">QOpenGLContext::makeCurrent</a>().</p><p>Returns handle for the window for which the context was created.</p>
<!-- @@@window -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 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>