I did a similar thing in the mid 00's. An R5K Indy can throw a couple hundred flat shaded polygons around at a respectable framerate, depending on their size, and the graphics sub-system installed. There are a couple options, one having just a frame buffer, and at least one other that had onboard geometry hardware.
Indy machines have no texture memory and will perform very poorly on textured graphics. An O2 will perform excellent. It has a shared memory graphics sub-system that can actually handle very large 100mb+ images as textures and do so frame locked to the display. These machines very widely in their overall capability and a lot depends on the option boards installed.
Here is what I remember: (I do not have an IRIX machine to sort out more, but this info should help)
MIPSPro was an additional installation on IRIX. Versions prior to IRIX 6.5.11, I believe, will compile programs and just include nag messages that encourage you to get a license. Later ones refuse to compile. An older MIPSPro is difficult to use on a newer IRIX. You want a newer IRIX for other reasons, like installing more recent Open Source Software, which SGI referred to as "freeware."
GCC and friends are on the Freeware distribution CD. It is likely the packages can also be found online. This will be a fairly old version of GCC today, but should suffice for what you are doing. Ask around at the forum I linked below for other info.
For either compiler, you want to load the full "Development Foundation" distribution CD, which includes header and library files necessary for your program to be compiled. This is necessary whether you use MIPSPro, or GCC.
GCC is recommended, unless your version of IRIX is old enough to make the more permissive version of MIPSPro an option. Even then, you probably want GCC as MIPSPro can be a bit different to work with, though it's well documented.
The Internet Archive has IRIX installation media:
You may find what you need there. You may also benefit by asking this question at one of the more active IRIX communities currently online:
They may have more current libraries and GCC tools to work with. If so, use them.
Edit: I did not make this sufficiently clear: Once you have installed the "Development Foundation" you can then install OSS dev tools however you want or need to and need only point them to the header files needed to build software. It is, in my opinion, easier to start with the SGI inst packages, but a tarball can work just fine too.
Regarding your program: Your first three includes should work. I am not sure about the X related ones. The SGI X Server was a highly customized version of 3WM, called 4dwm. It had extensions to make 3D GL graphics network transparent. (GLX)
A great resource for this kind of thing is the SGI Developer Books. Here's an example:
Those can also be installed via the "Documentation" CD, and as part of the "Development Foundation" CD.
Use "inst" to launch the system software manager from the command line, or the much easier to understand, "swmgr" from any terminal on your Indigo Magic Desktop. All SGI system software, including freeware and the GCC compiler, can be installed via this tool. It's advanced, featuring version management and a lot of installation options. As was typical for many SGI system tools, "swmgr" is just a spiffy GUI front end to "inst", which does the real work.
Newer versions of Software Manager can install right over the Internet via URL, (though I doubt https) and pretty much all versions can install from something like an NFS share. You may be able to mount the CD images on a machine and get the tools onto your SGI that way.
If you burn an actual CD, make sure you use ISO9660 format in order for it to work under all "inst" use cases, including installing a new instance of IRIX on an otherwise blank system.