summaryrefslogtreecommitdiffstats
path: root/doc/html/qaxserver-example-opengl.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/qaxserver-example-opengl.html')
-rw-r--r--doc/html/qaxserver-example-opengl.html206
1 files changed, 206 insertions, 0 deletions
diff --git a/doc/html/qaxserver-example-opengl.html b/doc/html/qaxserver-example-opengl.html
new file mode 100644
index 0000000..33d884e
--- /dev/null
+++ b/doc/html/qaxserver-example-opengl.html
@@ -0,0 +1,206 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/activeqt/examples/opengl/opengl.doc:33 -->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Qt' OpenGL widgets as an ActiveX (executable)</title>
+<style type="text/css"><!--
+fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+body { background: #ffffff; color: black; }
+--></style>
+</head>
+<body>
+
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+<tr bgcolor="#E5E5E5">
+<td valign=center>
+ <a href="index.html">
+<font color="#004faf">Home</font></a>
+ | <a href="classes.html">
+<font color="#004faf">All&nbsp;Classes</font></a>
+ | <a href="mainclasses.html">
+<font color="#004faf">Main&nbsp;Classes</font></a>
+ | <a href="annotated.html">
+<font color="#004faf">Annotated</font></a>
+ | <a href="groups.html">
+<font color="#004faf">Grouped&nbsp;Classes</font></a>
+ | <a href="functions.html">
+<font color="#004faf">Functions</font></a>
+</td>
+<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Qt' OpenGL widgets as an ActiveX (executable)</h1>
+
+
+
+The ActiveX control in this example uses the QGlWidget class in
+Qt to render an OpenGL scene in an ActiveX. The control exposes a few
+methods to change the scene. The example is based on the
+<a href="opengl-box-example.html">"box" example</a> from the standard
+Qt distribution.
+<p> The example demonstrates the use of the default factory and
+<a href="qaxfactory.html#isServer">QAxFactory::isServer</a>(), and the implementation of an additional COM
+interface using <a href="qaxbindable.html">QAxBindable</a> and <a href="qaxaggregated.html">QAxAggregated</a>. The server executable
+can run both as an ActiveX server and as a stand alone application.
+<p>
+
+The application uses the default factory as provided by the
+<a href="qaxfactory.html#QAXFACTORY_DEFAULT">QAXFACTORY_DEFAULT</a> macro to expose the <tt>GLBox</tt> widget as an ActiveX
+control.
+<pre> #include &lt;<a href="qaxfactory-h.html">qaxfactory.h</a>&gt;
+
+ QAXFACTORY_DEFAULT( GLBox,
+ "{5fd9c22e-ed45-43fa-ba13-1530bb6b03e0}",
+ "{33b051af-bb25-47cf-a390-5cfd2987d26a}",
+ "{8c996c29-eafa-46ac-a6f9-901951e765b5}",
+ "{2c3c183a-eeda-41a4-896e-3d9c12c3577d}",
+ "{83e16271-6480-45d5-aaf1-3f40b7661ae4}"
+ )
+</pre>The implementation of <tt>main</tt> initializes the <a href="qapplication.html">QApplication</a> object,
+and uses <a href="qaxfactory.html#isServer">QAxFactory::isServer</a>() to determine whether or not it is
+appropriate to create and show the application interface.
+<pre> /*
+ The main program is here.
+ */
+
+ int main( int argc, char **argv )
+ {
+ <a name="x2732"></a> QApplication::<a href="qapplication.html#setColorSpec">setColorSpec</a>( QApplication::CustomColor );
+ <a href="qapplication.html">QApplication</a> a(argc,argv);
+
+ if ( !QGLFormat::hasOpenGL() ) {
+ <a href="qapplication.html#qWarning">qWarning</a>( "This system has no OpenGL support. Exiting." );
+ return -1;
+ }
+
+ if ( !QAxFactory::isServer() ) {
+ GLObjectWindow w;
+ w.<a href="qwidget.html#resize">resize</a>( 400, 350 );
+ <a name="x2733"></a> a.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &amp;w );
+ w.<a href="qwidget.html#show">show</a>();
+ return a.<a href="qapplication.html#exec">exec</a>();
+ }
+ <a name="x2731"></a> return a.<a href="qapplication.html#exec">exec</a>();
+ }
+</pre>
+<p>
+
+The <tt>GLBox</tt> class inherits from both the <a href="qglwidget.html">QGLWidget</a> class to be able
+to render OpenGL, and from <a href="qaxbindable.html">QAxBindable</a>.
+<pre> #include &lt;<a href="qaxbindable-h.html">qaxbindable.h</a>&gt;
+
+ class GLBox : public <a href="qglwidget.html">QGLWidget</a>,
+ public QAxBindable
+ {
+ <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
+</pre>The class reimplements the <a href="qaxbindable.html#createAggregate">QAxBindable::createAggregate</a>() function from <a href="qaxbindable.html">QAxBindable</a>
+to return the pointer to a <a href="qaxaggregated.html">QAxAggregated</a> object.
+<pre> public:
+
+ GLBox( <a href="qwidget.html">QWidget</a>* parent, const char* name );
+ ~GLBox();
+
+ <a href="qaxaggregated.html">QAxAggregated</a> *createAggregate();
+
+ public slots:
+
+ void setXRotation( int degrees );
+</pre>The rest of the class declaration and the implementation of the OpenGL
+rendering is identical to the original "box" example.
+<p>
+
+The implementation file of the <tt>GLBox</tt> class includes the <tt>objsafe.h</tt>
+system header, in which the <tt>IObjectSafety</tt> COM interface is defined.
+<pre> #include &lt;objsafe.h&gt;
+</pre>A class <tt>ObjectSafetyImpl</tt> is declared using multiple inheritance
+to subclass the <a href="qaxaggregated.html">QAxAggregated</a> class, and to implement the IObjectSafety
+interface.
+<pre> class ObjectSafetyImpl : public <a href="qaxaggregated.html">QAxAggregated</a>,
+ public IObjectSafety
+ {
+ public:
+</pre>The class declares a default constructor, and implements the queryInterface
+function to support the IObjectSafety interface.
+<pre> ObjectSafetyImpl() {}
+
+ long queryInterface( const <a href="quuid.html">QUuid</a> &amp;iid, void **iface )
+ {
+ *iface = 0;
+ if ( iid == IID_IObjectSafety )
+ *iface = (IObjectSafety*)this;
+ else
+ return E_NOINTERFACE;
+
+ AddRef();
+ return S_OK;
+ }
+</pre>Since every COM interface inherits <tt>IUnknown</tt> the <tt>QAXAGG_IUNKNOWN</tt> macro
+is used to provide the default implementation of the <tt>IUnknown</tt> interface.
+The macro is defined to delegate all calls to <tt>QueryInterface</tt>, <tt>AddRef</tt>
+and <tt>Release</tt> to the interface returned by the controllingUnknown() function.
+<pre> QAXAGG_IUNKNOWN;
+</pre>The implementation of the <tt>IObjectSafety</tt> interface provides the caller
+with information about supported and enabled safety options, and returns
+<tt>S_OK</tt> for all calls to indicate that the ActiveX control is safe.
+<pre> HRESULT WINAPI GetInterfaceSafetyOptions( REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions )
+ {
+ *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER;
+ *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER;
+ return S_OK;
+ }
+ HRESULT WINAPI SetInterfaceSafetyOptions( REFIID riid, DWORD pdwSupportedOptions, DWORD pdwEnabledOptions )
+ {
+ return S_OK;
+ }
+ };
+</pre>The implementation of the <tt>createAggregate()</tt> function just returns a new
+<tt>ObjectSafetyImpl</tt> object.
+<pre> QAxAggregated *GLBox::createAggregate()
+ {
+ return new ObjectSafetyImpl();
+ }
+</pre>
+<p> To build the example you must first build the <a href="qaxserver.html">QAxServer</a> library. Then run qmake and your make tool in
+<tt>examples/wrapper</tt>.
+<p> <hr>
+<p> The <a href="qaxserver-demo-opengl.html">demonstration</a> requires your
+WebBrowser to support ActiveX controls, and scripting to be enabled.
+<p> In contrast to the other QAxServer examples Internet Explorer will not
+open a dialog box to ask the user whether or not the scripting of the GLBox
+control should be allowed (the exact browser behaviour depends on the security
+settings in the Internet Options dialog).
+<p>
+
+<pre> &lt;SCRIPT LANGUAGE=JavaScript&gt;
+ function setRot( form )
+ {
+ GLBox.setXRotation( form.XEdit.value );
+ GLBox.setYRotation( form.YEdit.value );
+ GLBox.setZRotation( form.ZEdit.value );
+ }
+ &lt;/SCRIPT&gt;
+
+ &lt;p&gt;
+ An OpenGL scene:&lt;br&gt;
+ &lt;object ID="GLBox" CLASSID="CLSID:5fd9c22e-ed45-43fa-ba13-1530bb6b03e0"
+ CODEBASE=http://www.trolltech.com/demos/openglax.cab&gt;
+ [Object not available! Did you forget to build and register the server?]
+ &lt;/object&gt;&lt;br&gt;
+
+ &lt;form&gt;
+ Rotate the scene:&lt;br&gt;
+ X:&lt;input type="edit" ID="XEdit" value="0"&gt;&lt;br&gt;
+ Y:&lt;input type="edit" name="YEdit" value="0"&gt;&lt;br&gt;
+ Z:&lt;input type="edit" name="ZEdit" value="0"&gt;&lt;br&gt;
+ &lt;input type="button" value="Set" onClick="setRot(this.form)"&gt;
+ &lt;/form&gt;
+</pre><p>See also <a href="qaxserver-examples.html">The QAxServer Examples</a>.
+
+<!-- eof -->
+<p><address><hr><div align=center>
+<table width=100% cellspacing=0 border=0><tr>
+<td>Copyright &copy; 2007
+<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
+<td align=right><div align=right>Qt 3.3.8</div>
+</table></div></address></body>
+</html>