IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

GridMesh QML Type

Defines a mesh with vertices arranged in a grid.

This type was introduced in Qt 5.0.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

GridMesh QML Type

  • Import Statement: import QtQuick

  • Since:: Qt 5.0

  • Group: GridMesh is part of qtquick-effects

Detailed Description

GridMesh defines a rectangular mesh consisting of vertices arranged in an evenly spaced grid. It is used to generate geometry. The grid resolution is specified with the resolution property.

Property Documentation

 

resolution : size

This property holds the grid resolution. The resolution's width and height specify the number of cells or spacings between vertices horizontally and vertically respectively. The minimum and default is 1x1, which corresponds to four vertices in total, one in each corner. For non-linear vertex transformations, you probably want to set the resolution higher.

Result

QML code

gridmesh.vert

Image non disponible
 
Sélectionnez
import QtQuick 2.0

ShaderEffect {
    width: 200
    height: 200
    mesh: GridMesh {
        resolution: Qt.size(20, 20)
    }
    property variant source: Image {
        source: "qt-logo.png"
        sourceSize { width: 200; height: 200 }
    }
    vertexShader: "gridmesh.vert"
}
 
Sélectionnez
#version 440
layout(location = 0) in vec4 qt_Vertex;
layout(location = 1) in vec2 qt_MultiTexCoord0;
layout(location = 0) out vec2 qt_TexCoord0;
layout(std140, binding = 0) uniform buf {
    mat4 qt_Matrix;
    float qt_Opacity;
    float width;
};
void main() {
    vec4 pos = qt_Vertex;
    float d = 0.5 * smoothstep(0.0, 1.0, qt_MultiTexCoord0.y);
    pos.x = width * mix(d, 1.0 - d, qt_MultiTexCoord0.x);
    gl_Position = qt_Matrix * pos;
    qt_TexCoord0 = qt_MultiTexCoord0;
}

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+