问题描述
我找到了一个解决方案来解决我在OpenGL中遇到的问题,但这全都是用GL 4.5编写的,而我编写的应用程序必须是OS 3.0支持的GL 3.0代码。通过在docs.GL上进行引用,并将其转换回我所熟悉的3.0代码,我已经能够翻译大多数代码。
我在理解下面的代码时有些挣扎,所以我只是想知道是否有人能够向我指出正确的方向。
vertexArray
vertexBuffer
indexBuffer
都是int
GL.VertexArrayVertexBuffer(vertexArray,vertexBuffer,IntPtr.Zero,Unsafe.SizeOf<ImDrawVert>());
GL.VertexArrayElementBuffer(vertexArray,indexBuffer);
GL.EnabLevertexArrayAttrib(vertexArray,0);
GL.VertexArrayAttribBinding(vertexArray,0);
GL.VertexArrayAttribFormat(vertexArray,2,VertexAttribType.Float,false,0);
GL.EnabLevertexArrayAttrib(vertexArray,1);
GL.VertexArrayAttribBinding(vertexArray,1,8);
GL.EnabLevertexArrayAttrib(vertexArray,2);
GL.VertexArrayAttribBinding(vertexArray,4,VertexAttribType.UnsignedByte,true,16);
编辑:如果有人想知道,我会在C#中使用OpenTK。
解决方法
对于以后偶然遇到此特定问题的任何人,我必须阅读GL 4.5代码的说明,并将其与GL 3.0代码进行匹配。
对于此特定代码段,它变为:
GL.BindVertexArray(vertexArray);
GL.BindBuffer(BufferTarget.ArrayBuffer,vertexBuffer);
GL.BindBuffer(BufferTarget.ElementArrayBuffer,indexBuffer);
GL.EnableVertexAttribArray(0);
GL.VertexAttribPointer(0,2,VertexAttribPointerType.Float,false,Unsafe.SizeOf<ImDrawVert>(),0);
GL.EnableVertexAttribArray(1);
GL.VertexAttribPointer(1,8);
GL.EnableVertexAttribArray(2);
GL.VertexAttribPointer(2,4,VertexAttribPointerType.UnsignedByte,true,16);