Simplify the depth transformation in the scene graph.
Use default depth function GL_LESS and depth clear value 1, and set the near and far clipping planes to -1 and 1. This change will make the transformations a bit easier for people who implement custom 3D geometry since [-1, 1] is the typical z-range after a projection transformation. The change has no visual impact on 2D geometry. Change-Id: I75d4a8acc15131ffaa5d13a749e42dffbc1d09db Reviewed-by: Glenn Watson <glenn.watson@nokia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
parent
8c68dcd2aa
commit
70dee431e8
|
@ -231,11 +231,11 @@ void QSGDefaultRenderer::render()
|
|||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(true);
|
||||
glDepthFunc(GL_GREATER);
|
||||
glDepthFunc(GL_LESS);
|
||||
#if defined(QT_OPENGL_ES)
|
||||
glClearDepthf(0);
|
||||
glClearDepthf(1);
|
||||
#else
|
||||
glClearDepth(0);
|
||||
glClearDepth(1);
|
||||
#endif
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
@ -298,9 +298,6 @@ void QSGDefaultRenderer::render()
|
|||
int debugtimeSorting = debugTimer.elapsed();
|
||||
#endif
|
||||
|
||||
m_renderOrderMatrix.setToIdentity();
|
||||
m_renderOrderMatrix.scale(1, 1, qreal(1) / m_currentRenderOrder);
|
||||
|
||||
int opaqueStart = 0;
|
||||
int transparentStart = 0;
|
||||
for (int i = 0; i < m_renderGroups.size(); ++i) {
|
||||
|
@ -523,16 +520,16 @@ void QSGDefaultRenderer::renderNodes(QSGNode *const *nodes, int count)
|
|||
}
|
||||
if (changes & QSGRenderNode::DepthState) {
|
||||
#if defined(QT_OPENGL_ES)
|
||||
glClearDepthf(0);
|
||||
glClearDepthf(1);
|
||||
#else
|
||||
glClearDepth(0);
|
||||
glClearDepth(1);
|
||||
#endif
|
||||
if (m_clear_mode & QSGRenderer::ClearDepthBuffer) {
|
||||
glDepthMask(true);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
glDepthMask(false);
|
||||
glDepthFunc(GL_GREATER);
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
if (changes & QSGRenderNode::ColorState)
|
||||
bindable()->reactivate();
|
||||
|
@ -617,7 +614,7 @@ void QSGDefaultRenderer::renderNodes(QSGNode *const *nodes, int count)
|
|||
if (changeRenderOrder) {
|
||||
currentRenderOrder = geomNode->renderOrder();
|
||||
m_current_projection_matrix.setColumn(3, projection.column(3)
|
||||
+ currentRenderOrder
|
||||
+ (m_currentRenderOrder - 1 - 2 * currentRenderOrder)
|
||||
* m_current_projection_matrix.column(2));
|
||||
updates |= QSGMaterialShader::RenderState::DirtyMatrix;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ private:
|
|||
QSGMaterial *m_currentMaterial;
|
||||
QSGMaterialShader *m_currentProgram;
|
||||
const QMatrix4x4 *m_currentMatrix;
|
||||
QMatrix4x4 m_renderOrderMatrix;
|
||||
QDataBuffer<QSGNode *> m_opaqueNodes;
|
||||
QDataBuffer<QSGNode *> m_transparentNodes;
|
||||
QDataBuffer<QSGNode *> m_tempNodes;
|
||||
|
|
|
@ -313,7 +313,7 @@ void QSGRenderer::setProjectionMatrixToRect(const QRectF &rect)
|
|||
rect.x() + rect.width(),
|
||||
rect.y() + rect.height(),
|
||||
rect.y(),
|
||||
qreal(0.01),
|
||||
1,
|
||||
-1);
|
||||
setProjectionMatrix(matrix);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue