I am interested in rendering to a texture, but want to be able to keep my code as cross platform compatible as possible. I know in Windows one may render to a DIBitmap which may then be used as a texture, but the code seems WAY too windows dependant. Is there a way of doing this that is cross platform compatible, or is there a way to get this accomplished in a similar way with X and (hopefully) Macintosh?
Yes. All textures have same format. They are 2D arrays of pixels, aligned in 1D memory as row after row. Therefore your texture has its beginning address (within a pointer) where you can access individual pixels with this formula:
adr= first_pix_addr + (Y * width + X);
The rest is bitmap header which is platform dependent. For example Win32 BMP has headers describing the bitmap, but it also contains a pointer to the actual pixels. If you wish to use crossplatform textures, use TGA or RAW formats. Bitmap headers are just structures that get written into files to describe the bitmap.
Hope this helps.
There is no need of using DIB to render to textures, and reading pixels is slow as hell.
Just do the render and use glCopyTexSubImage.
See my tutorial on NeHe (#36 if i can remember) for an easy and quite fast render to texture method…
hope it helps