小编Ini*_*aJr的帖子

在 winforms 中显示 OpenTk.GLControl

我一直在尝试在 C# winforms 中显示 OpenGl 图形,并且偶然发现了一个非常有用的 NuGet 包,称为 OpenTK。我按照OpenTK 的“学习”选项卡上的介绍性教程进行操作,并且能够渲染一些简单的形状。该教程非常有帮助,但它是基于在 GameWindow(与主窗体分开)中显示 OpenGL 图形。我发现可以通过使用 OpenTK.GLControl 控件直接在主窗体中显示 OpenGL 图形。为了正常工作,我安装了附加的 NuGet 包 OpenTK.GLControl。我在 Form1.Designer.cs 文件中添加了该控件,并在 Form1.cs 中定义了其必要的方法。但是,我看不到 GLControl。

我的代码中是否缺少关键步骤,或者包/dll 文件是否有问题?

Form1.Designer.cs:

    private void InitializeComponent()
    {
        /* Generic Form1 code */

        this.gLControl.Location = new System.Drawing.Point(-2, 0);
        this.gLControl.Name = "gLControl";
        this.gLControl.Size = new System.Drawing.Size(500, 300);
        this.gLControl.TabIndex = 0;
        this.gLControl.VSync = false;
        this.gLControl.Load += new System.EventHandler(this.GLControl_Load);
        this.gLControl.Resize += new System.EventHandler(this.GLControl_Resize);
        this.gLControl.Paint += new System.Windows.Forms.PaintEventHandler(this.GLControl_Paint);
    }

    private OpenTK.GLControl gLControl;
Run Code Online (Sandbox Code Playgroud)

表格1.cs:

    private bool _loaded;
    private Shader …
Run Code Online (Sandbox Code Playgroud)

c# opengl graphics winforms opentk

4
推荐指数
1
解决办法
6853
查看次数

标签 统计

c# ×1

graphics ×1

opengl ×1

opentk ×1

winforms ×1