<script type='text/javascript' charset='utf-8'> <!-- expandToItem('navTree','mglfunctionreference'); //--> </script> Mgl is a suite of mex/m files for displaying psychophysics stimuli in Matlab. Runs on Mac OS X (G4/5 and Intel) and Linux. Version 1.10

A quick overview

mgl is a set of matlab functions for dispalying 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 both Linux and Mac OS X systems. Stimuli can be displayed full screen or in a window (helpful for debugging on a system that only has one display). With a single command that specifies the distance to and size of a monitor, the coordinate system can be specified in degrees of visual angle, thus obviating the need to explicitly convert from the natural coordinate frame of psychophysics experiments into pixels. The best way to see whether it will be useful to you is to try out the mglTest programs (see 1.2 below) and also the sample experiment testExperiment. A basic “hello world” program can be written in four lines:

Open the screen, 0 specifies to draw in a window. 1 would be full screen in the main display, 2 would be full screen in a secondary display, etc…

>> mglOpen(0);

Select the coordinate frame for drawing (e.g. for a monitor 57 cm away, which has width and height of 16 and 12 cm).

>> mglVisualAngleCoordinates(57,[16 12]);

draw the text in the center (i.e. at 0,0)

>> mglTextDraw('Hello World!',[0 0]);

The above is drawn on the back-buffer of the double-buffered display so to make it show up you flush the display (this function will wait till the end of the screen refresh)

>> mglFlush;

To close an open screen:

>> mglClose;

What is in the mgl distribution

  • mgl/mgllib: The main distribution that has all functions for displaying to the screen.
  • mgl/task: A set of higher level routines that set up a structure for running tasks and trials. Relies on functions in mgl/mgllib. You do no need to use any of these functions if you just want to use this library for drawing to the screen.
  • mgl/utils: Various utility functions.

GNU General Public License

These programs are free to distribute under the GNU General Public License. See the file mgl/COPYING for details.

Recompiling mgl

For G4/5 based macs you should not need to recompile the distribution as it comes with precompiled .mexmac files.

However, if you want to use the code on linux or if when you first start using the functions they do not work or cause an obvious error like a segmentation fault, then you may want to recompile. This requires mex to be setup properly on your machine. At a minimum you will need to have the apple developer tools installed on your machine (XCode) The command to recompile is:

» mglMake(1);

If all else fails, how to get back control over the display?

If you can't do mglClose, you can always press:

option-open apple-esc

this will quit your matlab session as well.

Can I get access to all OpenGL functions?

We have only exposed parts of the OpenGL functionality. If you need to dig deeper to code your stimulus, consider writing your own mex file. This will allow you to use the full functionality of the OpenGL library. To do this, you could start by modifying one of our mex functions (e.g. mglClearScreen.c) and add your own GL code to do what you want and compile.

Printing the wiki help pages

You can print out all the wiki help pages at once, by using this link.

This is a test. Delete this line later. Added from GRU.

software/mgl/gettingstarted.txt · Last modified: 2009/05/01 13:32 (external edit) Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0