3

maybe the question is simple but I'm using OpenTK with WinForms , the problem is I can't find GLcontrol in the toolbox , so I added it manually in Form1.Designer.cs , this is the code #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        glcontrol1 = new OpenTK.GLControl();
        this.SuspendLayout();
        // 
        // glControl1
        // 

        // 
        // Form1
        // 
        this.Controls.Add(glcontrol1);
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(584, 561);     
        this.Name = "Form1";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);

    }

    #endregion
    OpenTK.GLControl glcontrol1;

the problem is when I open Form1 in design mode , It shows these messages "could not load type OpenTK.ToolkitOptions from assembly ..." "the variable glcontrol1 is either undeclared or not assigned " I'd like a way to add GLcontrol to toolbox , anyone knows how ?

niceman
  • 2,653
  • 29
  • 57
  • this is the call stack in case needed : at OpenTK.GLControl..ctor(GraphicsMode mode, Int32 major, Int32 minor, GraphicsContextFlags flags) at OpenTK.GLControl..ctor() – niceman Nov 19 '14 at 16:24

1 Answers1

3

Double check your project references, you need both OpenTK.dll and OpenTK.GLControl.dll.

Adding GLControl to the WinForms toolbox is covered under "Building a Windows.Forms + GLControl based application" in the documentation.

To begin with, create a Form on which you will place your GLControl. Right click in some empty space of the Toolbox, pick "Choose Items..." and browse for OpenTK.GLControl.dll. Make sure you can find the "GLControl" listed in the ".NET Framework Components", as in the image below.

Adding GLControl to the Toolbox

Then you can add the GLControl to your form as any .NET control. A GLControl named glControl1 will be added to your Form.

The Fiddler
  • 2,726
  • 22
  • 28
  • thank you , now I have another problem , when I drag GLcontrol to the form , the same messages appear : could not load type OpenTK.ToolkitOptions from assembly at OpenTK.GLControl..ctor(GraphicsMode mode, Int32 major, Int32 minor, GraphicsContextFlags flags) at OpenTK.GLControl..ctor() – niceman Nov 20 '14 at 15:31
  • someone told me maybe the problem in my OpenTK , so I installed it but the same problem appears ! , and the strange thing is that I opened my project in another computer and it worked , maybe it's my windows , though it used to work , I have Windows 8.1 x64 and the other computer's Windows 7 x86 I think . – niceman Nov 20 '14 at 15:32
  • It may be that you have more than one versions of OpenTK lying around and Visual Studio is getting confused. Navigate to OpenTK/Binaries/OpenTK/Release and run `Examples.exe`. Do the examples work? If they do, (a) copy-paste OpenTK.dll and OpenTK.GLControl.dll directly to your project, (b) remove the exist OpenTK references from your project, and (c) add the dlls you just copied as project references. – The Fiddler Nov 20 '14 at 20:13