Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use QSurfaceFormat instead of QGLFormat.
Forum Updated to NodeBB v4.3 + New Features

How to use QSurfaceFormat instead of QGLFormat.

Scheduled Pinned Locked Moved General and Desktop
12 Posts 2 Posters 4.7k 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.
  • L Offline
    L Offline
    lygstate
    wrote on 23 Oct 2013, 07:48 last edited by
    #1

    "QSurfaceFormat":http://qt-project.org/doc/qt-5.1/qtgui/qsurfaceformat.html
    http://qt-project.org/doc/qt-5.1/qtopengl/qglformat.html

    in the document of "QSurfaceFormat::depthBufferSize()":http://qt-project.org/doc/qt-5.1/qtgui/qsurfaceformat.html#depthBufferSize
    There is dead functions setDepth() and depth().
    @
    int QSurfaceFormat::depthBufferSize() const
    Returns the depth buffer size.
    See also setDepthBufferSize(), setDepth(), and depth().
    @

    I want to know how to setDepth in QSurfaceFormat.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on 23 Oct 2013, 10:09 last edited by
      #2

      @
      QSurfaceFormat f;
      f.setDepthBufferSize( 24 );
      @

      Looks like the docs are out of date and contain an error. I'll fix them.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on 23 Oct 2013, 11:13 last edited by
        #3

        Fixed in https://codereview.qt-project.org/#change,68934 Thanks for the heads up.

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lygstate
          wrote on 23 Oct 2013, 11:54 last edited by
          #4

          [quote author="ZapB" date="1382522966"]@
          QSurfaceFormat f;
          f.setDepthBufferSize( 24 );
          @

          Looks like the docs are out of date and contain an error. I'll fix them.[/quote]

          Thanks for your answer, but 24 is a magical number, where does it comes from?

          indeed, I want a equivalent for
          @
          glutInitDisplayMode(GLUT_ALPHA | GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
          @
          I have a piece of opengl code(generated by SCADE, that's why I can not implement it directly in Qt) code to running under QWinodw. The problem is that it's didn't running fine, so I wanna to know what kinds of initialization and running parameters should be set.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on 23 Oct 2013, 12:25 last edited by
            #5

            24 is the bit depth of the depth buffer being requested, it's not a magic number.

            To get the equivalent to what you want I think you need this or some variation of it:

            @
            QSurfaceFormat f;
            f.setDepthBufferSize( 24 ); // or 16, or 32 depending on what precision you want
            f.setStencilBufferSize( 8 );
            @

            The default should automatically include an RGBA color buffer and double buffering.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lygstate
              wrote on 23 Oct 2013, 13:56 last edited by
              #6

              Herder, thanks a lot, how about the alphaBufferSize? I want a value for it. Indeed, I am a newbie about opengl, sorry about the naive question.

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on 23 Oct 2013, 14:12 last edited by
                #7

                @
                f.setAlphaBufferSize(8);
                @

                although I think that is also the default (RGBA color buffer with 8 bits per channel).

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  ZapB
                  wrote on 23 Oct 2013, 14:14 last edited by
                  #8

                  Do

                  @
                  qDebug() << f;
                  @

                  to check both what you request and then after the context is created to see what you actually got back:

                  @
                  QSurfaceFormat actualFormat = m_context->format();
                  qDebug() << actualFormat;
                  @

                  Nokia Certified Qt Specialist
                  Interested in hearing about Qt related work

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lygstate
                    wrote on 24 Oct 2013, 05:08 last edited by
                    #9

                    Hi, Robot, thanks for your vivid answer. Now I am facing a serious problem about Qt 5.x opengl works with SCADE, when I using Qt 5.x/vs2010-x86 (QWindow/QGLWidget) to show a SCADE opengl rendering staff, it's can show it correctly, but the problem is it's flashing.
                    With the same copy of code running under Qt 4.8.3/vs2008-x86, it's works fine. So I am confused, and don't know if this is a bug or there is something i need to take care of. Ask for advice. Really appreciate for this.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on 24 Oct 2013, 06:57 last edited by
                      #10

                      Sorry, I have no idea without seeing some code that exhibits the problem. Can you make a small compilable example that shows the issue please?

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        lygstate
                        wrote on 24 Oct 2013, 07:20 last edited by
                        #11

                        [quote author="ZapB" date="1382597848"]Sorry, I have no idea without seeing some code that exhibits the problem. Can you make a small compilable example that shows the issue please?[/quote]

                        "OpenGL flashing bug":https://bugreports.qt-project.org/browse/QTBUG-34295
                        This is my bug report, I attached the source code that can be compiled, all the dependence are included, except it's only works with vs2008/vs2010/x86/opengl version.

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          ZapB
                          wrote on 24 Oct 2013, 14:45 last edited by
                          #12

                          OK thanks. I'll try to take a look soon.

                          Nokia Certified Qt Specialist
                          Interested in hearing about Qt related work

                          1 Reply Last reply
                          0

                          1/12

                          23 Oct 2013, 07:48

                          • Login

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