FruitTetris.cpp
// When the current tile is moved or rotated (or created), update the VBO containing its vertex position data.
When the current tile is moved or rotated (or created), update the VBO containing its vertex position data.
When the current tile is moved or rotated ( or created ) update the VBO containing its vertex position data .
void updatetile()
{
	glBindBuffer(GL_ARRAY_BUFFER, vboIDs[4]);
	for (int i = 0; i < 4; i++)
	{
		GLfloat x = tilepos.x + tile[i].x;
		GLfloat y = tilepos.y + tile[i].y;
		vec4 p1 = vec4(33.0 + (x * 33.0), 33.0 + (y * 33.0), 0.4, 1.0);
		vec4 p2 = vec4(33.0 + (x * 33.0), 66.0 + (y * 33.0), 0.4, 1.0);
		vec4 p3 = vec4(66.0 + (x * 33.0), 33.0 + (y * 33.0), 0.4, 1.0);
		vec4 p4 = vec4(66.0 + (x * 33.0), 66.0 + (y * 33.0), 0.4, 1.0);
		vec4 newpoints[6] = { p1, p2, p3, p2, p3, p4 };
		glBufferSubData(GL_ARRAY_BUFFER, i * 6 * sizeof(vec4), 6 * sizeof(vec4), newpoints);
	}
	glBindVertexArray(0);
}
void updatetile ( ) { glBindBuffer ( GL_ARRAY_BUFFER , vboIDs [ 4 ] ) ; for ( int i = 0 ; i < 4 ; i ++ ) { GLfloat x = tilepos . x + tile [ i ] . x ; GLfloat y = tilepos . y + tile [ i ] . y ; vec4 p1 = vec4 ( 33.0 + ( x * 33.0 ) , 33.0 + ( y * 33.0 ) , 0.4 , 1.0 ) ; vec4 p2 = vec4 ( 33.0 + ( x * 33.0 ) , 66.0 + ( y * 33.0 ) , 0.4 , 1.0 ) ; vec4 p3 = vec4 ( 66.0 + ( x * 33.0 ) , 33.0 + ( y * 33.0 ) , 0.4 , 1.0 ) ; vec4 p4 = vec4 ( 66.0 + ( x * 33.0 ) , 66.0 + ( y * 33.0 ) , 0.4 , 1.0 ) ; vec4 newpoints [ 6 ] = { p1 , p2 , p3 , p2 , p3 , p4 } ; glBufferSubData ( GL_ARRAY_BUFFER , i * 6 * sizeof ( vec4 ) , 6 * sizeof ( vec4 ) , newpoints ) ; } glBindVertexArray ( 0 ) ; }
When the current tile is moved or rotated (or created), update the VBO containing its vertex position data.
When the current tile is moved or rotated ( or created ) update the VBO containing its vertex position data .
// Bind the VBO containing current tile vertex positions. // Calculate the grid coordinates of the cell. // Create the 4 corners of the square whose vertices are using location in pixels. // These vertices are later converted by the vertex shader. // Two points are used by two triangles respectively. // Put new data in the VBO.