Ich versuchte banch von Linien (variieren Grund- und einfachste Sache) mit VBO als folloiwng zu zeichnen:OpenGL mit OpenTK: Wie ersetzt man nicht funktioniert GL.EnableClientState (ArrayCap.ColorArray)?
struct VertexColor
{
public Vector2d vertex;
public uint color;
//...
}
//...
Draw(){
GL.EnableClientState(ArrayCap.ColorArray);
GL.EnableClientState(ArrayCap.VertexArray);
GL.BindBuffer(BufferTarget.ArrayBuffer, lineVbo.VboID);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, lineVbo.EboID);
GL.VertexPointer(2, VertexPointerType.Double, BlittableValueType.StrideOf(lineList.ToArray()), 0);
GL.ColorPointer(4, ColorPointerType.UnsignedByte, BlittableValueType.StrideOf(lineList.ToArray()), 16);
GL.DrawElements(PrimitiveType.Lines, lineVbo.NumElements, DrawElementsType.UnsignedInt, 0);
}
Es funktionierte gut auf meinem PC, sondern auf anderen DrawElements warf „access memory Verletzung“, das war wahrscheinlich wegen der Verwendung von glEnableClientState (nach ähnlichen Fragen zu SO).
ich es mit neuen Draw ersetzt (über Shader, aber eigentlich brauche ich keine Shader in meinem Programm):
Shader.Bind(shader); //Shader is a helper class that works correctly
GL.BindBuffer(BufferTarget.ArrayBuffer, lineVbo.VboID);
GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Double, false, BlittableValueType.StrideOf(lineList.ToArray()), 0);
GL.EnableVertexAttribArray(0);
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.UnsignedByte, false, BlittableValueType.StrideOf(lineList.ToArray()), 16);
GL.EnableVertexAttribArray(1);
GL.BindBuffer(BufferTarget.ArrayBuffer, lineVbo.EboID);
GL.DrawElements(PrimitiveType.LineStrip, lineVbo.NumElements, DrawElementsType.UnsignedInt, (IntPtr)0);
Fragment-Shader gibt einen Fehler „Fehler: 29718: 48252: '': Speicher Qualifier nicht gültig mit Layout-Qualifikations id“:
#version 330 core
layout(location = 1) in vec4 fragmentColor;
out vec4 color;
void main(){
color = fragmentColor;
}
Wie kann ich diesen Fehler zu überwinden oder EnableClientState in anderer Weise ersetzen?