OnRenderSizeChanged overriden with reduced access error?

Viewed 37

I am hosting a Win32 OpenGL window in WPF through a DLL. In the DLL when I try to override OnRenderSizeChanged from the base class HwndHost I get the error that it is being overridden with reduced access. Why is this happening and how can I fix it?

I am following these two tutorials Creating OpenGL Windows in WPF and Walkthrough: Host a Win32 Control in WPF. The latter is from Microsoft.

Here is my function:

virtual void OnRenderSizeChanged(SizeChangedInfo^ sizeInfo) override
        {
            if (m_hDC == NULL || m_hRC == NULL)
                return;

            // Apply DPI correction
            // NOTE: sizeInfo->NewSize contains doubles, so we do the multiplication before
            // converting to int.
            int iHeight = (int)(sizeInfo->NewSize.Height * m_dScaleY);
            int iWidth = (int)(sizeInfo->NewSize.Width * m_dScaleX);

            if (iWidth == 0 || iHeight == 0)
                return;

            wglMakeCurrent(m_hDC, m_hRC);
            glViewport(0, 0, iWidth, iHeight);

            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
            // gluPerspective( 67.5, ((double)(iWidth) / (double)(iHeight)), 1.0, 500.0);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
        }
1 Answers
Related