Okay so I have a weird problem. I'm using Java, LWJGL, and GLSL.

Basically heres the problem.

This code gets me this result - http://inferno.codebrainshideout.net/Images/glslbug2.png

public class Triangle { //Triangle coordinates public Vertex a, b, c; //Triangle normals public Vertex i, j, k; //Triangle texture coordiantes public Vertex u, v, w; //Triangle Material public Material mat; //Model that this triangle belongs too. public Model model; //// constructor and other methods here ///// public void draw() { mat.glMaterialSet(); glVertexAttrib3f(glGetAttribLocation(GraphicsCore.program, "indices"), (float)a.weights[0].frame.index, 0, 0); glBegin(GL_TRIANGLES); glTexCoord3d(u.x, u.y, u.z); glNormal3d(i.x, i.y, i.z); glVertex3d(a.x, a.y, a.z); glTexCoord3d(v.x, v.y, v.z); glNormal3d(j.x, j.y, j.z); glVertex3d(b.x, b.y, b.z); glTexCoord3d(w.x, w.y, w.z); glNormal3d(k.x, k.y, k.z); glVertex3d(c.x, c.y, c.z); glEnd(); } }

But if I move glVertexAttrib3f() inside of the glBegin() I get this - http://inferno.codebrainshideout.net/Images/glslbug1.png

public class Triangle { //Triangle coordinates public Vertex a, b, c; //Triangle normals public Vertex i, j, k; //Triangle texture coordiantes public Vertex u, v, w; //Triangle Material public Material mat; //Model that this triangle belongs too. public Model model; //// constructor and other methods here ///// public void draw() { mat.glMaterialSet(); glBegin(GL_TRIANGLES); glVertexAttrib3f(glGetAttribLocation(GraphicsCore.program, "indices"), (float)a.weights[0].frame.index, 0, 0); glTexCoord3d(u.x, u.y, u.z); glNormal3d(i.x, i.y, i.z); glVertex3d(a.x, a.y, a.z); glTexCoord3d(v.x, v.y, v.z); glNormal3d(j.x, j.y, j.z); glVertex3d(b.x, b.y, b.z); glTexCoord3d(w.x, w.y, w.z); glNormal3d(k.x, k.y, k.z); glVertex3d(c.x, c.y, c.z); glEnd(); } }

What did I do wrong? I've seen people change attributes during there glBegin in examples. Why does it literally destroy my model when I do it?

This happens with any attribute I try to change, regardless of the data in it. Basically if I use glVertexAttrib() in any way inside of glBegin I get this problem.

I need to change the indices attribute for each vertex in the triangle, but I can't do that because any attributes I change inside of glBegin causes that to happen. What do?