Anyone know the codes to draw polygons in fortran. Actually a few points work too.
u can render in fortran?
i am thinking of just a few points should do it, not lines necessary, just the code to setup a coordinate system is good enough, the codes for display and print etc etc
yeah, as far as I know, you can't do that. Its possible you that there's a c library you could use from a fortran program, but thats the only way i can think of doing it. I haven't done that enough times (used c libraries with fortran codes) to really be able to help more than that.
Before the days of graphic interfaces, us old Fortran programmers would print graphs on line printers. We would create a coordinate system based on the points of a printer, 10 characters per inch horizontal, 6 lines per inch vertical. Horizontal was limited to 120 or 132 characters, but vertical was unlimited (OK, limited to one box of paper). Then using a matrix to represent the paper, we would fill in the "dots", and then print it out. To save memory, a single horizontal vector could be used, and what ever functions involved were used to cacluate the "dots" for that rows worth of vertical displacement.
I would assume that modern day Fortran programs with access to graphics mode on monitors would have a draw line function, as they did back in the days of plotters.
last I knew(3 years ago) fortran didn't have rendering capabilities...like franz said you had to port to C(or just dump a data file into C or excel or matlab).
I know you can mix languages through libraries, so I believe that hypothetically you can use C libraries called from fortran to do any rendering you like, but I've never heard of anyone using that capability actually for rendering. Usually some sort of data dump (HDF is common) is used, that is then rendered using something else. The only time I've ever even called C routines in fortran was using code that I didn't even write, so I'm really not familiar with it, any limitations or problems that might arise.
I think franznietzsche is on the right track: dump your data and either use a canned graphics package, or use C/C++ if you want to reinvent the wheel.
OpenGL if you're a wheel-reinventing glutton for punishment.
I avoid going as low-level as OpenGL by using VTK. You can use VTK via C++, or Python if you prefer a more civilized approach to life.
Fortran is one tool. Trying to solve every problem using just one tool is a trap.
"Graphics mode on monitors"? That's when the going was good! Now you have multiple levels of hardware and software between you and the monitor.
You could dump out a text file of numbers and then use a spreadsheet program to import and plot the numbers.
The last graphics monitors I'm aware of were used in arcade games. These could only draw straight lines, and were called vector monitors. In Battlezone, you drove in a tank and all objects were 3-d wire frames.
Unlike plotters, some of the graphic monitors had the ability to draw arcs, but I don't remember the interface. Plotters were really slow at drawing curves, since you had to break them up into a series of small lines.
Most, if not all, older computers (mainframes) with plotters included a Fortran callable library for using the plotters. The choiced for languages in those days was assembly (with various levels of macro capability), Cobol, Fortran, and later, RPG (report generator, an associative language similar to the punched card / line printer processors that you programmed via a matrix board and wires).
I would assume that Microsoft's Fortran can do some Windows graphics, either directly or through a C library interface.
You could download the fortranposix (I think that is the name) library for fortan and it would be connected to gnuplot for graphing. Or you could do like I do:
Write a short script that runs your fortran which makes a data dump, then calls gnuplot to produce pdfs of your results (could be set for screen just as well).
I've been trying to figure our how to call gnuplot from inside my Fortran77 program to save manually opening the dump file and choosing all the plotting parameters each time i want to view the program output. Any idea if / how I can do this?!
gnuplot call from fortran
I just came across the same problem in plotting data produced by my FNCK0 in MINUIT (old f77 program but still very very useful).
I solved it by using :
command = "gnuplot gnucomm"
the (previously declared) string 'command' is executed by the shell.
Gnucomm is the file with the plot command (or anything else) to be executed by GNUPLOT
in my case that file is written within Fortran since my output file may change its name following my input parameters:
OPEN (UNIT=8, FILE= "gnucomm", STATUS= 'UNKNOWN')
WRITE(8,*) "plot '"//TRIM(FILEout)//"','"//TRIM(FILEout)//"'
& us 1:3 w l ,'"//TRIM(FILEout)//"' us 1:4 w i"
This worked nice on my MacBook with gfortran
Using built-in specs.
Configured with: ../gcc-4.3-20070810/configure --enable-threads=posix --enable-languages=fortran
Thread model: posix
gcc version 4.3.0 20070810 (experimental)
Or I guess if you want to get fancy you could try dumping a text file full of SVG. But feeding through a spreadsheet program (or gnuplot as Ulderico suggests) would probably be simpler...
Separate names with a comma.