Results 1 to 9 of 9

Thread: qt and gl/cl inerop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2012
    Posts
    38
    Thanks
    3

    Default qt and gl/cl inerop

    hеllo.
    I'm trying to use an interop with opengl and opencl in qt.
    this is my code:
    Qt Code:
    1. GLuint id = 0;
    2. glGenBuffers(1, &id);
    3. glBindBuffer(GL_ARRAY_BUFFER, id);
    4. glBufferData(GL_ARRAY_BUFFER, lSize, NULL, GL_STATIC_DRAW);
    5.  
    6. int err;
    7. cl::BufferGL buff;
    8. buff= cl::BufferGL(context, CL_MEM_WRITE_ONLY, id, &err);
    9.  
    10. glBindBuffer(GL_ARRAY_BUFFER, 0);
    11. vertexBufferObject = id;
    To copy to clipboard, switch view to plain text mode 
    I get always the same error:
    -60: CL_INVALID_GL_OBJECT.
    i omitted the construction of the gl/cl context code, but I'm was try this without qt and all works fine.
    When i use the code in qt i get the error.
    What can be?
    the threads and contexts that are used in qt?
    How i can resolve?
    But I wish understand and use my own library, rather than use an already done library .
    thanks.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qt and gl/cl inerop

    show your COMPLETE & COMPILABLE example that works, and then show your COMPLETE & COMPILABLE example that doesn't work.

    Please explain how this is a qt question.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Nov 2012
    Posts
    38
    Thanks
    3

    Default Re: qt and gl/cl inerop

    thanks.
    but I must gain some information, before post my code:
    I'm trying to work with
    http://doc.qt.digia.com/opencl-snaps...contextgl.html.
    I not understand the
    supportsObjectSharing
    and the
    Qt Code:
    1. /*!
    2.   Constructs a new OpenCL context object that is suitable for use
    3.   with OpenGL objects.
    4. */
    5. QCLContextGL::QCLContextGL()
    6. : QCLContext(), d_ptr(new QCLContextGLPrivate())
    7. {
    8. }
    To copy to clipboard, switch view to plain text mode 
    in the qclcontextgl.cpp line:81.
    1)I'm not understand what is a 1)context and what is a 2)contextprivate.
    Is related to multithreading?
    where i can found documentation on this arg?
    thanks.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qt and gl/cl inerop

    1 - http://www.dyn-lab.com/articles/cl-gl.html

    2 - you don't need to worry about it - it is the qt implementation. It wont be thread related.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Nov 2012
    Posts
    38
    Thanks
    3

    Default Re: qt and gl/cl inerop

    this is my qglwidget constructor for try to create interoperability:
    i use this lib :http://doc.qt.digia.com/opencl-snaps...contextgl.html
    Qt Code:
    1. CTest::CTest(HINSTANCE hPrevInstance, int nShowCmd)
    2. {
    3. m_hPrevInstance = hPrevInstance;
    4. m_nShowCmd = nShowCmd;
    5. CApplication::m_Draw = bind(&CTest::Draw, this);
    6. CApplication::m_Create = bind(&CTest::CreateInit, this);
    7.  
    8. setMouseTracking(true);
    9. m_pTimer = new QTimer(this);
    10. connect(m_pTimer, SIGNAL(timeout()), this , SLOT(OnIdleOpenGl()) );
    11. makeCurrent();
    12. context.create();
    13.  
    14. vert = NULL;
    15. if (!vert) {
    16. vert = new QGLBuffer(QGLBuffer::VertexBuffer);
    17. vert->setUsagePattern(QGLBuffer::DynamicDraw);
    18. if (!vert->create()) {
    19. delete vert;
    20. vert = 0;
    21.  
    22. }
    23. }
    24. if (vert) {
    25. vert->bind();
    26. vert->allocate(sizeof(GLfloat) * 4 * 4);
    27. if (!vert->map(QGLBuffer::WriteOnly)) {
    28. // No point using a vertex buffer if we cannot map it.
    29. vert->unmap();
    30. vert->release();
    31. delete vert;
    32. vert = 0;
    33. } else {
    34. vert->unmap();
    35. vert->release();
    36. }
    37.  
    38. }
    39. QCLBuffer BBB;
    40. if (context.supportsObjectSharing()) {
    41. BBB = context.createGLBuffer(vert,QCLMemoryObject::WriteOnly);
    42. }
    43.  
    44. m_pTimer->setInterval( 3 );
    45. m_pTimer->start();
    46. }
    To copy to clipboard, switch view to plain text mode 
    but this:
    context.supportsObjectSharing()
    return false
    and this if i remove the test:
    BBB = context.createGLBuffer(vert,QCLMemoryObject::Write Only);
    return a void openclbuffer.

    thanks

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qt and gl/cl inerop

    looks like your conext should acquire() the qclbuffer
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7
    Join Date
    Nov 2012
    Posts
    38
    Thanks
    3

    Default Re: qt and gl/cl inerop

    in the bezierpatch demo of the library all work fine, but i'm not understand why!

  8. #8
    Join Date
    Nov 2012
    Posts
    38
    Thanks
    3

    Default Re: qt and gl/cl inerop

    how i can understand the thread related problematics in qt and opengl?
    thanks.

  9. #9
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qt and gl/cl inerop

    what thread 'problematics'?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.