【发布时间】:2016-08-08 18:13:20
【问题描述】:
后续行动: OpenGL4Net WM_PAINT does not exist?
我还在密切关注:https://sourceforge.net/p/ogl4net/wiki/Tutorials
目前的程序:
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;
}
}
}
}
问:如果我正确实施了教程,对于program.Init();线上的错误System.BadImageFormatException,我该怎么办?
另外:
附加信息:无法加载文件或程序集 'OpenGL4Net, Version=4.3.37.24,Culture=neutral,PublicKeyToken=null' 或其之一 依赖关系。试图加载一个不正确的程序 格式。
这可能是由于警告:
项目的处理器架构不匹配 正在构建的“MSIL”和参考的处理器架构 “OpenGL4Net”、“AMD64”。这种不匹配可能会导致运行时失败。 请考虑更改您的目标处理器架构 通过配置管理器进行项目,以便对齐处理器 您的项目和参考之间的体系结构,或采取 依赖于具有匹配处理器架构的参考 您项目的目标处理器架构。
但是根据:
How do I fix the Visual Studio compile error, "mismatch between processor architecture"?
这应该不是问题。下载 OpenGL4Net DLL 时只有(32 位或 64 位)位选项。
鉴于 Microsoft 中间语言与处理器不同,我尝试在发布模式而不是调试模式下运行,但没有任何区别。
【问题讨论】:
标签: c# .net opengl dll compiler-errors