Opengl не рендеринг элементов, а массив [закрыто]C#

Место общения программистов C#
Ответить
Anonymous
 Opengl не рендеринг элементов, а массив [закрыто]

Сообщение Anonymous »

im использует silk.net внутри Avalonia и класс OpenGlControlBase с C# и VisualStudio 2022. < /p>
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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»