1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the documentation of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** GNU General Public License Usage
29 ** Alternatively, this file may be used under the terms of the GNU
30 ** General Public License version 3.0 as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL included in the
32 ** packaging of this file. Please review the following information to
33 ** ensure the GNU General Public License version 3.0 requirements will be
34 ** met: http://www.gnu.org/copyleft/gpl.html.
36 ** If you have questions regarding the use of this file, please contact
37 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
43 \page qaxserver-demo-opengl.html
45 \title OpenGL in an HTML page
48 <SCRIPT LANGUAGE="JavaScript">
49 function setRot( form )
51 GLBox.setXRotation( form.XEdit.value );
52 GLBox.setYRotation( form.YEdit.value );
53 GLBox.setZRotation( form.ZEdit.value );
58 An OpenGL scene:<br />
59 <object ID="GLBox" CLASSID="CLSID:5fd9c22e-ed45-43fa-ba13-1530bb6b03e0"
60 CODEBASE="http://qt.nokia.com/demos/openglax.cab">
61 [Object not available! Did you forget to build and register the server?]
65 Rotate the scene:<br />
66 X:<input type="edit" ID="XEdit" value="0" /><br />
67 Y:<input type="edit" name="YEdit" value="0" /><br />
68 Z:<input type="edit" name="ZEdit" value="0" /><br />
69 <input type="button" value="Set" onClick="setRot(this.form)" />
75 \example activeqt/opengl
76 \title OpenGL Example (ActiveQt)
78 The OpenGL example demonstrates the use of the default factory
79 and QAxFactory::isServer(), and the implementation of an
80 additional COM interface using QAxBindable and QAxAggregated.
81 The server executable can run both as an ActiveX server and as a
82 stand-alone application.
84 The ActiveX control in this example uses the QGlWidget class in
85 Qt to render an OpenGL scene in an ActiveX. The control exposes a few
86 methods to change the scene.
88 The application uses the default factory as provided by the
89 QAXFACTORY_DEFAULT macro to expose the \c GLBox widget as an ActiveX
91 \snippet examples/activeqt/opengl/main.cpp 0
92 The implementation of \c main initializes the QApplication object,
93 and uses \c QAxFactory::isServer() to determine whether or not it is
94 appropriate to create and show the application interface.
95 \snippet examples/activeqt/opengl/main.cpp 1
96 \snippet examples/activeqt/opengl/main.cpp 2
97 \snippet examples/activeqt/opengl/main.cpp 3
99 The \c GLBox class inherits from both the \l QGLWidget class to be able
100 to render OpenGL, and from \l QAxBindable.
101 \snippet examples/activeqt/opengl/glbox.h 0
102 The class reimplements the \l QAxBindable::createAggregate() function from QAxBindable
103 to return the pointer to a \l QAxAggregated object.
104 \snippet examples/activeqt/opengl/glbox.h 1
105 The rest of the class declaration and the implementation of the OpenGL
106 rendering is identical to the original "box" example.
108 The implementation file of the \c GLBox class includes the \c objsafe.h
109 system header, in which the \c IObjectSafety COM interface is defined.
110 \snippet examples/activeqt/opengl/glbox.cpp 0
111 A class \c ObjectSafetyImpl is declared using multiple inheritance
112 to subclass the QAxAggregated class, and to implement the IObjectSafety
114 \snippet examples/activeqt/opengl/glbox.cpp 1
115 The class declares a default constructor, and implements the queryInterface
116 function to support the IObjectSafety interface.
117 \snippet examples/activeqt/opengl/glbox.cpp 2
118 Since every COM interface inherits \c IUnknown the \c QAXAGG_IUNKNOWN macro
119 is used to provide the default implementation of the \c IUnknown interface.
120 The macro is defined to delegate all calls to \c QueryInterface, \c AddRef
121 and \c Release to the interface returned by the controllingUnknown() function.
122 \snippet examples/activeqt/opengl/glbox.cpp 3
123 The implementation of the \c IObjectSafety interface provides the caller
124 with information about supported and enabled safety options, and returns
125 \c S_OK for all calls to indicate that the ActiveX control is safe.
126 \snippet examples/activeqt/opengl/glbox.cpp 4
127 The implementation of the \c createAggregate() function just returns a new
128 \c ObjectSafetyImpl object.
129 \snippet examples/activeqt/opengl/glbox.cpp 5
131 To build the example you must first build the QAxServer library.
132 Then run \c qmake and your make tool in \c
133 examples/activeqt/wrapper.
135 The \l{qaxserver-demo-opengl.html}{demonstration} requires your
136 WebBrowser to support ActiveX controls, and scripting to be
139 In contrast to the other QAxServer examples Internet Explorer will not
140 open a dialog box to ask the user whether or not the scripting of the GLBox
141 control should be allowed (the exact browser behaviour depends on the security
142 settings in the Internet Options dialog).
144 \snippet doc/src/examples/activeqt/opengl-demo.qdocinc 0