summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-05-13 16:52:23 +0300
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-06-04 08:24:43 +0000
commit5a861acb8064ddc41399bf9e036983ae14da9ea7 (patch)
tree2fff6e096e920270a309d5aee78278c04d6929ef /examples
parentc318bc17d35423949c70ba8101c1bcd35b1c8c91 (diff)
Execute Canvas3D OpenGL in render thread
The render loop has been redesigned. The OpenGL commands are queued instead of executed immediately. updatePaintNode() now transfers the commands to the renderer, which implements all OpenGL related things that used to be in the Canvas class. The actual rendering is done in response to beforeRendering signal in the render thread. [ChangeLog][Renderer] OpenGL rendering moved to render thread. Task-number: QTBUG-44953 Change-Id: Ibd5897e64b84b6c7ce169cece8293381eca94ab9 Reviewed-by: Tomi Korpipää <tomi.korpipaa@theqtcompany.com> Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/canvas3d/canvas3d/framebuffer/doc/src/framebuffer.qdoc4
-rw-r--r--examples/canvas3d/canvas3d/jsonmodels/jsonmodels.js5
-rw-r--r--examples/canvas3d/canvas3d/textureandlight/doc/src/textureandlight.qdoc18
3 files changed, 14 insertions, 13 deletions
diff --git a/examples/canvas3d/canvas3d/framebuffer/doc/src/framebuffer.qdoc b/examples/canvas3d/canvas3d/framebuffer/doc/src/framebuffer.qdoc
index 6149496..74c7084 100644
--- a/examples/canvas3d/canvas3d/framebuffer/doc/src/framebuffer.qdoc
+++ b/examples/canvas3d/canvas3d/framebuffer/doc/src/framebuffer.qdoc
@@ -58,7 +58,7 @@
\snippet canvas3d/framebuffer/qml/framebuffer/framebuffer.js 0
- Then, in the \c initGL function, we create the framebuffer object:
+ Then, in the \c initializeGL function, we create the framebuffer object:
\snippet canvas3d/framebuffer/qml/framebuffer/framebuffer.js 1
@@ -75,7 +75,7 @@
\section1 Rendering into the Framebuffer
- In \c renderGL function, we first need to draw the scene into the
+ In \c paintGL function, we first need to draw the scene into the
framebuffer. We start by binding the framebuffer object and setting a
viewport:
diff --git a/examples/canvas3d/canvas3d/jsonmodels/jsonmodels.js b/examples/canvas3d/canvas3d/jsonmodels/jsonmodels.js
index e48abd5..8a6dafe 100644
--- a/examples/canvas3d/canvas3d/jsonmodels/jsonmodels.js
+++ b/examples/canvas3d/canvas3d/jsonmodels/jsonmodels.js
@@ -253,7 +253,8 @@ function paintGL(canvas) {
// Draw the model
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, modelOne.indexVBO);
- if (stateDumpExt)
+ // Getting state dump is a synchronous operation, so only do it when logging is enabled
+ if (isLogEnabled && stateDumpExt)
log("GL STATE DUMP:\n"+stateDumpExt.getGLStateDump(stateDumpExt.DUMP_FULL));
gl.drawElements(drawMode, modelOne.count, gl.UNSIGNED_SHORT, 0);
@@ -621,7 +622,7 @@ function fillModel(modelData, model) {
new Float32Array(modelData.vertices),
gl.STATIC_DRAW);
log(" "+model.normalsVBO.name);
- if (stateDumpExt)
+ if (isLogEnabled && stateDumpExt)
log("GL STATE DUMP:\n"+stateDumpExt.getGLStateDump(stateDumpExt.DUMP_VERTEX_ATTRIB_ARRAYS_BIT || stateDumpExt.DUMP_VERTEX_ATTRIB_ARRAYS_CONTENTS_BIT));
gl.bindBuffer(gl.ARRAY_BUFFER, model.normalsVBO);
diff --git a/examples/canvas3d/canvas3d/textureandlight/doc/src/textureandlight.qdoc b/examples/canvas3d/canvas3d/textureandlight/doc/src/textureandlight.qdoc
index 3c7a644..4ae0afd 100644
--- a/examples/canvas3d/canvas3d/textureandlight/doc/src/textureandlight.qdoc
+++ b/examples/canvas3d/canvas3d/textureandlight/doc/src/textureandlight.qdoc
@@ -56,7 +56,7 @@
\snippet canvas3d/textureandlight/qml/textureandlight/main.qml 0
\dots
- Inside it, we catch the \c initGL and \c renderGL signals to forward the
+ Inside it, we catch the \c initializeGL and \c paintGL signals to forward the
initialization and rendering calls to the js object:
\snippet canvas3d/textureandlight/qml/textureandlight/main.qml 1
@@ -67,7 +67,7 @@
\snippet canvas3d/textureandlight/qml/textureandlight/main.qml 4
- In the \c initGL function of the JavaScript, we initialize the OpenGL
+ In the \c initializeGL function of the JavaScript, we initialize the OpenGL
state. We also create the TextureImage and register handlers for image
load success and fail signals. If the load succeeds, the OpenGL texture
is created and filled with pixel data from the loaded image.
@@ -83,9 +83,9 @@
\snippet canvas3d/textureandlight/qml/textureandlight/textureandlight.js 0
- \section2 initGL Function
+ \section2 initializeGL Function
- Let's take a closer look at the \c initGL function. It is called by
+ Let's take a closer look at the \c initializeGL function. It is called by
Canvas3D once the render node is ready.
First of all, we need to get a Context3D from our Canvas3D. We want
@@ -98,7 +98,7 @@
\snippet canvas3d/textureandlight/qml/textureandlight/textureandlight.js 2
Next, let's take a look into shader initialization in the
- \c initShaders function, which we call in \c{initGL}. First we define
+ \c initShaders function, which we call in \c{initializeGL}. First we define
the vertex shader:
\snippet canvas3d/textureandlight/qml/textureandlight/textureandlight.js 3
@@ -125,16 +125,16 @@
Above, first we create the buffer, then bind it and finally insert the
data into it. Other buffers are all handled in a similar fashion.
- As the final step in \c{initGL}, we create a texture image from
+ As the final step in \c{initializeGL}, we create a texture image from
TextureImageFactory, and register handlers for \c imageLoaded and
\c imageLoadingFailed signals. Once the texture image is successfully
loaded, we create the actual texture:
\snippet canvas3d/textureandlight/qml/textureandlight/textureandlight.js 8
- \section2 renderGL Function
+ \section2 paintGL Function
- \c renderGL is called by Canvas3D whenever it is ready to receive a new
+ \c paintGL is called by Canvas3D whenever it is ready to receive a new
frame. Let's go through the steps that are done in each render cycle.
First we check if canvas has been resized or if pixel ratio has changed,
@@ -142,7 +142,7 @@
\snippet canvas3d/textureandlight/qml/textureandlight/textureandlight.js 9
- Then we clear the render area using the clear color set in \c{initGL}:
+ Then we clear the render area using the clear color set in \c{initializeGL}:
\snippet canvas3d/textureandlight/qml/textureandlight/textureandlight.js 10