Add support for signed and unsigned integer vertex attributes.

This commit is contained in:
Paul Chote
2023-10-23 18:58:12 +01:00
committed by Gustas
parent 4547f3c2b9
commit 143cd8f856
6 changed files with 30 additions and 10 deletions

View File

@@ -386,6 +386,10 @@ namespace OpenRA.Platforms.Default
int stride, IntPtr pointer);
public static VertexAttribPointer glVertexAttribPointer { get; private set; }
public delegate void VertexAttribIPointer(int index, int size, int type,
int stride, IntPtr pointer);
public static VertexAttribIPointer glVertexAttribIPointer { get; private set; }
public delegate void EnableVertexAttribArray(int index);
public static EnableVertexAttribArray glEnableVertexAttribArray { get; private set; }
@@ -595,6 +599,7 @@ namespace OpenRA.Platforms.Default
glDeleteBuffers = Bind<DeleteBuffers>("glDeleteBuffers");
glBindAttribLocation = Bind<BindAttribLocation>("glBindAttribLocation");
glVertexAttribPointer = Bind<VertexAttribPointer>("glVertexAttribPointer");
glVertexAttribIPointer = Bind<VertexAttribIPointer>("glVertexAttribIPointer");
glEnableVertexAttribArray = Bind<EnableVertexAttribArray>("glEnableVertexAttribArray");
glDisableVertexAttribArray = Bind<DisableVertexAttribArray>("glDisableVertexAttribArray");
glDrawArrays = Bind<DrawArrays>("glDrawArrays");

View File

@@ -13,6 +13,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using OpenRA.Graphics;
namespace OpenRA.Platforms.Default
{
@@ -135,7 +136,10 @@ namespace OpenRA.Platforms.Default
for (ushort i = 0; i < bindings.Attributes.Length; i++)
{
var attribute = bindings.Attributes[i];
OpenGL.glVertexAttribPointer(i, attribute.Components, OpenGL.GL_FLOAT, false, bindings.Stride, new IntPtr(attribute.Offset));
if (attribute.Type == ShaderVertexAttributeType.Float)
OpenGL.glVertexAttribPointer(i, attribute.Components, OpenGL.GL_FLOAT, false, bindings.Stride, new IntPtr(attribute.Offset));
else
OpenGL.glVertexAttribIPointer(i, attribute.Components, (int)attribute.Type, bindings.Stride, new IntPtr(attribute.Offset));
OpenGL.CheckGLError();
}
}