OpenGL4Net WM_PAINT does not exist?

血红的双手。 提交于 2020-01-07 02:18:41

问题


I'm trying to get OpenGL4Net working with C# in Microsoft Visual Studio Comunity 2015.

I've downloaded this file: https://sourceforge.net/projects/ogl4net/files/Rev.%2037/x64/

And followed these instructions: https://sourceforge.net/p/ogl4net/wiki/Tutorials/

At first with a console application but then starting again with a Windows Form application as it seems as if it was going to be using the window from that as opposed to making its own.

So far the various refrances have been added, form1.cs is untouched and Program.cs looks like this:

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

The compiler seems unhappy about the comment at the end of the code, however the main issue is that I recieve the error:

The type or namespace name 'WM_PAINT' does not exist in the namespace 'Windows' (are you missing an assembly reference?)

I've been unable to find what reference I need for WM_PAINT online, including a reference for System.Windows did not help.

Q: How can I solve this and am I setting this up correctly?


回答1:


WM_PAINT is described in detail in its MSDN entry:

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

The article however omits its POD value, being the Integer constant "15".




回答2:


Had this problem earlier, the example forgets to add the reference, the case should be:

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

(Would comment if rep allowed me too)



来源:https://stackoverflow.com/questions/38833678/opengl4net-wm-paint-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!