C# glGenBuffers和glGenTextures始终返回0 安装程序

C# glGenBuffers和glGenTextures始终返回0 安装程序,c#,opengl,C#,Opengl,我正在使用System.Windows.Forms.Form作为窗口源代码。建造商: 表单加载: 在加载方法中,选择设备配置,该配置实际上正在工作。像GL.GetString(GL.GL\u扩展名)这样的调用正在工作。也会加载所有gl方法,因此支持所有使用的方法 表格如下: Application.Initialize(this)初始化所使用的框架(由我编写),并初始化一个默认着色器(正在工作)和一个不工作的模型。 这会导致以后的渲染失败,因为返回句柄无效 框架 我有一个自己的OpenGL包

我正在使用
System.Windows.Forms.Form
作为窗口源代码。建造商:


表单加载:

在加载方法中,选择设备配置,该配置实际上正在工作。像
GL.GetString(GL.GL\u扩展名)
这样的调用正在工作。也会加载所有gl方法,因此支持所有使用的方法


表格如下:

Application.Initialize(this)
初始化所使用的框架(由我编写),并初始化一个默认着色器(正在工作)和一个不工作的模型。 这会导致以后的渲染失败,因为返回句柄无效

框架 我有一个自己的OpenGL包装器,它有所有参数的枚举,以支持开发,而无需多次查看OpenGL引用。例如,方法
glGenBuffers

[MethodGL]
public delegate void glGenBuffers(Int32 count, ArrayBufferHandle[] buffers);
ArrayBufferHandle
定义:

/// <summary>
/// Represents a handle to a buffer
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 4)]
[ComVisible(true)]
public struct ArrayBufferHandle
{
    [FieldOffset(0)]
    UInt32 Handle;
    /// <summary>
    /// Determines if the buffer is valid
    /// </summary>
    public Boolean IsValid { get { return Handle > 0; } }
    /// <summary>
    /// Retrieves the default array buffer
    /// <br>which is used to reset bindings</br>
    /// </summary>
    public static ArrayBufferHandle Default { get { return new ArrayBufferHandle(); } }
    /// <summary>
    /// Retrieves the string representation of the current object
    /// </summary>
    /// <returns>The current object represented as string</returns>
    public override String ToString()
    {
        return String.Format("[ArrayBufferHandle Handle:{0} Valid:{1}]", Handle, IsValid);
    }
}
//
///表示缓冲区的句柄
/// 
[StructLayout(LayoutKind.Explicit,Size=4)]
[ComVisible(true)]
公共结构ArrayBufferHandle
{
[字段偏移量(0)]
UInt32手柄;
/// 
///确定缓冲区是否有效
/// 
公共布尔值有效{get{return Handle>0;}}
/// 
///检索默认数组缓冲区
///
用于重置绑定
/// 公共静态ArrayBufferHandle默认值{get{return new ArrayBufferHandle();}} /// ///检索当前对象的字符串表示形式 /// ///表示为字符串的当前对象 公共重写字符串ToString() { 返回String.Format(“[ArrayBufferHandle:{0}有效:{1}]”,句柄,IsValid); } }
当然,着色器创建正在工作,并使用如上所示的类型

结论 对于我所面临的问题,我想我没有更多的话要说
glGenBuffers
glGenTextures
返回零,我不知道为什么。该设置与我已经使用过的其他设置类似


当然,当不渲染任何模型时,窗口显示为蓝色背景,并且我在使用
glGetError

时没有任何错误。首先,感谢MārtiņšMožeiko引导我走向正确的方向

事实证明,方法
void-glGenBuffer(Int32计数,UInt32[]buffers)
正在工作,但方法
void-glGenBuffers(Int32计数,ArrayBufferHandle[]buffers)
没有工作。两者都有一个传递的4字节/元素数组,但.NET处理它们的方式似乎不同。解决方案很简单:

void glGenBuffers(Int32 count, [Out]ArrayBufferHandle[] buffers)

向数组添加
Out
属性。

您是否尝试过在gl warnings设置为full的情况下通过gDebugger运行程序?(并启用了错误破解)@Necrolis不,还没有,我不知道这个工具存在。我现在就去试试。谢谢。我第三次阅读你的帖子,但仍然不理解你的问题…@PaulMichalik,glGenBuffers和GlgenTexture总是返回0。实际的gl函数是否失败,或者你的包装器是否没有按预期工作?
[MethodGL]
public delegate void glGenBuffers(Int32 count, ArrayBufferHandle[] buffers);
/// <summary>
/// Represents a handle to a buffer
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 4)]
[ComVisible(true)]
public struct ArrayBufferHandle
{
    [FieldOffset(0)]
    UInt32 Handle;
    /// <summary>
    /// Determines if the buffer is valid
    /// </summary>
    public Boolean IsValid { get { return Handle > 0; } }
    /// <summary>
    /// Retrieves the default array buffer
    /// <br>which is used to reset bindings</br>
    /// </summary>
    public static ArrayBufferHandle Default { get { return new ArrayBufferHandle(); } }
    /// <summary>
    /// Retrieves the string representation of the current object
    /// </summary>
    /// <returns>The current object represented as string</returns>
    public override String ToString()
    {
        return String.Format("[ArrayBufferHandle Handle:{0} Valid:{1}]", Handle, IsValid);
    }
}
void glGenBuffers(Int32 count, [Out]ArrayBufferHandle[] buffers)