#!/bin/bash

CmdlineGL

This is a simple binary that reads a stream of OpenGL commands as text, renders them to an X11 window, and then writes any user input from the window to standard out. It enables any language capable of reading and writing text to then be able to build interactive graphical applications.

This is an old project I wrote in college. It was my 6th entry in a series of "Abuse of Technology" projects where I would do something absurd that was also sort of cool or intriguing or surprising that it could even work. In this case, I was writing animated OpenGL demos in Bash, though it can be used in conjunction with any language.

The source code is hosted on GitHub. While I'm not planning to actively maintain the code, I'm perfectly willing to review and accept pull requests for new features or which make it compatible with more systems.

Releases

Version Changes Files
2.1.0
2024-01-02
  • Add --geometry option
  • Documentation improvements
CmdlineGL-2.1.0.tar.bz2
README.md
Manual (html)
2.0.0
2018-04-01
  • Replace homebrew font support with ftgl library API
  • Rewrote most parsing code to eliminate some buggy edge cases
  • New quoting syntax for command arguments
  • New Divisor syntax and cglPushDivisor replace cglFixedPt
  • Each type of named object is now in its own namespace
  • Use SDL_image in cglLoadImage for broader image format support
  • Stricter parsing of OpenGL calls with open-end argument lists
  • Default projection sets model farther from near clipping plane
  • Option to disable default projection matrix or viewport
  • Notification for window status events
  • Manual page
  • Converted static hash table generator to perl
  • Overhaul of build scripts, mostly borrowed from daemonproxy
CmdlineGL-2.0.0.tar.bz2
README.md
Manual (html)

What people Are Saying About CmdlineGL...

I'm so glad there are sickos out there doing this stuff so I can read about it.
— PaperCow
This is so stupid, I love it.
— mortelsson
It's the best kind of stupid!
— jaybill
Every day we stray further from God's light.
— MachineGunPablo
My eye won't stop twitching.
— ICanBeAnyone
echo "You're insane, and I love it."
— RobLoach

Not everyone has a Linux desktop, so here's a video

Getting Started

First, you will need a system that has SDL, OpenGL, Glut, and FTGL. If you're compiling from source, you'll also need the headers for all of those, and likely autoconf and Perl. The relevant libraries for Debian-based systems are:

sudo apt-get install \
  libsdl1.2-dev libsdl-image1.2-dev \
  libgl1-mesa-dev libftgl-dev
and for Fedora/RHEL systems are:
sudo yum install \
  SDL-devel SDL_image-devel mesa-libGL-devel \
  mesa-libGLU-devel ftgl-devel

You can build it like normal:

$ ./configure
$ make
$ make install
though there is a convenient Makefile provided so all you actually need to type is "make install".

You can stream to CmdlineGL directly:

$ echo "glClearColor 0 1 0
> glClear GL_COLOR_BUFFER_BIT
> cglSwapBuffers
> " | CmdlineGL >/dev/null

Or you can import every CmdlineGL command into your shell!

$ source CmdlineGL.lib
$ glClearColor '#00FF00'
$ glClear GL_COLOR_BUFFER_BIT
$ cglSwapBuffers
but for more practical applications, see the ./share/examples directory.