Texture sub area ?

All, I’ve looked everywhere for some insight on this, hopefully someone may have done it before and can help.

The problem is that I need to let users load/display very large texture in my application (like Arial photos), anywhere between 1000 and 4000 pixels square. I know I cant do this directly in ogl (powers of 2 and max texture sizes etc.) so I’ve came up with a work around.

The plan is to read the large texture and split it up into N tiles (which have n^2 sizes etc. to keep ogl happy) then render all the tiles in order to make the bigger picture. I have the process working all but one part, that is the calculation of the smaller sub section of the larger image.

I need to be ale to specify an origin point in the large texture and the dimensions of the smaller texture to cut out, then just do the necessary and cut out the smaller image from the larger. See below, given the big texture lx/ly in need to cut out the smaller texture sx/sy in the right format so it makes a sensible image.

                 lx
O -----------------------------------
  |                                   |
  |         sx                        |
  |     o---------                    |
  |     |        |                    |
  |     |        |sy                  | ly
  |     |        |                    |
  |     ----------                    |
  |                                   |
- -----------------------------------

My larger image data can have the format GL_RGBA, GL_RGB, GL_ALPHA etc. The image data is read from file using ‘fread’ and is stored in something like “unsigned char *image”. I need the smaller sub texture back in the same format.

This is where im stuck, with no idea how to do this, I’ve tried a few things but the smaller image data never looks right. I guess this is more a problem for understanding the format of the image data rather than ogl but maybe there’s another way to do this ? Any help or links to example code etc. is very much appreciated.

Thanks in advance
Ewan

[This message has been edited by ewanp (edited 10-12-2001).]

so much for ascii art but i guess you can see what i mean.