Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide QGLBuffer allocate input data
Forum Updated to NodeBB v4.3 + New Features

PySide QGLBuffer allocate input data

Scheduled Pinned Locked Moved Language Bindings
2 Posts 1 Posters 1.5k Views 1 Watching
  • 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.
  • I Offline
    I Offline
    INeedMySpace
    wrote on last edited by
    #1

    I'm trying to run PySide version of OpenGL Core Profile Qt demo - How_to_use_OpenGL_Core_Profile_with_Qt.

    It uses QGLBuffer.allocate() method (C++ code)

    @float points[] = { -0.5f, -0.5f, 0.0f, 1.0f,
    0.5f, -0.5f, 0.0f, 1.0f,
    0.0f, 0.5f, 0.0f, 1.0f };
    m_vertexBuffer.allocate( points, 3 * 4 * sizeof( float ) );@

    Pythonic way will be:

    @points = [-0.5, -0.5, 0.0, 1.0,
    0.5, -0.5, 0.0, 1.0,
    0.0, 0.5, 0.0, 1.0]
    m_vertexBuffer.allocate(points)@

    But when I run this code I get following error

    @TypeError: 'PySide.QtOpenGL.QGLBuffer.allocate' called with wrong argument types:
    PySide.QtOpenGL.QGLBuffer.allocate(list)
    Supported signatures:
    PySide.QtOpenGL.QGLBuffer.allocate(void, int = -1)
    PySide.QtOpenGL.QGLBuffer.allocate(int)
    @

    I found unit test that is used for this functionality - it uses QByteArray.

    @data = QByteArray("12345")
    b.allocate(data)@

    But I don't understand how to convert Python list to QByteArray or use allocate with list. Or is it a bug in PySide wrapper function?

    You have been involved in illegal use of magic.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      INeedMySpace
      wrote on last edited by
      #2

      It seems I found solution. We should use python modules like struct or array. For example:

      @from array import *

      points = [0.5, 1, -0.5]
      data = array('f', points)

      data.tostring() - returns packed data with size of len(data.tostring())@

      You have been involved in illegal use of magic.

      1 Reply Last reply
      0

      • Login

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