VBO techniques for updating data

Started by tris, June 22, 2010, 19:23:52

Previous topic - Next topic

tris

I'm trying to find the most efficient storage technique for updating vertex data. First i had 2 vbo's per texture; 1 for vertices and 1 for texture cords. I then packed both in to 1 using interleaved coordinates. It works but updates to either one wold require updating the whole vbo because of the way they are group.

My 3rd approach was to pack the single vbo serially like so:
private final float dataCords[] = { 
		//[0],[1] Top Left    		[2],   [3] Top Right	   
		0.0f, 0.0f,                        width, 0.0f,	
		//[4],[5] Bottom Left           //[6], [7] Bottom Right 
		0.0f, height,			width, height,			
		//[8],[9] Top Left		//[10],        [11] Top Right	
		xOff, yOff,	                        widthRatio, yOff,	
		//[12],[13] Bottom Left     //[14],        [15] Bottom Right 
		xOff, heightRatio,		widthRatio, heightRatio,	
	};


This works too and makes updating easier. Is this the best approach for my situation or is there a better way?

Also, say I want to change to texture cordinates to cut the image in half by making the widthRatio 0.5f via glBufferSubData. if I do this during the rendering loop per user request, that would permenantly change the data in the vbo. If i want to temporarily change it for 1 draw and not others, is it better to create a temporary vbo where the modified data is sent and used to render or just keep modifying the original every needed render call?