I created a regular grid that arises from a 2D image, that is, each pixel has a vertex. There are two four pixel triangles, so I have a triangle in the upper right and lower left. I use vertex and index buffers for this.

Now I dynamically delete triangles / faces on the border of two different types of vertices (according to my application), because otherwise there will be distortions. I wrote a geometric shader that takes a triangle and draws a triangle or nothing (see the first image). The shader recognizes if the triangle is “faulty” (has orange edges) and lowers it.
Now this works great, but I may lose some details due to my vertex geometry. I can add additional triangles to the grid (see. Second image, new triangles with a dashed orange line).

How to do it in OpenGL?
My first idea is to create one square instead of two triangles, check four possible cases of triangles and create these triangles dynamically in a geometric shader. But it can be slow; GL_QUAD is deprecated, and alternatives may be slow. What do you have in mind?
source share