initial copy & paste from GLPlot