Help with Grid and Terrain

I’m trying to make some terrain with a grid that looks up the height and sets all the triangles with the Y that has this point as a shared coordinate. My code Is included and so is an image of the result, which has only the one triangle being affected. For now I am not worried about memory efficiency.

void makeVertexGrid(int row, int column)
{
	
	int i = 0;
	float firsttriangle[3][3] = { {1.,.5,-5.},  
								  {-1.,.5,5.}, 
								  {-1.,.5,-5.} }; 
	
	float secondtriangle[3][3] = { {1,.5,-5  }, 
								 {1,.5,5},   
								 {-1,.5,5} }; 
	//rows
	for (int r = 0; r < 8 ; r++)
	{
		if (r > 0) 
			{
			//next colum so add 10 z units each time
			firsttriangle[0][2] = (firsttriangle[0][2] + 10.0f);
			firsttriangle[1][2] = firsttriangle[1][2] + 10.0f;
			firsttriangle[2][2] = firsttriangle[2][2] + 10.0f;
			secondtriangle[0][2] = secondtriangle[0][2] + 10.0f;
			secondtriangle[1][2] = secondtriangle[1][2] + 10.0f;
			secondtriangle[2][2] = secondtriangle[2][2] + 10.0f;
		
			firsttriangle[0][0] = 1.f; //firsttriangle[0][1] = .5f;
			firsttriangle[1][0] = -1.f; //firsttriangle[1][1] = .5f;
			firsttriangle[2][0] = -1.f; //firsttriangle[2][1] = .5f;
			secondtriangle[0][0] = 1.f; //secondtriangle[0][1] = .5;
			secondtriangle[1][0] = 1.f; //secondtriangle[1][1] = .5;
			secondtriangle[2][0] = -1.f; //secondtriangle[2][1] = .5;
			}
		for (int c = 0 ; c<  30; c++)
		{
			// X
			g_vertex_buffer_data[i++] = firsttriangle[(c % 3)][0]++;
			firsttriangle[(c % 3)][0]++;
			//Y
			g_vertex_buffer_data[i++] = gridForY(r + 5, c + 1); 
			//Z
			g_vertex_buffer_data[i++] = firsttriangle[c % 3][2];
		}

		for (int c = 0 ; c < 30; c++)
		{
			g_vertex_buffer_data[i++] = secondtriangle[(c % 3)][(0)]++;
			secondtriangle[(c % 3)][(0)]++;
			g_vertex_buffer_data[i++] = gridForY(r + 5, c + 1);
			g_vertex_buffer_data[i++] = secondtriangle[c % 3][2];

		}

	}

}

My idea was to get this working and than get help / manage the terrain as quads instead of triangles.

What do I need to do to get this point shared by all the triangles that share this coordinate?

Also, my goal was to get some experience with C++ projects so I can get a job. I chose a ball that moves on a rotated terrain. Am I being to ambitious? I’m not sure if there is enough sample code / help to learn this. Could you advise me? OpenGL is interesting.

Thank you,
Josheir

image

Just to explain: the two double array triangles are the three vertices, for each triangle, one in each row : x y z.

Thanks for your time,

Josheir