Problem with updating a VBO

Ello JGO,

I’m trying to draw multiple differently coloured cubes without creating seperate render classes for each colour. The way I’ve gone about doing this is by updating the VBO with the correct colour before rendering it. (side question: is this actually faster than multiple classes with each a different colour?) I based my code on the “The Quad updating a VBO with BufferSubData” http://www.lwjgl.org/wiki/index.php?title=The_Quad_updating_a_VBO_with_BufferSubData tutorial on the lwjgl wiki.

The problem I’m having is that I get an invalid value error in my matrix logic every time I include the following piece of code before my rendering;
c is the cube I’m currently rendering.

// Set the right colour
			GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
			// Apply and update vertex data
			for (int i = 0; i < vertices.length; i++) {
				VertexData vertex = vertices[i];
				
				float[] rgba = c.getRGBA();
				vertex.setRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
				 
				// Put the new data in a ByteBuffer (in the view of a FloatBuffer)
				FloatBuffer vertexFloatBuffer = verticesByteBuffer.asFloatBuffer();
				vertexFloatBuffer.rewind();
				vertexFloatBuffer.put(vertex.getElements());
				vertexFloatBuffer.flip();
				 
				GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, i * VertexData.stride, verticesByteBuffer);
			}

The rgba values assigned by default (in RenderColourCube.setupVertices() seem to work without problems)
Complete RenderColourCube code is found here: http://pastebin.java-gaming.org/8c317474c72
ColourCube class is found here: http://pastebin.java-gaming.org/c31775c4279

I guess it’s time to dive into shaders then!

Solutions/tips to this problem still welcome ofc.

Wow, that was easier to implement than I thought… Thanks a lot!
If you don’t mind me asking, what’s your resource for learning GLSL?

Here’s a good resource from Lighthouse3d.

No, dont use Lighthouse, there are errors.

Thanks! I’ll be careful in Lighthouse3D waters, although the one from github looks very good.