VAO Rendering

So I made a system that proceduraly generates a VAO. I have a method finalizeModel() which does everything to the model that needs to be done. So I enable vertex attib array. I was thinking… say someone wants to load the VAO back up and add another attrib, would it be a fault if someone where to run finalizeModel() again? As per calling GL20.glEnableVertexAttribArray(i); twice.


	public static Model finalizeModel() {
		for (int i=0; i<current_vbos.length; i++)
			GL20.glEnableVertexAttribArray(i);
		GL30.glBindVertexArray(0);
		return null;
	}
	
	public static Model load2DModel(float[] positions, float[] texture_coords, int[] indices) {
		startNewModel(2, 1);
		pushAttributeBuffer(0, 2, positions);
		pushAttributeBuffer(1, 2, texture_coords);
		pushIndexBuffer(indices);
		finalizeModel();
		return storeModel(new Model(current_model, current_vbos, current_offshore_vbos, indices.length));
	}

no

Also i can’t help but notice that you typing GL20. GL30. every time you call lwjgl. Tip if you statically import the library you won’t have to put the GL** calls before everything. eg import static org.lwjgl.opengl.GL11.;
Also if you are using eclipse add "org.lwjgl.opengl.GL11.
" (or whatever) to you favourites to make static importing easier. :slight_smile:

While I appreciate the info, nothing will change there. I remember when I hated typing more than I needed, but it’s overly ugly to hide all namespaces. Alongside the real reason is if I were to use static imports, I wouldn’t remember what versions kept what. So it’s just a reminder for me. To be honest, I might rejar opengl with this style: GL11.enable(); over GL11.glEnable();

You can call glEnableVertexAttribArray(n) any number of times you want, it’s just going to enable that vertex attribute array. If you call it twice, that vertex attribute array will still be enabled. The only way to disable it is to use glDisableVertexAttribArray(n), so don’t worry :slight_smile:

Thank you for the nice explanation. I didn’t want to make a call that will double anything, but to test this is pretty… hard to do because things on things aren’t apparent.

http://pastebin.java-gaming.org/11db92c574115
Got me a nice little procedural ModelLoader class :slight_smile: