Jump to content
  • Advertisement
Sign in to follow this  
db123

OpenGL [fixed by update qt to 5.1]performance of wglMakeCurrent[ work with QT5.0.2]

This topic is 2186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i am working with opengl and qt, but i find some performance problem about wglMakCurrent.

this is the test result which was captured by intel vtune.

[attachment=16973:1.jpg]

 

[attachment=16974:2.jpg]

 

[attachment=16975:3.jpg]

 

i am not use QWidget not QGLWidget because i want to make the rendering code with a same style.

when i render a QT widget with directx9, i send the wid() to my render, and createdevice from this HWND.

if i need a child widget, i will create a new SwapChain for this new widget.

this framework work with directx perfect.

 

but there is a performance question when i make it work with opengl.

 

like directx, i send wid() to opengl render, and create a GLContext by this HWND. this is the initialize code:

                m_HDC = ::GetDC( m_BindWnd );

                PIXELFORMATDESCRIPTOR FormatDesc;
                memset(&FormatDesc, 0, sizeof(PIXELFORMATDESCRIPTOR));
                FormatDesc.nSize		= sizeof(PIXELFORMATDESCRIPTOR);
                FormatDesc.nVersion		= 1;
                FormatDesc.dwFlags		= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI| PFD_DOUBLEBUFFER;
                FormatDesc.iPixelType	= PFD_TYPE_RGBA;
                FormatDesc.cColorBits	= 32;
                FormatDesc.cDepthBits	= 32;
                // FormatDesc.cStencilBits	= 0;
                FormatDesc.iLayerType	= PFD_MAIN_PLANE;

                INT PixelFormat = ChoosePixelFormat( m_HDC, &FormatDesc);
                if (PixelFormat && SetPixelFormat( m_HDC, PixelFormat, &FormatDesc) )
                {
                    m_GLContext = wglCreateContext(m_HDC);

                    if ( m_GLContext && wglMakeCurrent(m_HDC, m_GLContext) )
                    {
                        InitializeGLEW();
                    }
                }

         if a new qwidget created, i will do the same thing for this new qwidget.

 

        when i render them, i will call beginRender and endRender for these warpper object.

        in directx9, i will set the rendertarget to the one which is created by the swapchain.

        in opengl, i will call wglMakeCurrent in BeginRender, call wglMakeCurrent( NULL, NULL ) in EndRender. eg:

            void Viewport::SwapChain()
            {
                if( m_GLContext && m_HDC )
                {
                    ::SwapBuffers( m_HDC );
                }
            }
            
            void Viewport::BeginRender()
            {
                X_ASSERT( m_HDC && m_GLContext );

                BOOL bRet = ::wglMakeCurrent( m_HDC, m_GLContext );

                X_ASSERT( bRet );
            }
            
            void Viewport::EndRender()
            {
                BOOL bRet = ::wglMakeCurrent( NULL, NULL );

                X_ASSERT( bRet );                
            }

          all the codes are in main thread.  In addition to this, i have do nothing. 

          this will be very serious when i drag and move the window.

          smile.png

 

 

---

         this framework is work fine with normal window which is created by windows api.

         but when i use it work with qt, it does not work. work with dx fine....

 

Share this post


Link to post
Share on other sites
Advertisement

i have fixed this question with update qt to qt5.1 and use the offical release. dry.png

it works well now.biggrin.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!