Setup
I’m using System.Windows.Forms.Form as window source. Constructor:
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
Form-Load:
_Device = new Device(this, DeviceConfiguration.SelectConfiguration(Bits.Eight, Bits.Eight, Bits.Eight, Bits.Eight, Bits.Twentyfour, Bits.Eight, true, true), 1024, 768);
Debug.WriteLine(GL.GetString(GL.GL_EXTENSIONS));
base.OnLoad(e);
In the load method the device configuration is selected, which is actually working. Calls like GL.GetString(GL.GL_EXTENSIONS) are working. All gl-methods are loaded too so all used methods are supported.
Form-Shown:
Application.Initialize(this);
RenderSettings = new RenderSettings(this);
Debug.WriteLine("After setup render settings: " + GL.GetErrorDescription());
_Textures[0] = Resources.LoadTexture("Resources\\Buttons\\btn_big_bg_normal.dds");
_Textures[1] = Resources.LoadTexture("Resources\\Buttons\\btn_big_bg_normal.dds");
base.OnShown(e);
_IsShown = true;
The Application.Initialize(this) initializes the framework used ( written by me ) and is also initializing a default shader, which is working, and model which is not working.
This causes the rendering later to fail because the returning handle is invalid.
Framework
I’ve a own OpenGL-wrapper which has enums for all parameters to enable development without looking in the OpenGL-references many times. As example the method glGenBuffers:
[MethodGL]
public delegate void glGenBuffers(Int32 count, ArrayBufferHandle[] buffers);
The ArrayBufferHandle definition:
/// <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);
}
}
Of course the shader creation is working and uses the types like the shown above.
Conclusion
I don’t think i’ve much more to say to the issues i’ve faced. glGenBuffers and glGenTextures returning zero and i don’t know why. The setup seems like others i’ve already used.
Of course the window is shown with a blue background when not rendering any models and i don’t have any errors when using glGetError.
First: Thanks to Mārtiņš Možeiko who led me into the right direction.
As it turns out the method
void glGenBuffer(Int32 count, UInt32[] buffers)is working, but the methodvoid glGenBuffers(Int32 count, ArrayBufferHandle[] buffers)isn’t. Both have a 4-byte / element array which is passed but .NET seems to handle them different. The solution has been simple:Add a
Outattribute to the array.