Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualManabreak

Posted 30 August 2012 - 02:59 AM

Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

The order stays the same, I've checked it a million times. Posted Image I've even tried disabling texturing and texture coordinates alltogether, it didn't help, so I really doubt it's the texture coordinates messing up the geometry.

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 :D

#5Manabreak

Posted 30 August 2012 - 02:41 AM

Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

The order stays the same, I've checked it a million times. Posted Image I've even tried disabling texturing and texture coordinates alltogether, it didn't help, so I really doubt it's the texture coordinates messing up the geometry.

Here's the code I use to initialize the vertex and index buffers (the data is the same as in the first post):
// 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);

And here's the rendering code:
// 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);

#4Manabreak

Posted 30 August 2012 - 02:39 AM

Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

The order stays the same, I've checked it a million times. Posted Image

Here's the code I use to initialize the vertex and index buffers:
// 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);

And here's the rendering code:
// 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);

#3Manabreak

Posted 30 August 2012 - 02:39 AM

Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

The order stays the same, I've checked it a million times. Posted Image

Here's the code I use to initialize the vertex and index buffers:
// 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);

And here's the rendering code:
// 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);

#2Manabreak

Posted 30 August 2012 - 02:33 AM

Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

The order stays the same, I've checked it a million times. :)

#1Manabreak

Posted 29 August 2012 - 02:27 PM

Umm, the problem is quite clear when you look the images - the geometry is f'd up. It's the same object from the exact same perspective.

PARTNERS