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:
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.