public void SetVertexAttribute(string objectName, string shaderName, int index, string vertexPropertyName, int stride, int offset) { GL.BindVertexArray(_objectsHandleDictionary[objectName].ObjectHandle); int location = GL.GetAttribLocation(_shaderHandleDictionary[shaderName], vertexPropertyName); if (location != -1) { GL.EnableVertexAttribArray(location); GL.VertexAttribPointer(location, 3, VertexAttribPointerType.Float, false, stride, IntPtr.Add(IntPtr.Zero, offset)); GL.VertexAttribDivisor(location, 0); } }
public void SetInstanceAttribute(string objectName, string shaderName, int index, string instancePropertyName, int stride, int offset) { GL.BindVertexArray(_objectsHandleDictionary[objectName].ObjectHandle); int location = GL.GetAttribLocation(_shaderHandleDictionary[shaderName], instancePropertyName); if (location != -1) { for (int i = 0; i < 4; i++) { GL.EnableVertexAttribArray(location + i); GL.VertexAttribPointer(location + i, 4, VertexAttribPointerType.Float, false, stride, IntPtr.Add(IntPtr.Zero, i * offset)); GL.VertexAttribDivisor(location + i, 1); } } }