Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How pass an array from qml to opengl Shader
QtWS25 Last Chance

How pass an array from qml to opengl Shader

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlopenglgslarray
1 Posts 1 Posters 664 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simkat82
    wrote on 31 May 2018, 15:07 last edited by
    #1

    Hello Everyone,

    I'm trying to paint a polygon on a map, using QML + Opengl.
    I can paint everything I want but, using QML, I don't find any solutions to pass an array of colors as a propriety of my Shaders: the array is correctly initialized in my app, but there is no way to pass it to opengl program.

    In "square.vert" I tried to define something like:
    attribute float sArray[ELEMENT]; // sArray is the proprity correctly defined in qml container

    Can anyone help me? Is there another way to pass a int[] o float[] to openGl scripts?

    Thanks in advance,

    Simone

    ShaderEffect {
        width: parent.width
        height: width
        blending: true
        property vector2d u_viewport_resolution : Qt.vector2d(width*1.0, height*1.0)
        **property variant qmlArray: externArray**
        property bool quant: true
        property int cellColor: externcellColor
        vertexShader:"qrc:/square.vert"
        fragmentShader: "qrc:/clutter.frag"
    }
    
    function vector_initialize()
    {
        console.log("vector_initialize");
        var colorIndex = 0;
        for (var i = 0; i < 11520; ++i ) {
    
            externArray[i]= 3.;//colorIndex;
            colorIndex = colorIndex +1;
    
            if (colorIndex == 5 )
                colorIndex = 0;
    
        }
    }
    
    1 Reply Last reply
    0

    1/1

    31 May 2018, 15:07

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved