Turning a 2D array of points into a mesh (or Wireframe)

So I’m working with a terrain generation algorithm (Midpoint Displacement) to create a random landscape. Problem I’m having with it, is that I cannot for the life of me figure out how to get the points to display as a wireframe. I’ve tried using polygon mode, lines, triangles, but nothing gives me the correct result, as the end of one row will be connected to the beginning of the next, or when I try triangles, it works like line strip just spiky.

I’m new to 3D and OpenGL, but not Java. I finished a 2D game very easily and I want to begin work on a future senior design project. I know the algorithm works, as it displays well as just a point cloud.

Any help appreciated, sorry for the beginner question, figure this would be the place to ask. Thanks for any help.

I don’t quite understand the problem.
You are able to get points to display correctly with a algorithm, but you cant draw lines to connect them?

Well let me show you how I’m drawing.

for(int i = 0; i < heightMap.length; i++)
		{
			glBegin(GL_LINE_STRIP);
			for(int j = 0; j < heightMap[i].length; j++)
			{
				glVertex3f(heightMap[i][j].x, heightMap[i][j].y, heightMap[i][j].z);
			}
			glEnd();
		}

So this draws lines for each row. But what I want is a connected mesh. I realize that the code I provided will not do this, but so have many other methods I have tried. So I’m wondering if I’m missing something about creating a mesh or wireframe.