<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- wince-opengl.qdoc --> <head> <title>Qt 4.6: Qt for Windows CE and OpenGL ES</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">Qt for Windows CE and OpenGL ES<br /><span class="subtitle"></span> </h1> <a name="introduction"></a> <h3>Introduction</h3> <p><a href="http://www.opengl.org">OpenGL</a> is an industry standard API for 2D/3D graphics. It provides a powerful, low-level interface between software and acceleration hardware, and it is operating system and window system independent. <a href="http://www.khronos.org/opengles">OpenGL ES</a> is a subset of the <a href="http://www.opengl.org">OpenGL</a> standard. Because it is designed for use with embedded systems, it has a smaller, more constrained API.</p> <p><a href="http://www.khronos.org/opengles/1_X">OpenGL ES version 1.x</a> is designed for fixed function hardware, while its successor <a href="http://www.khronos.org/opengles/2_X">OpenGL ES version 2.x</a> is designed for programmable hardware. It is worth noting that there is a significant difference between the two, and that they are not compatible with each other. OpenGL ES 1.x limits processing to a pre-defined set of fixed options for drawing and lighting objects. OpenGL 2.x has a significantly shorter graphics pipeline than 1.x. Instead of using function transformation and a fragment pipeline, 2.x uses the <a href="http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf">OpenGL ES Shading Language (GLSL ES)</a>. Instead of using the pre-defined functions, the programmer writes small shader programs telling the hardware in detail how to render each object.</p> <p>The <a href="qtopengl.html">QtOpenGL module</a> offers classes that make it easy to draw 3D graphics in GUI applications using OpenGL ES. Qt provides a plugin that integrates both OpenGL ES versions <a href="http://www.khronos.org/opengles/1_X">1.x</a> and <a href="http://www.khronos.org/opengles/2_X">2.x</a> with Qt for Embedded. However, Qt for Embedded can be adapted to a wide range of OpenGL versions.</p> <p>To translate <a href="qpainter.html">QPainter</a> operations into OpenGL ES calls (there are actually two subclasses, one for OpenGL/ES 1.1 and another for OpenGL/ES 2.0), Qt uses a subclass of <a href="qpaintengine.html">QPaintEngine</a>. This specialized paint engine can be used to improve 2D rendering performance on appropriate hardware. It can also overlay controls and decorations onto 3D scenes drawn using OpenGL.</p> <ul><li><a href="#introduction">Introduction</a></li> <li><a href="#using-opengl-es-with-qt">Using OpenGL ES with Qt</a></li> <li><a href="#using-opengl-with-qt-for-windows-ce">Using OpenGL with Qt for Windows CE</a></li> <ul><li><a href="#configure">Configure</a></li> <li><a href="#using-opengl-to-accelerate-normal-2d-painting">Using OpenGL to Accelerate Normal 2D Painting</a></li> </ul> </ul> <a name="using-opengl-es-with-qt"></a> <h3>Using OpenGL ES with Qt</h3> <p>To use OpenGL-enabled widgets in a Qt for Embedded application, all that is required is to subclass <a href="qglwidget.html">QGLWidget</a> and draw into instances of the subclass with standard OpenGL functions. The current implementation only supports OpenGL ES and 2D painting within a <a href="qglwidget.html">QGLWidget</a>. Using OpenGL ES to accelerate regular widgets as well as compositing top-level windows with OpenGL ES are not currently supported. These issues will be addressed in future versions of Qt.</p> <p><b>Note:</b> The OpenGL paint engine is not currently supported in regular widgets. However, any application that uses <a href="qgraphicsview.html">QGraphicsView</a> can set a <a href="qglwidget.html">QGLWidget</a> as the viewport and obtain access to the OpenGL paint engine that way:</p> <pre> QGraphicsView view(&scene); view.setViewport(new QGLWidget()); view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); view.setFrameStyle(0); view.showFullScreen();</pre> <p>It is recommended that the <a href="qgraphicsview.html#ViewportUpdateMode-enum">QGraphicsView::FullViewportUpdate</a> flag be set because the default double-buffered behavior of <a href="qglwidget.html">QGLWidget</a> does not support partial updates. It is also recommended that the window be shown full-screen because that usually has the best performance on current OpenGL ES implementations.</p> <p>Once a <a href="qgraphicsview.html">QGraphicsView</a> has been initialized as above, regular widgets can be added to the canvas using <a href="qgraphicsproxywidget.html">QGraphicsProxyWidget</a> if the application requires them.</p> <p><b>Note:</b> OpenGL ES 2.X does not support PBuffers, so <a href="qglpixelbuffer.html">QGLPixelBuffer</a> will not work. In this case, <a href="qglframebufferobject.html">QGLFramebufferObject</a> should be used instead. However, OpenGL ES 1.X does not support Framebuffer objects, with the exception of some OpenGL ES 1.X extensions. In this case, please use <a href="qglpixelbuffer.html">QGLPixelBuffer</a>.</p> <p><b>Note:</b> On most embedded hardware, the OpenGL implementation is actually <a href="http://www.khronos.org/opengles/1_X/">OpenGL/ES 1.1</a> or <a href="http://www.khronos.org/opengles/2_X/">OpenGL/ES 2.0</a>. When painting within a <a href="qglwidget.html#paintGL">QGLWidget::paintGL</a>() override, it is necessary to limit the application to only the features that are present in the OpenGL/ES implementation.</p> <a name="using-opengl-with-qt-for-windows-ce"></a> <h3>Using OpenGL with Qt for Windows CE</h3> <p>Qt for Windows CE uses EGL 1.1 to embed OpenGL ES windows within the Windows CE window manager.</p> <a name="configure"></a> <h4>Configure</h4> <p>To configure Qt for Windows Mobile 5.0 and OpenGL ES Common Lite support you can run <tt>configure</tt> like this:</p> <pre> configure -platform win32-msvc2005 -xplatform wincewm50pocket-msvc2005 -opengl-es-cl</pre> <p>OpenGL ES includes profiles for floating-point and fixed-point arithmetic. The floating point profile is called OpenGL ES CM (Common) and the fixed-point profile is called OpenGL ES CL (Common Lite).</p> <p>You can run <tt>configure</tt> with the <tt>-opengl-es-cm</tt> option for the Common profile or <tt>-opengl-es-cl</tt> for the Common Lite profile. In both cases, ensure that the <tt>lib</tt> and <tt>includes</tt> paths include the OpenGL ES headers and libararies from your SDK. The OpenGL ES lib should be called either <tt>libGLES_CM.lib</tt> for the Common profile or <tt>libGLES_CL.lib</tt> for the Common Lite profile.</p> <p>The distinction between the Common and Common Lite profiles is important, because the Common Lite profile has less functionality and only supports a fixed-point vertex format.</p> <p>To start programming with Qt and OpenGL ES on Windows CE, you can start with the <a href="opengl-hellogl-es.html">Hello GL ES Example</a>. This example shows how to use <a href="qglwidget.html">QGLWidget</a> and QGLPainter with OpenGL ES. It also provides some hints on how to port OpenGL code to OpenGL ES.</p> <a name="using-opengl-to-accelerate-normal-2d-painting"></a> <h4>Using OpenGL to Accelerate Normal 2D Painting</h4> <p>Qt provides QOpenGLPaintEngine, a subclass of <a href="qpaintengine.html">QPaintEngine</a> that translates <a href="qpainter.html">QPainter</a> operations into OpenGL calls. This is especially convenient for drawing text or <a href="qimage.html">QImage</a> objects in an OpenGL ES context. For further details, refer to the <a href="opengl-hellogl-es.html">Hello GL ES Example</a>.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>