private static List <OpenGLVertex> UVMDVerticesToWindowVertices(IList <ThreeD.Vertex> vertices, UVTXFile?uvtx) { List <OpenGLVertex> vertexDataList = new List <OpenGLVertex>(); for (int i = 0; i < vertices.Count; i += 3) { OpenGLVertex v1 = ConvertSingleVertex(vertices[i + 0], uvtx); OpenGLVertex v2 = ConvertSingleVertex(vertices[i + 1], uvtx); OpenGLVertex v3 = ConvertSingleVertex(vertices[i + 2], uvtx); Vector3 normal = Vector3.Cross(v2.position - v1.position, v3.position - v1.position).Normalized(); v1.normal = normal; v2.normal = normal; v3.normal = normal; //v1.texCoord = new Vector2(0, 0); //v2.texCoord = new Vector2(0, 1); //v3.texCoord = new Vector2(1, 0); vertexDataList.Add(v1); vertexDataList.Add(v2); vertexDataList.Add(v3); } return(vertexDataList); }
private void Buffer(OpenGLVertex[] data) { using (new Bind(this)) { Count = data.Count(); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(data.Length * BlittableValueType.StrideOf(data)), data, BufferUsageHint.StaticDraw); int size; GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size); if (data.Length * BlittableValueType.StrideOf(data) != size) throw new ApplicationException("Vertex data not uploaded correctly"); } }