The order stays the same, I've checked it a million times.
EDIT:
Ugh, I finally solved it. I didn't notice that after I duplicated the vertices they were already in the correct order and I still used the old index array. Duh. Well, it works now
Posted 30 August 2012 - 02:59 AM
Posted 30 August 2012 - 02:41 AM
// Vertices id_vb = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, id_vb); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Vertex.Size() * vertices.Count), vertices.ToArray(), BufferUsageHint.StaticDraw); GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.Size(), Vector3.SizeInBytes * 2); GL.NormalPointer(NormalPointerType.Float, Vertex.Size(), Vector3.SizeInBytes); GL.VertexPointer(3, VertexPointerType.Float, Vertex.Size(), 0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); // Indices id_ib = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, id_ib); GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(sizeof(int) * indices.Count), indices.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
// Bind texture if one is available
if(textures.Count > 0) {
GL.ActiveTexture(TextureUnit.Texture0);
GL.BindTexture(TextureTarget.Texture2D, textures[0].id);
}
// Bind buffers
GL.BindBuffer(BufferTarget.ArrayBuffer, id_vb);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, id_ib);
// Enable client states
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
GL.EnableClientState(ArrayCap.NormalArray);
// Set offsets for buffer data
GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.Size(), Vector3.SizeInBytes * 2);
GL.NormalPointer(NormalPointerType.Float, Vertex.Size(), Vector3.SizeInBytes);
GL.VertexPointer(3, VertexPointerType.Float, Vertex.Size(), 0);
// Draw the elements
GL.DrawElements(BeginMode.Triangles, indices.Count, DrawElementsType.UnsignedInt, 0);
// Disable client states
GL.DisableClientState(ArrayCap.VertexArray);
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.NormalArray);
// Unbind buffers
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindTexture(TextureTarget.Texture2D, 0);
Posted 30 August 2012 - 02:39 AM
// Vertices id_vb = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, id_vb); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Vertex.Size() * vertices.Count), vertices.ToArray(), BufferUsageHint.StaticDraw); GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.Size(), Vector3.SizeInBytes * 2); GL.NormalPointer(NormalPointerType.Float, Vertex.Size(), Vector3.SizeInBytes); GL.VertexPointer(3, VertexPointerType.Float, Vertex.Size(), 0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); // Indices id_ib = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, id_ib); GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(sizeof(int) * indices.Count), indices.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
// Bind texture if one is available
if(textures.Count > 0) {
GL.ActiveTexture(TextureUnit.Texture0);
GL.BindTexture(TextureTarget.Texture2D, textures[0].id);
}
// Bind buffers
GL.BindBuffer(BufferTarget.ArrayBuffer, id_vb);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, id_ib);
// Enable client states
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
GL.EnableClientState(ArrayCap.NormalArray);
// Set offsets for buffer data
GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.Size(), Vector3.SizeInBytes * 2);
GL.NormalPointer(NormalPointerType.Float, Vertex.Size(), Vector3.SizeInBytes);
GL.VertexPointer(3, VertexPointerType.Float, Vertex.Size(), 0);
// Draw the elements
GL.DrawElements(BeginMode.Triangles, indices.Count, DrawElementsType.UnsignedInt, 0);
// Disable client states
GL.DisableClientState(ArrayCap.VertexArray);
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.NormalArray);
// Unbind buffers
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindTexture(TextureTarget.Texture2D, 0);
Posted 30 August 2012 - 02:39 AM
// Vertices id_vb = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, id_vb); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Vertex.Size() * vertices.Count), vertices.ToArray(), BufferUsageHint.StaticDraw); GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.Size(), Vector3.SizeInBytes * 2); GL.NormalPointer(NormalPointerType.Float, Vertex.Size(), Vector3.SizeInBytes); GL.VertexPointer(3, VertexPointerType.Float, Vertex.Size(), 0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); // Indices id_ib = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, id_ib); GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(sizeof(int) * indices.Count), indices.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
// Bind texture if one is available
if(textures.Count > 0) {
GL.ActiveTexture(TextureUnit.Texture0);
GL.BindTexture(TextureTarget.Texture2D, textures[0].id);
}
// Bind buffers
GL.BindBuffer(BufferTarget.ArrayBuffer, id_vb);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, id_ib);
// Enable client states
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
GL.EnableClientState(ArrayCap.NormalArray);
// Set offsets for buffer data
GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.Size(), Vector3.SizeInBytes * 2);
GL.NormalPointer(NormalPointerType.Float, Vertex.Size(), Vector3.SizeInBytes);
GL.VertexPointer(3, VertexPointerType.Float, Vertex.Size(), 0);
// Draw the elements
GL.DrawElements(BeginMode.Triangles, indices.Count, DrawElementsType.UnsignedInt, 0);
// Disable client states
// Disable client states
GL.DisableClientState(ArrayCap.VertexArray);
GL.DisableClientState(ArrayCap.TextureCoordArray);
GL.DisableClientState(ArrayCap.NormalArray);
// Unbind buffers
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindTexture(TextureTarget.Texture2D, 0);
Posted 30 August 2012 - 02:33 AM
Posted 29 August 2012 - 02:27 PM