【问题标题】:OpenGL4Net WM_PAINT does not exist?OpenGL4Net WM_PAINT 不存在?
【发布时间】:2016-12-14 11:49:26
【问题描述】:

我正在尝试让 OpenGL4Net 在 Microsoft Visual Studio 社区 2015 中与 C# 一起使用。

我已经下载了这个文件: https://sourceforge.net/projects/ogl4net/files/Rev.%2037/x64/

并遵循以下说明: https://sourceforge.net/p/ogl4net/wiki/Tutorials/

首先使用控制台应用程序,然后再次使用 Windows 窗体应用程序,因为它似乎要使用其中的窗口,而不是创建自己的窗口。

到目前为止,已经添加了各种引用,form1.cs 保持不变,Program.cs 看起来像这样:

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenGL4NET;

namespace pads2
{
    class Program : Form
    {
        RenderingContext rc;

        static void Main(string[] args)
        {
            Program program = new Program();
            program.Init();
            Application.Run(program);
        }

        // required for open GL
        void Init()
        {
            rc = RenderingContext.CreateContext(this);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        }

        void Render()
        {
            gl.Clear(GL.COLOR_BUFFER_BIT);

            // here is the right place to draw all your scene

            rc.SwapBuffers();
        }

        // change window size
        protected override void OnSizeChanged(EventArgs e)
        {
            gl.Viewport(0, 0, ClientSize.Width, ClientSize.Height);
            // projection matrix may also need adjusting
        }

        // required for open GL
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case Windows.WM_PAINT: Render(); break;
                default: base.WndProc(ref m); break;
            }
        }
    }
}

    /*
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
    /*

编译器似乎对代码末尾的注释不满意,但主要问题是我收到了错误:

命名空间“Windows”中不存在类型或命名空间名称“WM_PAINT”(您是否缺少程序集引用?)

我一直无法在线找到我需要的 WM_PAINT 参考资料,包括 System.Windows 的参考资料也没有帮助。

问:我该如何解决这个问题?我的设置是否正确?

【问题讨论】:

  • private const int WM_PAINT = 15;
  • 哇,谢谢,这出乎意料的简单。你要回答还是要我?

标签: c# .net opengl wm-paint tooling


【解决方案1】:

WM_PAINT 在其 MSDN 条目中有详细描述:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd145213(v=vs.85).aspx

但是文章省略了它的 POD 值,即整数常量“15”。

【讨论】:

    【解决方案2】:

    之前有这个问题,例子忘记添加引用,情况应该是:

     case OpenGL4NET.Windows.WM_PAINT: Render(); break;
    

    (如果代表也允许我会发表评论)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多