|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the documentation of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
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. |
|
23 ** |
|
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. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 /*! |
|
43 \page qaxserver-demo-opengl.html |
|
44 |
|
45 \title OpenGL in an HTML page |
|
46 |
|
47 \raw HTML |
|
48 <SCRIPT LANGUAGE="JavaScript"> |
|
49 function setRot( form ) |
|
50 { |
|
51 GLBox.setXRotation( form.XEdit.value ); |
|
52 GLBox.setYRotation( form.YEdit.value ); |
|
53 GLBox.setZRotation( form.ZEdit.value ); |
|
54 } |
|
55 </SCRIPT> |
|
56 |
|
57 <p /> |
|
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?] |
|
62 </object><br /> |
|
63 |
|
64 <form> |
|
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)" /> |
|
70 </form> |
|
71 \endraw |
|
72 */ |
|
73 |
|
74 /*! |
|
75 \example activeqt/opengl |
|
76 \title OpenGL Example (ActiveQt) |
|
77 |
|
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. |
|
83 |
|
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. |
|
87 |
|
88 The application uses the default factory as provided by the |
|
89 QAXFACTORY_DEFAULT macro to expose the \c GLBox widget as an ActiveX |
|
90 control. |
|
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 |
|
98 |
|
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. |
|
107 |
|
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 |
|
113 interface. |
|
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 |
|
130 |
|
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. |
|
134 |
|
135 The \l{qaxserver-demo-opengl.html}{demonstration} requires your |
|
136 WebBrowser to support ActiveX controls, and scripting to be |
|
137 enabled. |
|
138 |
|
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). |
|
143 |
|
144 \snippet doc/src/examples/activeqt/opengl-demo.qdocinc 0 |
|
145 */ |