1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
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.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
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://qtsoftware.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 | */
|
---|