gl is gl.getapi (gl.getprocaddress); где GL - это Glinterface от Avalonia.
Очистка и так далее происходит до того, как мой код рендеринга.
Код: Выделить всё
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure()
.UsePlatformDetect()
.WithInterFont()
.UseReactiveUI()
.LogToTrace()
.With(new Win32PlatformOptions()
{
RenderingMode = new List()
{
Win32RenderingMode.Wgl,
Win32RenderingMode.Software,
}
});
< /code>
Код инициализации - < /p>
float heigth = 1;
float width = 1;
// x,y,z
float[] vertices =
{
0.0f, heigth, 0f, // oben
-width, -heigth, 0f, // unten links
width, -heigth, 0f, // unten rechts
};
uint[] indices = [0, 1, 2];
// VAO binding
vao = api.GenVertexArray();
api.BindVertexArray(vao);
// VBO binding
vbo = api.GenBuffer();
api.BindBuffer(GLEnum.ArrayBuffer, vbo);
api.BufferData(GLEnum.ArrayBuffer, vertices.AsSpan(), GLEnum.StaticDraw);
// Vertex-Attributes
api.EnableVertexAttribArray(0);
api.VertexAttribPointer(
index: 0,
size: 3,
type: GLEnum.Float,
normalized: false,
stride: 3 * sizeof(float),
pointer: IntPtr.Zero
);
// EBO binding
ebo = api.GenBuffer();
api.BindBuffer(GLEnum.ElementArrayBuffer, ebo);
api.BufferData(GLEnum.ElementArrayBuffer, indices.AsSpan(), GLEnum.StaticDraw);
api.BindVertexArray(0);
< /code>
Это код рендеринга < /p>
int offset = 0;
api.BindVertexArray(vao);
----> working call
api.DrawArrays(GLEnum.Triangles, 0, 3);
----> not working call
api.DrawElements(GLEnum.Triangles, 3, GLEnum.UnsignedInt, ref offset);
api.BindVertexArray(0);
с помощью Dlavelements:
Подробнее здесь: https://stackoverflow.com/questions/797 ... -but-array