OpenGL4Net WM_PAINT does not exist?

本文关键字:not exist does PAINT WM OpenGL4Net | 更新日期: 2023-09-27 18:01:15

我正在尝试让OpenGL4Net在Microsoft Visual Studio community 2015中与c#一起工作。

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

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

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

到目前为止,已经添加了各种引用,form .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());
        }
    }
    /*

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

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

我一直无法找到什么参考我需要WM_PAINT在线,包括系统的参考。Windows没有帮助。

问:我如何解决这个问题,我设置正确吗?

OpenGL4Net WM_PAINT does not exist?

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

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

文章省略了它的POD值,为整型常量"15"。

之前遇到过这个问题,示例忘记添加引用,情况应该是:

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

(如果rep允许我也会评论)