Initial setup
- Add the mgl directory to your Matlab path. In Matlab:
>> addpath(genpath('MYPATH/mgl'));where MYPATH should be replaced by the path to your version of mgl.
- Make sure to enable access for assistive devices so that you can use the function mglGetKeyEvent, mglGetMouseEvent, mglPostEvent, mglSimulateRun and mglEatKeys.
- There are a few functions (mglEditScreenParams and mglDoRetinotopy) that require the mrTools GUI functions to be installed. If you are not already using mrTools, you can download the following:
svn checkout http://cbi.nyu.edu/svn/mrTools/trunk/mrUtilities/MatlabUtilities mrToolsUtilities
and add that to your MATLAB path (with MYPATH replaced with the path to your version of the mrToolsUtilities):
>> addpath(genpath('MYPATH/mrToolsUtilities'));
Test your setup
You can see what functions are available by doing (in matlab):
>> help mgl
After downloading, you may wish to try the mglTest programs (e.g. mglTestDots, mglTestTex, etc….).
If these functions don't work or you are running on Linux (version 1.5 only), then you may need to recompile. This may especially be necessary if you are running an older version of matlab (we run Matlab version >= 7.3 on Mac OS >= 10.4.8). We have found that mex files created on Matlab 7.3 do not run on matlab 14.1 for instance (if you run -nojvm you will see that it complains that it cannot find a dynamic link library for the mex functions – if you run with the matlab desktop it will just crash the system). If this happens to you simply recompile and you should be good to go.
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. The command to recompile is:
» mglMake(1);
The mglMake command simply runs mex on all the .c files in the mgl/mgllib directory – you can do this by hand (e.g. mex mglPrivateOpen.c), if you prefer.
Note that this requires mex to be setup properly on your machine. On a Mac OS X machine, at a minimum you will need to have the apple developer tools installed (XCode) http://developer.apple.com/tools/. On linux, you will need a compatible version of gcc (older versions of gcc can be found here).
If all else fails, how to get back control over the display?
If you can't do mglClose, you can always press:
option-command-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.
Mailing List
If you want to subscribe to an email list which will make (very infrequent) announcements about major changes to mgl, you can do so from http://cbi.nyu.edu/mailman/listinfo/mgl-announce. Note that this is a moderated email list to which you will not be able to make posts, only receive announcements.