Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 db123   Members   -  Reputation: 216

Like
0Likes
Like

Posted 25 July 2013 - 08:42 AM

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.

1.jpg

 

2.jpg

 

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....

 



Sponsor:

#2 db123   Members   -  Reputation: 216

Like
0Likes
Like

Posted 26 July 2013 - 08:45 AM

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

it works well now.biggrin.png






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS