okay, after keeping the issue as an item on my "someday" To Do list the time has come to check it out. Hope this helps and apologies for the spelling mistakes (no time for proofreading... just wrote it in one go):
1. Find out a function in a suitable library to uncompress and read an image (tiff, jpeg, bmp...) into memory, i.e. to let you access the uncompressed image in memory as if it were an array. For example, loadBMP(). There are libraries for any kind of image file (see e.g. http://www.libtiff.org/libtiff.html)
2. Once you have the image allocated as an array, you can leverage OpenGL or DirectX. Let's assume OpenGL. Load the array into the OpenGL space as a texture.
3. Initialize the OpenGL space, and set two reference (coordinate) systems for each vertex:
a) Texture coordinates (texture system): coordinates range from 0 to 1 and stand for the relative location of a vertex with respect to the other. This relative location won't change when transformations are applied. A texture coordinate is defined by a family of functions called gLtextcoord(). You have to call the proper gLtextcoord() function on each vertex of the mesh.
b) Absolute coordinates (absolute or geographic system... the terms are just mine to make them clear!). When triangles are transformed, these coordinates will change according to the applied transformation (as opposed to texture coordinates, which won't change). An absolute coordinate is defined by calling a funtion of the gLVertex() family (gLVertex2s(), gLVertex2f().... depending on if we are in 2D, 3D... you have to look for a suitable one for your case).
To define a list of vertices you have to start with glBegin() and finish with glEnd(), something like this:
glBegin()
for(....){
gLtextcoord(); // define texture coordinate for point i
gLVertex2s(); // luego absolute coordinate for point i
}
glEnd();
4. Apply your transformation using the absolute coordinates, but when plotting the points, use their texture coordinates instead and... there you are: you'll be drawing the texture of that (transformed) triangle (hopefully :)
A skeleton of the app could be like this:
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutCreateWindow("GLUT Test");
glutReshapeWindow(600,600);
glutDisplayFunc(&display);
glutMainLoop();
return EXIT_SUCCESS;
}
where your stuff would go inside the display() function
A handy on-line manual of OpenGL is available at http://www.glprogramming.com/red/