Hi,
see this image:
The PROJECTION_MATRIX is setup with:

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

I know each vertex position, and with a function, I project each vertex. I would know the position of each triangles vertex on image. But I obtain strange result, for example for the first two triangles (yellow), I obtain this coordinate:

In OpenGL, the bottom left corner of the viewport is (0,0). To make it top left change the glOrtho call like this glOrtho(-1.0, 1.0, 1.0, -1.0, -1.0, 1.0);.

… or adjust the vertices bottom left. found out recently that f.e. scissor box is operating on bottom-left origin anyways so flipping is necessary in case of top-left origin.

Yes, it’s correct and it’s works. But if in the same function I draw the texture and I generate the coordinate the results is wrong.
When you write that the result is wrong do you mean that you texture appear upside down, or you mean that the projected coordinate are wrong? For the first change your texture coord on the triangle, for the second keep your original gluOrtho parameter and take y = (viewport_height-1) - y.So [0.000000 511.000000] coordinates become [0.0 0.0]. Notice that your coordinate you give above seem strange because if the size of your viewport or image is [512 512] then the pixel coordinate for x and for y vary between [0 511]. If you count your pixel from position 1 to 512 then y = viewport_height - y.