A follow up to: OpenGL4Net WM_PAINT does not exist?
I am still closely following: https://sourceforge.net/p/ogl4net/wiki/Tutorials
The program as it currently stands:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenGL4NET;
namespace pads2
{
class Program : Form
{
private const int WM_PAINT = 15;
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 WM_PAINT: Render(); break;
default: base.WndProc(ref m); break;
}
}
}
}
Q: Provided that I'm implementing the tutorial correctly, what can I do about the error System.BadImageFormatException
on line program.Init();
?
Additionally:
Additional information: Could not load file or assembly 'OpenGL4Net, Version=4.3.37.24, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
This could be due to the warning:
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "OpenGL4Net", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
However according to:
How do I fix the Visual Studio compile error, "mismatch between processor architecture"?
This should not be an issue. There is only the option of (32 or 64) bit when downloading the OpenGL4Net DLL.
Given that Microsoft Intermediate Language is not the same as a processor, I tried running in release mode instead of debug mode, but it makes no difference.