Onrendersizechangege offriden的访问误差减少了?

发布于 2025-02-08 08:56:44 字数 1459 浏览 0 评论 0 原文

我通过DLL在WPF中托管Win32 OpenGL窗口。在DLL中,当我尝试从基类 hwndhost 中覆盖 时,我会发现它被降低访问被覆盖。为什么会发生这种情况?如何解决?

我正在关注这两个教程演练:托管WPF中的Win32控件。后者来自微软。

这是我的功能:

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();
        }

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();
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揽月 2025-02-15 08:56:44

一个类,从基类或接口中的任何方法实现虚拟方法无法降低该方法的访问。

使该函数公开已修复。

public:
        virtual void OnRenderSizeChanged(SizeChangedInfo^ sizeInfo) override

A class that implements a virtual method from a base class or any method from an interface cannot reduce the access of that method.

Making the function public fixed it.

public:
        virtual void OnRenderSizeChanged(SizeChangedInfo^ sizeInfo) override
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文