I get a random contour as an input. I need to transform it into a polygon and display it in 3d space. (A)
Normally, I would do it through a standard ear-clipping algorithm, and the result will be something like (B)
However due to a bug in the graphics drivers for the video card I'm working on (VIVANTE GC 2000), I can only triangulate small shapes like that. The reason is that when rendering, if a vertex of a mesh lies too far outside of frustum to the left or right - the position is calculated incorrectly. This results in wild flickering and deformation of large meshes on the screen. It is a confirmed driver issue, and it doesn't happen on other platforms or even with the older version of drivers for the same videocard. Unfortunately, I can't use the old drivers, and the card manufacturer isn't likely to fix the bug, seeing it's been known for almost a decade.
Here's a relates SO thread going a bit more in-depth of the problem OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?
So I have to use crutches. In other words - I have to split my mesh into several smaller triangles, something like (C) So that at any point in time, the vertexes of the triangles rendered are not outside of frustum too far.
Unfortunately, there's really no way to do it otherwise that I see. I know this is a very inelegant solution, but there really no other way to get around the driver bug.
But I'm stuck at actually doing it. Somehow, I can't wrap my head around how I should generate the triangulated data (A -> C). Can someone help me with an algorithm of splitting/triangulating mesh in such a way or give ideas? Assume that all "squares" are N-by-N squares with N being specified by me.
Or maybe someone has some other suggestions how I could deal with the problem.