0

Microsoft Visual Studio Comunity 2015 で OpenGL4Net を 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());
        }
    }
    /*

コンパイラはコードの最後のコメントに不満を持っているようですが、主な問題は次のエラーが表示されることです。

タイプまたは名前空間名「WM_PAINT」が名前空間「Windows」に存在しません (アセンブリ参照がありませんか?)

System.Windows の参照を含め、WM_PAINT に必要な参照をオンラインで見つけることができませんでした。

Q: どうすればこれを解決できますか? また、正しく設定していますか?

4

2 に答える 2

0

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".

于 2016-08-08T18:24:24.700 に答える
0

以前にこの問題があった場合、例では参照を追加するのを忘れています。ケースは次のようになります。

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

(担当者も許可してくれたらコメントします)

于 2016-12-07T16:54:07.637 に答える