MGL is a library of functions that work from within Matlab to draw graphics, images, shapes into a specially created window. It uses/wraps the most commonly used graphics standard (OpenGL). Timing is very good and you can finely control getting input from the keyboard, mouse, and other devices. It also hooks up very neatly to different kinds of eye trackers and has some other nice features making it a good choice for programming up stimuli for experiments. From the MGL website:
mgl is a set of matlab functions for displaying full screen visual stimuli from matlab. It is based on OpenGL functions, but abstracts these into more simple functions that can be used to code various kinds of visual stimuli. It can be used on Mac OS X systems […] http://gru.stanford.edu/doku.php/mgl/overview
Here is a very basic description of what happens when you draw graphics to the display (in the OpenGL drawing model):
If you have MGL installed properly (try help mglOpen
and see if you get any help returnd on the command line), you can try the following
% open a screen (and associated "context")
mglOpen(0)
% change the coordinate frame, so we can specify
% everything in degrees of visual angle, rather than
% pixels
mglVisualAngleCoordinates(57,[16 12]);
% clear the background to a gray
mglClearScreen([0.5 0.5 0.5])
% draw a rectangle at 0,0 with w=2, h=4
% and color (RGB) [0 1 1]
mglFillRect(0, 0, [2 4], [0 1 1]);
% now swap out the buffers, so we can see what we have drawn
% in the back buffer
mglFlush();
% some time later, close the window
mglClose()
Return to the description of this week’s aims
The MGL website and the MGL github repo
Some detailed information about OpenGL. You can also find lots and lots of tutorials via google and youtube.
Wikipedia article on visual angle