* @param[in] mvpMatrix Atm working with a 4x4 (full) affine. But anything would work, just take care with the w-division.
* @param[in] view_port_width TODO
* @param[in] view_port_height TODO
* @param[in] image Where to extract the texture from
* @param[in] depth_buffer TODO note: We could also pass an instance of a Renderer here. Depending on how "stateful" the renderer is, this might make more sense.
* @param[in] mapping_type Which Transformation type to use for mapping
* @return A Mat with the texture as an isomap
* // note: framebuffer should have size of the image (ok not necessarily. What about mobile?) (well it should, to get optimal quality (and everywhere the same quality)?)
* @param[in] mvp_matrix Atm working with a 4x4 (full) affine. But anything would work, just take care with the w-division.
* @param[in] viewport_width TODO
* @param[in] viewport_height TODO
* @param[in] image Where to extract the texture from
* @param[in] depth_buffer TODO note: We could also pass an instance of a Renderer here. Depending on how "stateful" the renderer is, this might make more sense.
* @param[in] mapping_type Which Transformation type to use for mapping
* @return A Mat with the texture as an isomap
* // note: framebuffer should have size of the image (ok not necessarily. What about mobile?) (well it should, to get optimal quality (and everywhere the same quality)?)
// Possible improvement: - If only part of the triangle is visible, split it
// - Share more code with the renderer?
Vec4fv0_3d=mesh.vertices[triangleIndices[0]];
Vec4fv1_3d=mesh.vertices[triangleIndices[1]];
Vec4fv2_3d=mesh.vertices[triangleIndices[2]];
Vec4fv0_3d=mesh.vertices[triangle_indices[0]];
Vec4fv1_3d=mesh.vertices[triangle_indices[1]];
Vec4fv2_3d=mesh.vertices[triangle_indices[2]];
Vec4fv0,v1,v2;// we don't copy the color and texcoords, we only do the visibility check here.
// This could be optimized in 2 ways though:
// - Use render(), or as in render(...), transfer the vertices once, not in a loop over all triangles (vertices are getting transformed multiple times)
// - We transform them later (below) a second time. Only do it once.
v0=Mat(mvpMatrix*Mat(v0_3d));
v1=Mat(mvpMatrix*Mat(v1_3d));
v2=Mat(mvpMatrix*Mat(v2_3d));
v0=Mat(mvp_matrix*Mat(v0_3d));
v1=Mat(mvp_matrix*Mat(v1_3d));
v2=Mat(mvp_matrix*Mat(v2_3d));
// Well, in in principle, we'd have to do the whole stuff as in render(), like