If the goal is education and maths, I suggest the following. Start by getting a good computer graphics textbook; the kind of thing that undergraduate CS majors would read. I don't own one (not a UI person), but a friend used to have a good one in the 1980s.
If you really insist on using the hardware frame buffer, then the techniques that aragats suggested sound reasonable. Another approach I would suggest: Find some framework (like Kivy or Qt5) which is capable of using the frame buffer under FreeBSD, and read the source code so as to see how they do it. That will give you a starting point for the techniques experienced programmers use; then combine it with reading documentation for the API they use, and combining it with a good textbook.
An user interface can be of course programmed in Java, Qt, GTK,..., to be used with a mouse / pointer.
A graphical user interface and the computer mouse have become most often used with a personal computer.
It is however important to keep things like it should, not to use QT for framebuffer, if it is not necessary.
There is a quote attributed to Einstein that may have arisen as a paraphrase of the above quote, commonly given as “Everything should be made as simple as possible, but no simpler,” "Everything should be made as simple as possible, but not simpler", or “Make things as simple as possible, but not simpler.”
fb looks stable. It looks sufficiently available for next coming years.
It runs without need of Xorg installation or additional graphical env, like coming wayland (or other).
Framebuffer does not need numerous layers of layers of libraries.
It does not depends on drivers for GL.
It does not require or need regular code updates/maintainance.
It has a clean usage of the memory and resource, and it allows to protect our environment.
It allows to do not use Wayland, SDL, QT, GTK,...
For some specific areas of applications, a low specs-computer like a PI for educative purpose can display highly complex 2D plots/outputs of simulations. For simple graphical applications and specific requirements, it can be a convenient, versatile option, due to previously mentioned advantages.
Furthermore, it is cheap, compilable, and widely available.
But, in term of longevity, much better is Microsoft MSDOS or FreeDOS. But it needs the environment to run it. MSDOS would be more reliable, because it runs on any kind of platforms and it will be stable over years.
Last but not least, low-power consumption devices and Energy Efficient Computing are important for education, for students, ... academic. The earlier getting used to it, the better. It protects our planet.