Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Old Fortran with Updated OpenGL

Classically_Trained
1,488 Views

I'd appreciate some guidance from those who have had a better perspective on changes in OpenGL over the last decade or so.  I have a number of legacy Fortran programs that make use of OpenGL.  I know Fortran well, but the developer of the basic connections to OpenGL is no longer around.  It appears that he used f90gl/glut to create the basic graphics that we needed.

We were able to compile using old compilers and the techniques this fellow used up until early 2017 when the powers that be felt that we needed to update software.  This obliterated our ability to compile and use these olds ways to connect to OpenGL.  So it falls to me as the one with the most grey in my beard to figure out how to re-enable our ability to modify these programs with OpenGL.

After a year of fussing, I now have at least "Intel Parallel Studio XE 2018 Update 1 Composer Edition for Fortran Windows" and am able to compile.  That was not a small effort.  But now I press forward to OpenGL.  

I'm gathering that GLUT is no longer a realistic/modern bridge between Fortran and OpenGL.  I've certainly reviewed the samples Intel provides with Parallel Studio, though it looks pretty foreign to my eyes.  I'd welcome some advice on how to approach a new "bridge" or what I need to learn to implement OpenGL with these old programs. 

I did begin some tutorials at learnopengl.com, but this takes a route of GLFW/GLAD that seems more complex than what I need.  Do I just need to push through it?

Thanks for helping the old dog learn new tricks.

 

0 Kudos
1 Solution
andrew_4619
Honored Contributor II
1,488 Views

Well glut is still around at opengl.org and you should be able download and build that in the latest ifort. How much glut do you use? I personally do not use glut as my applications just use the windows SDK. I do have windows that are rendered with open gl but I have my own routines for mouse and key input to those OGL windows all other user interaction is via normal Windows menu's and modeless dialogs from the main window.  That maybe too much work.... Describe what you need to do in OGL, all the newer fragment shader stuff is not that accessible in fortran stuff like GLEW is best used but I have not seen a Fortran implementation of that. But do you actually need that? 

View solution in original post

0 Kudos
12 Replies
andrew_4619
Honored Contributor II
1,489 Views

Well glut is still around at opengl.org and you should be able download and build that in the latest ifort. How much glut do you use? I personally do not use glut as my applications just use the windows SDK. I do have windows that are rendered with open gl but I have my own routines for mouse and key input to those OGL windows all other user interaction is via normal Windows menu's and modeless dialogs from the main window.  That maybe too much work.... Describe what you need to do in OGL, all the newer fragment shader stuff is not that accessible in fortran stuff like GLEW is best used but I have not seen a Fortran implementation of that. But do you actually need that? 

0 Kudos
JVanB
Valued Contributor II
1,488 Views

The problem with glut is that it can't access the printer. I used to have an example of setting up a canvas on Windows on my website before it was destroyed by vandals and thieves.  I had a partial implementation of GLEW in Fortran that was within a couple of days of being a full implementation before distractions intervened.  My implementation of OpenGL is sort of like f03gl but it's a little better because it uses the Win32 API rather than glut so it can output to printers and files and it also uses generic interfaces when applicable.  Since it uses f03 interop it works with gfortran as well as ifort.  I looked at vulkan early on but it wasn't supported on my system back then so there wasn't much I could do about supporting it.  Perhaps things have changed in the interim.  If I had a stable website to put this stuff on perhaps I could try to figure out what state the project is in and post it for community availability.  I'm kind of at loose ends and broke just now so if you are local to me it might be possible to consult on your specific problem.

 

0 Kudos
Classically_Trained
1,488 Views

Thanks for the initial thoughts to both of you.  Most of what I'm dealing with is just points and lines in 2D for OpenGL.  I'm not so concerned about printing at this point. 

I did see that I can still download GLUT, but I thought that would be unable to get it to work with the more recent Windows OS's or new compilers based on things I read elsewhere.  It looks like the original code I'm dealing with was written with glut 1.2.8.  I assume to try the later 1.2.15 (which I understand to still be ancient by modern standards).  I'll investigate further, if you think that will be my easiest way forward.  

0 Kudos
JVanB
Valued Contributor II
1,488 Views

Does the glut from opengl.org support 64-bit Windows? I have used a freeglut from http://pinyotae.blogspot.com/2010/05/ that comes in both 32- and 64-bit flavors.

 

0 Kudos
andrew_4619
Honored Contributor II
1,488 Views
I do not think opengl.org supports 64-bit Windows. @RO - What did you do with Glew? Did you convert C headers to make a fortran interface? I remember looking at this a few years back but deciding there was quite a bit of work needed. It got put on in the back burner but it would be interesting to take it up again at some point.
0 Kudos
JVanB
Valued Contributor II
1,488 Views

I wrote a Fortran program that reads the C headers and then writes out Fortran code that has the C interop interfaces, a structure that has Fortran procedure pointers for all the C functions (actually subroutines in the Fortran sense) and a class constructor that uses one call to LoadLibrary and as many as it takes to GetProcAddress and C_F_PROCPOINTER to point those procedure pointer components at the desired functions, if found. The reason for this approach is that a canvas that writes to the screen doesn't necessarily have the same version of OpenGL or use the same functions as a canvas that writes to the printer or a file, and using a derived type like this permits different instances to be around simultaneously for different canvases. That said, I have never been able to have two different OpenGL instances around at the same time, although that may just be due to a bug in my OpenGL code.

There really isn't a unique translation of C headers to Fortran modules and there is a problem when the argument to the C function is a pointer. All such instances could in principle be translated to type(C_PTR) by value on the Fortran side, but it seems useful to take into account the precise level of indirection implied so as to make the Fortran code that invokes OpenGL extensions more natural. Fortran might not have been to best choice of language for the parser, but I like to keep the number of languages in a given project to a minimum because it simplifies the build environment. There may be specifications in some different format that the C headers are ultimately generated from, and if I had access to such specifications it might mean that it would take less work to account for the levels of indirection of the pointer arguments.

 

0 Kudos
andrew_4619
Honored Contributor II
1,488 Views
Interesting to know that RO. It is not something that is hot on my todo list at the moment but I may come back to this. They seem to have removed the option to message forum users BTW does anyone know why?
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,488 Views

Do either/any of you have good experiences to say about using HDF5/HDFView or similar capability tool for graphing (in particular 3D). I have been using the old ArrayVisualizer/ArrayViewer (which was based on an earlier version of HDF) , it still works but is a bit touchy. When I added OpenGL (principally via GLUT) it was sorely lacking in capabilities. ArrayVisualizer/ArrayViewer permitted my to ad-hoc add charts, graphs during simulation runs as well as open multiple views during simulation.

Jim Dempsey

0 Kudos
andrew_4619
Honored Contributor II
1,488 Views

I have never used HDF5/HDFView. Sorry!

0 Kudos
andrew_4619
Honored Contributor II
1,488 Views

Repeat Offender wrote:
I wrote a Fortran program that reads the C headers and then writes out Fortran code that .....

Hi RO I note that you aren't on the forum that often these days it seems but if you see this post I  would be interested in making contact. I was looking at the "GLEW" issue again today and it seems you have already done some of the heavy lifting already in this area.....

0 Kudos
JVanB
Valued Contributor II
1,488 Views

@andrew_4619 I'm kind of busy for the next couple of days but I would like to look at some of my old OpenGL code again if you might find it useful. It's a pity that we can't send PMs any more as an email exchange would help with collaboration.

 

0 Kudos
andrew_4619
Honored Contributor II
1,488 Views

Repeat Offender wrote:

@andrew_4619 I'm kind of busy for the next couple of days but I would like to look at some of my old OpenGL code again if you might find it useful. It's a pity that we can't send PMs any more as an email exchange would help with collaboration.

:-) My email is andrewatcadfildotcom

0 Kudos
Reply