I have been using Fortran form 20 years. I used a lot of comercial and non comercial compilers under Linux and Windows. I use Fortran and OpngGL as a graphics solution. FTN95 is going to be the most useful and powerful program because he is fast, 'small' (no Visual Studio is neede) logical in use and install etc. OpenGL+ClearWin is the best solution I have ever seen. But one thing is still needed Writing the .BMP to file from OpenGL window. I have looked for the solution for many years and I didn't find answer. I have answer but written in C+OpenGL code from OpenGL Super Bible but I can't rewrite it with succes to FNT95. It is any chanse that there is somebody who can help me. With this solution FTN95 seems to be the best Fortran compiler I have ever seen.
Writing the .BMP File
*As they say in the car repair manuals, “Installation is the reverse of removal.” To write a .BMP file, you simply add a BITMAPFILEHEADER structure to the bitmap in memory and write it to disk. Listing 11-10 is the SaveDIBitmap function.
Listing 11-10 SaveDIBitmap function*
int SaveDIBitmap(char filename, / I - File to save to */ BITMAPINFO info, / I - Bitmap information */ void bits) / I - Bitmap pixel bits */ { FILE fp; / Open file pointer / long size, / Size of file / infosize, / Size of bitmap info / bitsize; / Size of bitmap pixels / BITMAPFILEHEADER header; / File header / /
- Try opening the file; use 'wb' mode to write this binary file. / if ((fp = fopen(filename, 'wb')) == NULL) return (-1); if (info->bmiHeader.biSizeImage == 0)/ Figure out the bitmap size / bitsize = (info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 7) / 8 * abs(info->bmiHeader.biHeight); else bitsize = info->bmiHeader.biSizeImage; infosize = sizeof(BITMAPINFOHEADER); switch (info->bmiHeader.biCompression) { case BI_BITFIELDS : infosize += 12; / Add 3 RGB doubleword masks / if (info->bmiHeader.biClrUsed == 0) break; case BI_RGB : if (info->bmiHeader.biBitCount > 8 && info->bmiHeader.biClrUsed == 0) break; case BI_RLE8 : case BI_RLE4 : if (info->bmiHeader.biClrUsed == 0) infosize += (1 << info->bmiHeader.biBitCount) * 4; else infosize += info->bmiHeader.biClrUsed * 4; break; }; size = sizeof(BITMAPFILEHEADER) + infosize + bitsize; /
- Write the file header, bitmap information, and bitmap pixel data…
/
header.bfType = 'MB'; / Non-portable… sigh /
header.bfSize = size;
header.bfReserved1 = 0;
header.bfReserved2 = 0;
header.bfOffBits = sizeof(BITMAPFILEHEADER) + infosize;
if (fwrite(&header, 1, sizeof(BITMAPFILEHEADER), fp) <
sizeof(BITMAPFILEHEADER))
{
/
- Couldn't write the file header - return… / fclose(fp); return (-1); }; if (fwrite(info, 1, infosize, fp) < infosize) { /
- Couldn't write the bitmap header - return… / fclose(fp); return (-1); }; if (fwrite(bits, 1, bitsize, fp) < bitsize) { /
- Couldn't write the bitmap - return… / fclose(fp); return (-1); }; /
- OK, everything went fine - return… */ fclose(fp); return (0); }