Canvas that provides a 3D rendering context (deprecated). 更多...
import 语句: | import QtCanvas3D 1.1 |
Since: | QtCanvas3D 1.0 |
Canvas3D module was deprecated in Qt 5.12. Depracated modules are no longer maintained. They are provided to keep old source code working, but they can be removed in a future release. We strongly advise against using deprecated modules in new code or project.
The Canvas3D is a QML element that, when placed in your Qt Quick 2 scene, allows you to get a 3D rendering context and call 3D rendering API calls through that context object. Use of the rendering API requires knowledge of OpenGL-like rendering APIs.
There are two functions that are called by the Canvas3D implementation:
另请参阅 Context3D .
context : Context3D |
Deprecated in Qt 5.12. This property can be used to access the context created with getContext() 方法。
另请参阅 getContext() .
Deprecated in Qt 5.12. Specifies the ratio between logical pixels (used by the Qt Quick) and actual physical on-screen pixels (used by the 3D rendering).
fps : int |
Deprecated in Qt 5.12. This property specifies the current number of frames rendered per second. The value is recalculated every 500 ms, as long as any rendering is done.
注意:
This property only gets updated after a
Canvas3D
frame is rendered, so if no frames are being drawn, this property value won't change. It is also based on the number of
Canvas3D
frames actually rendered since the value was last updated, so it may not accurately reflect the actual rendering performance when If
Canvas3D.renderOnDemand
特性为
true
.
另请参阅 frameTimeMs .
pixelSize : size |
Deprecated in Qt 5.12. Specifies the size of the render target surface in physical on-screen pixels used by the 3D rendering.
renderOnDemand : bool |
Deprecated in Qt 5.12.
If the value is
false
, the render loop runs constantly and
Canvas3D.paintGL()
signal is emitted once per frame. If the value is
true
,
Canvas3D.paintGL()
is only emitted when
Canvas3D
content needs to be re-rendered because a geometry change or some other event affecting the
Canvas3D
content occurred. The application can also request a render using
Canvas3D.requestRender()
方法。
Deprecated in Qt 5.12. Specifies how the rendering should be done.
Canvas3D.RenderTargetOffscreenBuffer
indicates rendering is done into an offscreen buffer and the finished texture is used for the
Canvas3D
item. This is the default target.
Canvas3D.RenderTargetBackground
indicates the rendering is done to the background of the Qt Quick scene, in response to
QQuickWindow::beforeRendering()
信号。
Canvas3D.RenderTargetForeground
indicates the rendering is done to the foreground of the Qt Quick scene, in response to
QQuickWindow::afterRendering()
信号。
Canvas3D.RenderTargetBackground
and
Canvas3D.RenderTargetForeground
targets render directly to the same framebuffer the rest of the Qt Quick scene uses. This will improve performance on platforms that are fill-rate limited, but using these targets imposes several limitations on the usage of
Canvas3D
:
Canvas3D.RenderTargetOffscreenBuffer
render target.
main.cpp
.
This property can only be modified before the Canvas3D item has been rendered for the first time.
Deprecated in Qt 5.12. Emitted when OpenGL context is lost. This happens whenever the parent window of the Canvas3D is destroyed (or otherwise loses its context), or Canvas3D is moved to a different window. Removing Canvas3D from a window and adding it back to the same window doesn't cause context loss, as long as the window itself stays alive.
When context is lost, all objects created by Context3D are invalidated.
另请参阅 contextRestored .
Deprecated in Qt 5.12. Emitted when OpenGL context is restored after a loss of context occurred. The Context3D attached to the canvas needs to be reinitialized, so initializeGL is also emitted after this signal.
另请参阅 contextLost .
Deprecated in Qt 5.12. Emitted once when Canvas3D is ready and OpenGL state initialization can be done by the client.
Deprecated in Qt 5.12. Emitted each time a new frame should be drawn to Canvas3D . Driven by the Qt Quick scenegraph loop.
int frameSetupTimeMs () |
Deprecated in Qt 5.12. This method returns the number of milliseconds Canvas3D took to process the PaintGL signal for the previous frame. Before any frames have been rendered this method returns 0. This time doesn't include time spent on actual OpenGL rendering of the frame, nor the time the scene graph takes to present the frame to the screen. This value is updated after PaintGL signal handler returns.
This method was introduced in QtCanvas3D 1.1.
另请参阅 fps and frameTimeMs .
int frameTimeMs () |
Deprecated in Qt 5.12. This method returns the number of milliseconds the renderer took to process the OpenGL portion of the rendering for the previous frame. Before any frames have been rendered this method returns 0. This time is measured from the point OpenGL commands are transferred to render thread to the time glFinish() returns, so it doesn't include the time spent parsing JavaScript, nor the time the scene graph takes to present the frame to the screen. This value is updated for the previous frame when the next frame OpenGL command transfer is done.
另请参阅 fps and frameSetupTimeMs .
Returns the 3D rendering context that allows 3D rendering calls to be made. The type parameter is ignored for now, but a string is expected to be given.
Context3D getContext ( string type , Canvas3DContextAttributes options ) |
Deprecated in Qt 5.12.
Returns the 3D rendering context that allows 3D rendering calls to be made. The
type
parameter is ignored for now, but a string is expected to be given. If
Canvas3D
.
renderTarget
property value is either
Canvas3D.RenderTargetBackground
or
Canvas3D.RenderTargetForeground
,
options
parameter is also ignored, the context attributes of the Qt Quick context are used, and the
Canvas3DContextAttributes.preserveDrawingBuffer
property is forced to
false
。
options
parameter is only parsed when the first call to
getContext()
is made and is ignored in subsequent calls if given. If the first call is made without giving the
options
parameter, then the context and render target is initialized with default configuration.
另请参阅 Canvas3DContextAttributes , Context3D ,和 renderTarget .
*
Deprecated in Qt 5.12.
* Queues a new frame for rendering when
Canvas3D.renderOnDemand
* property is
true
. * Does nothing when
Canvas3D.renderOnDemand
特性为
false
.