Results 1 to 7 of 7

Thread: Question about the example “Scene Graph - OpenGL Under QML”

  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Question about the example “Scene Graph - OpenGL Under QML”

    How could I apply the effect on a specific component?

    Qt Code:
    1. //! [1]
    2. import QtQuick 2.0
    3. import OpenGLUnderQML 1.0
    4.  
    5. Item {
    6.  
    7. width: 320
    8. height: 480
    9.  
    10. //! [1] //! [2]
    11. Rectangle {
    12. color: Qt.rgba(1, 1, 1, 0.7)
    13. radius: 10
    14. border.width: 1
    15. border.color: "white"
    16. anchors.fill: label
    17. anchors.margins: -10
    18.  
    19. //apply the Squircle effect on the Rectangle rather than the root item
    20. Squircle {
    21. SequentialAnimation on t {
    22. NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
    23. NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
    24. loops: Animation.Infinite
    25. running: true
    26. }
    27. }
    28. }
    29.  
    30. Text {
    31. id: label
    32. color: "black"
    33. wrapMode: Text.WordWrap
    34. text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML"
    35. anchors.right: parent.right
    36. anchors.left: parent.left
    37. anchors.bottom: parent.bottom
    38. anchors.margins: 20
    39. }
    40. }
    41. //! [2]
    To copy to clipboard, switch view to plain text mode 

    No matter waht I try, it is always render on the background but not the Rectangle

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about the example “Scene Graph - OpenGL Under QML”

    Quote Originally Posted by stereoMatching View Post
    No matter waht I try, it is always render on the background but not the Rectangle
    That's the point of the whole approach, isn't it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about the example “Scene Graph - OpenGL Under QML”

    Quote Originally Posted by wysota View Post
    That's the point of the whole approach, isn't it?
    You are correct, my fault, didn't understand the example.

    We could use QGLWidget to render the texture and show it by old widget
    what if we want to render a texture but show it by qml scene by c++?
    There are some algorithms need to be done by c++(sorting, etc)

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about the example “Scene Graph - OpenGL Under QML”

    I don't understand what you mean. If you want to show an image using QML then use the Image element. Other than that you can always implement a custom QQuickItem and render whatever you want there using whatever scene graph has to offer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about the example “Scene Graph - OpenGL Under QML”

    Quote Originally Posted by wysota View Post
    I don't understand what you mean. If you want to show an image using QML then use the Image element. Other than that you can always implement a custom QQuickItem and render whatever you want there using whatever scene graph has to offer.
    Sorry I didn't explain what I want to do clearly.
    What I want to do is very similar to QGLWidget do

    create a widget, render the texture by opengl and show it on the widget

    I want to do the same thing on the qml too
    If it is possible, I would like to create a qml component
    which could show the image after render by opengl on the qml site

    The example of “Scene Graph - OpenGL Under QML” would render all of the background
    but that is not what I want to do

    pseudo codes
    Qt Code:
    1. Rectangle{
    2.  
    3. //......other components
    4.  
    5. //render the source by opengl, the result only apply on the GLImage, not the whole background
    6. GLImage{
    7.  
    8. source: "file:///users/downloads/jjj.png"
    9. //.....
    10.  
    11. }
    12.  
    13. //....other components
    14. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about the example “Scene Graph - OpenGL Under QML”

    As I said, you need to create a custom item that will render to an FBO and then display contents of that FBO. Alternatively you can render directly to the item.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    stereoMatching (27th June 2013)

  8. #7
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about the example “Scene Graph - OpenGL Under QML”

    Quote Originally Posted by wysota View Post
    As I said, you need to create a custom item that will render to an FBO and then display contents of that FBO. Alternatively you can render directly to the item.
    Thanks, but I have a hard time with FBO

    http://www.qtcentre.org/threads/5510...GL%29-with-Qt5
    can't find the bug

    edit: I found the examples which maybe could solve my problem, "Scene graph-Rendering", thanks for your help
    Last edited by stereoMatching; 27th June 2013 at 11:33.

Similar Threads

  1. converting GLUT/OpenGL to Qt/OpenGL - displaying issue
    By yoti13 in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2012, 00:45
  2. Replies: 0
    Last Post: 6th December 2009, 00:41
  3. OpenGL and Qt Question
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2009, 18:04
  4. OpenGL question
    By ^NyAw^ in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2008, 18:19
  5. OpenGL question
    By ^NyAw^ in forum General Programming
    Replies: 2
    Last Post: 4th February 2008, 09:39

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.