Anybody interested by a GRAPHPAK-like feature using OpenGL?

Let it all hang out

Anybody interested by a GRAPHPAK-like feature using OpenGL?

PostPosted by FDA OSInet » Thu Nov 05, 2015 2:46 am

While using NARS2000 when I am on Windows, I also develop very small C programs under Linux using OpenGL (only 2D yet to keep it as simple as possible, but I am amazed at how blazingly fast and powerful it is).

If I knew how to write an auxiliary processor, I could provide a very crude equivalent to the most basic functions of IBM's APL GRAPHPAK, for instance DRAW and FILL. If somebody knows how how to to it from C, I can also send him/her my C sources. Here is one of them, that I copied into the Wikipedia : ... mme_OpenGL

Color graphics, even in 2D (but 3D is quite easy too, and very well suited to APL when using the GRAPHPAK convention of a 2, 3 of 4-column array : [ink color] x y [optional z]) would be an ideal complement to NARS2000, and there is not much to do once the C programs are available, since the OpenGL library does 99% of the job ! The only part I am unable to do (yet) is interfacing my C programs with NARS2000.

Is anyone interested ?

* colorswap.c -- Compiler avec les options -lglut -lGL -lGLU :
* cc colorswap.c -lglut -lGL -lGLU && ./a.out
* Placer le pointeur dans la fenêtre, puis pressez :
* R G ou B pour changer la couleur du fond
* r g ou b pour changer celle de l'encre
* q pour quitter.
* Ce programme a été écrit sous OpenSuSE avec Geany
* depuis un Sony Satellite G50 qui bootant en Linux sur SSD connecté en USB
* à condition qu'on inhibe le secure boot et qu'on donne la
* priorité de boot à l'USB.

#include <GL/glut.h>

int puceau=1; /* le "once" du langage Eiffel n'existe pas en C */

// Nous avons besoin d'associer une fonction ("callback") à la fenêtre.
// C'est elle qui sera chargée de tout redessiner si nous la redimensionnons

void displayCB(void)

glClear(GL_COLOR_BUFFER_BIT); /* Mettre l'écran à "blanc" */
if (puceau) { glColor3f(0, 0, 1.0); /* Encre bleue la première fois */

// Nous définissons maintenant un polygone fermé de trois points :

glBegin(GL_POLYGON); // "Je commence un polygone"
glVertex2i(100,100); // Coordonnées des trois points
glEnd(); // "J'ai défini le polygone"
glFlush(); // "Maintenant, DESSINER le polygone"

void keyCB(unsigned char key, int x, int y) /* action sur caractère pressé */
if( key == 'q' ) exit(0); // q => "quitter"

if (key == 'R') glClearColor(1, 0, 0, 0); // R G et B : couleur du fond
if (key == 'G') glClearColor(0, 1, 0, 0);
if (key == 'B') glClearColor(0, 0, 1, 0);
if (key == 'Y') glClearColor(1, 1, 0, 0);

if (key == 'r') glColor3f(1, 0, 0); // r g et b : couleur de l'encre
if (key == 'g') glColor3f(0, 1, 0);
if (key == 'b') glColor3f(0, 0, 1);
if (key == 'y') glColor3f(1, 1, 0); // y pour le jaune

displayCB(); // On affiche

int main(int argc, char *argv[])
int win; // Identificateur de fenêtre. Mais il n'y en aura ici qu'une.

glutInit(&argc, argv); /* initialise GLUT */

glutInitDisplayMode(GLUT_RGB); // On travaille en RGB
glutInitWindowSize(500,400); // Fenêtre 500px de large 400px de haut

win = glutCreateWindow("Triangle interactif r/g/b/R/G/B/q"); /* create window */

// Les ordres sont maintenant exécutés dans la fenêtre "win"

glClearColor(0.9, 0.9, 0.2, 0); // Jaune pisseux
gluOrtho2D(0,600,0,600); // On travaillera dans ces coordonnées
glutDisplayFunc(displayCB); // Callback associé à la fenêtre
glutKeyboardFunc(keyCB); // Callback associé au clavier

glutMainLoop(); /* Et on part dans la boucle infinie... */

/* execution never reaches this point */

return 0;
Posts: 24
Joined: Sun Aug 30, 2015 5:07 am

Re: Anybody interested by a GRAPHPAK-like feature using Open

PostPosted by Robert Wallick » Thu Nov 05, 2015 2:10 pm

Hi FDA OSInet,

Once again OSInet, we seem to have very similar or even identical interests - re program goals in mind for APL/APL2. Believe it or not, I've actually developed a Quad-Host system function in C that directly interfaces-to/compiles-within NARS. QuadHOST, as a set of C routines is fully written and it works in NARS. This would/could mean calling external Windows programs (e.g. *.exe programs) as well as directly pulling up web pages in NARS is manifest and possible through use of the in-C-programming-lab System Function QuadHOST. It is not an auxiliary processor, but currently a one-way "call external programs / web pages" 'NARS' APL system function. IBM's APL2 has a similar functionality under System Command )HOST (not a System Function in APL2).

Bob Smith and I are unable to agree to terms of QuadHOST's use and release, hence I have not made QuadHOST available publicly. The differences between Bob Smith's view and mine may appear subtle or unimportant to others such as yourself, yet those individual "copyright ownership" differences are very real, distinct, perhaps even schismatic. I am unwilling to sign over source code rights to Sudley Place Software(SPS) since SPS is not a non-profit corporation, and since there are no guarantees NARS will forever remain FREE and OPEN-SOURCE a la Free Software Foundation.

Perhaps Bob and I might agree to have a compiled version of NARS made available that might include QuadHOST, but he is disposed to other projects at present. In fairness to Bob, I as any newcomer System/Compiler Programmer - also represent a drag on his time and his own distinct development goals and efforts for NARS.

Four of my other perspectives re NARS include that 1) it does not allow full screen menus(which QuadHOST probably solves using external menu builder freeware), 2) NARS is slow to store its workspace(s) to disk, especially when the workspace has over 150 functions or starts to increase geometrically in size or a Network drive storage media is used, 3) NARS lacks a GRAPHPAK capability - which you seem to have solved and 4) NARS is missing an Intelli-Sense auto-appear combo-box drop-down window with Quad-NL(name list) names to auto Tab choose from (which we've discussed in the past).

All the best,
Robert Wallick
Robert Wallick
Posts: 22
Joined: Thu Feb 05, 2015 5:35 pm

Re: Anybody interested by a GRAPHPAK-like feature using Open

PostPosted by FDA OSInet » Fri Nov 06, 2015 1:03 pm

Fine. Is there a repository where we could begin exchanging C programs, possible shell scripts and NARS2000 workspaces between us ?

I shall be quite busy on very different things till December 15th, but should after that date have some time to devote to help in any domain where I could do it, and till the end of February.

In the meantime, I shall have a look at IBM APL2's GRAPHPAK to be as compatible with it as possible, though I shall certainly not be able to rewrite the whole of GRAPHPAK itself. Opening the graphic session ans setting parameters (WINDOW ? VIEWPORT ? OPENGP ? These things are far away in my memory. I just remember that there was a dd vector specifying some elements of the graphic context and I could align on that). DRAW and FILL (acting on matrices) are of course mandatory.

I am not sure that PLOT would be of any help because it is so much easier to export data in CSV form and input it in LibreOffice Calc which offers a lot of charting facilities looking much more professional than GRAPHPAK charts (very useful in the 1970's, but our world and expectations have changed a bit since)..

Ideally, it would be nice to )OUT the IBM APL2 GRAPHPAK DEMO, just )IN it into NARS2000, )COPY the (yet to be written) GLPACK NARS2000 workspace to replace the original low-level primitives and have at least the star and the BLIVET drawn by the OpenGL APIs. I do not know whether it would be useful, but it certainly would be fun to try.

By the way speaking of CSV, any idea about I/O of more sophisticated APL objects in YAML ?
Posts: 24
Joined: Sun Aug 30, 2015 5:07 am

Re: Anybody interested by a GRAPHPAK-like feature using Open

PostPosted by Robert Wallick » Sat Nov 07, 2015 2:44 pm


I am a major proponent of open source software, freeware, exchanging software programs, code, etc. That being said, I would dramatically prefer doing so in a secure, private-NARS/APL-select-members-only environment. I would have greatly preferred some private file/code sharing arrangement affiliated with NARS.

For discussion's sake: Why not simply be fully publicly and entirely open-minded, i.e. free access to everyone, everywhere? There are countries and organizations around the world that are not U.S. or people friendly at all. They do not share software, quite the opposite. They do love to use software/freeware and exploit it for their own not-so-friendly purposes. They hack into U.S. government and corporate systems, etc. Sometimes planes get taken down or IED's explode - the world in its entirety is not overly friendly to a 100% "share-and-share-alike" philosophy.

APL was originally also used by the defense industry and as such - it was in some ways highly classified, in some areas of its use, e.g. cryptology/cryptography, cartography/mapping, missile guidance systems, robotics, artificial intelligence, etc. There was once-upon-a-time - a period when Navy/Army/AF software engineers vied to find the most efficient missile tracking forecast algorithm - I never saw it, but stories abound... APL now being less than cutting-edge technology - as viewed by most IT managers, is no longer viewed primarily as top-secret stuff. On the other hand, some of that former APL aura and industry usage probably has not gone away. I have no reason whatsoever to believe it does not follow APL, thus NARS, even today.

You seem to have a lot of innovative, intelligent, useful thought-provoking and highly interesting ideas. I probably cannot emphasize that enough. That is a huge asset for you personally and professionally.

I am also suggesting some amount of conservatism, careful insight, and care be taken re program sharing, APL and otherwise. Please be careful with whom you share software with. The world is not as open as it should or could be - but there are very valid reasons for that.

Also, as NARS were to improve, as it could and seems to be, NARS might be worth more than being merely free. Kind of like a co-op where contributors might get free access and non-contributors might pay a small fee or potentially use a somewhat reduced functionality version. I don't know. I do not purport to know Bob Smith, nor his intentions, nor his inner sense of guidance for Sudley Place Software. Obviously at least one version of NARS has been and still is - free!

In any event, thank you for sharing your thoughts and ideas. I remain open to some sort of carefully crafted code/file-sharing arrangement. I also remain open to discussion. A toast to software development and APL!

Nice to know you might have more free/available time on/after mid-December!

Best wishes,
Robert Wallick
U.S. Citizen, Programmer, Systems Developer, MBA
Robert Wallick
Posts: 22
Joined: Thu Feb 05, 2015 5:35 pm

Re: Anybody interested by a GRAPHPAK-like feature using Open

PostPosted by FDA OSInet » Mon Nov 09, 2015 10:42 am

Hmm.. concerning security, why not use the good old scheme used from the beginning by UNIX (and event MULTICS before, I guess) ? Allow everybody to write his own NARS2000 workspaces, C programs, possibly shell scripts or even test files, anything, with the following conventions :

1. Only their owner (logged on NARS2000 forum) can create or modify the original files
2. That creator and owner decides if he/she endorses proposed modifications stored in some other place.

Let us remember that nothing really bleeding edge is concerned here yet. The idea is just to help other people building their own things without reinventing the wheel every time, especially in uncompatible ways. I guess that giving NARS2000 some very, very crude (but possibly very useful as well) graphic possibiities will probably not be a threat to the national security of Western countries. And the West has already contributed so much to helping the world of software that a little, very little more, can probably do no harm.

The idea is that NARS2000 could, from a cleverly written language, become an ecosystem. A host for a contributed workspaces population.

(I even wonder if the IBM folks in Santa Teresa lab would not agree to make some non-commercial arrangement with us, because every new user of NARS2000 becomes a new potential user of IBM APL2 whenever he/she needs real performance, use of vectorized processing, and the like. Of course, this could be true of other APL suppliers as well. Just like with drugs, give the first APL for free, and once people get accustomed to it and need to use it in their business, they will complete it by those industrial, expensive - but aimed at performance, not just pedagogy - reasons, I guess).

In 1985, exporting a PC/AT (80286, 1 MB or RAM - not GB ! - and 30 MB of disk to some countries was forbidden by the COCOM. Today, however, nobody would still want to work on such a machine, even a schoolboy. Things are so relative... ;-)
Posts: 24
Joined: Sun Aug 30, 2015 5:07 am

Give me the structure of a NARS2000 array, and get the DRAW

PostPosted by FDA OSInet » Thu Nov 19, 2015 8:19 am

I guess I now have enough rough knowledge to implement a C function that would basically allow an equivalent to the IBM GRAPHPAK's DRAW function for use in NARS2000 (providing someone can handle the interface so it is callable from NARS2000).

Here is how the "zero" version would operate :

Called from APL : DRAW M

Called from C : draw(rows, columns, number_matrix);

The number of rows in the number of points. 1 row represents 1 point.

Number of columns :

If 2 : a set of line segments is drawn from 1st to last point, using a default color.
If 3 : First number is a pen indicator. 0 is pen-up. 1 to 15 mean a color and/or line thickness
If 4 : (reserved for future use) : the last number is a z coordinate

Coordinates :

That very first version would use screen coordinates, opening a window defined by something like window(1920,1200); for that reason, it does not matter much for me (nor OpenGL) whether the matrix provided uses integer or floating-point representation. Choose it as you please, as long as we stick to it. I can add a clear() fuction to clear the window (but also a flush() to allow some basic animation using some moving points).

All that is totally experimental. I just guess it would be fun allowing APL/NARS2000 to make some very basic geometric output, because just looking at arrays in numeric form is kind of cumbersome ;)
Posts: 24
Joined: Sun Aug 30, 2015 5:07 am

NARS2000 and OpenGL : beyond GRAPHPAK

PostPosted by FDA OSInet » Tue Dec 15, 2015 10:45 am

Now that I am getting a little more acquainted with OpenGL, I am also beginning to understand that it would probably be a pity to just use it through GRAPHPAK. Why ? Because GRAPHPAK stays program-directed, while OpenGL also allows much more powerful user-interaction-directed behaviour.

Here is how I am now perceiving a typical OpenGL application :

1) Define the basic data representing the state of your graphics, and the small service functions (kinda "methods") you will need

2) Write the function which will display that structure, many times per second if needed, should changes happen in it

3) Define whichever dynamic keyboard and mouse interactions you want

4) Main program : associate the preceding functions as "callbacks" of the keyboard and the mouse (including button press and/or mere movements of the mouse without any button pressed) and enter an infinite loop. The program is not in control anymore. YOU are in control as the user.

While not as straighforward as the GRAPHPAK approach at first, it could be quickly mastered by a NARS2000 user if NARS2000 comes with a supplied workspace OPENGL containing some basic keyboard, mouse and display functions. The basic OpenGL APIs that would have to be available are mainly glBegin(), glVertex(), glEnd() and glFlush(). The very nature of APL free us from the boring C variants needed to specify whether one uses 2D or 3D, integer of floating-point; scalar or vector : APL can say that to OpenGL without bothering the programmer. In fact, programming anything would become much easier in NARS2000 than in C just for that reason : much less API names to remember.

Comments and ideas welcome :)
Posts: 24
Joined: Sun Aug 30, 2015 5:07 am

Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 0 guests