A lot has changed in MAME since this was written, the official doco is much more up to date than this

The GLSL shaders are possibly the most complete solution to bringing back the authentic feel and look of old school CRTs when retrogaming via emulation. While there have been a few solutions to this in the pasti.e. scanlines, scale2x, scale3x, hq2x, etc none come close to the HLSL shaders (directx) nor GLSL shader (opengl) implementations of current day gaming.

You can try out Mah!Cade a MAME frontend based on Wah!Cade

Back in the days of old I never understood the charge for s-video (8/16bit era) and probably never will. I enjoy the imperfections of the old screens with their slightly offset picture, folded corners etc. It adds character and it's character which is sadly lacking from today's displays .... the digital era, where a dead pixel or cracked screen is the best you can hope for, but I digress.... Failing to locate my NES after moving house forced my son into having his first experience of Super Mario Bros. in emulated form on his laptop. Watching him play on an LCD, I began to yearn for the CRT days. I could have setup one of the old XBOX's connected to an old CRT out in the garage but taking into account space constraints we fell back onto the idea of using his laptop. I began to wonder what GLSL shader could do for bringing back that warm, soft tube look that is lost in today's displays. It was shortly thereafter I found a set of GLSL shaders online (from somewhere? see comments). The CRT curvature in the original GLSL shaders was extreme so that has been toned down somewhat in my version.
Default GLSL Enabled
blktiger_noglsl blktiger_glsl
Black Tiger
outrun_noglsl outrun_glsl
Outrun
pacman_noglsl pacman_glsl
Pac-Man
tmnt_noglsl tmnt_glsl
Teenage Mutant Ninja Turtles
Now thanks to GLSL shaders those wonderful imperfect screens are back on newer displays. To set this up execute the following steps: 1) Download the shader pack 2) Extract the shader pack to ~/.mame/ you should have the following additional directory structure
~/.mame/osd:
CRT-geom_idx16_lut.fsh
CRT-geom_rgb32_dir.fsh
CRT-geom_rgb32_lut.fsh
CRT-geom.vsh
makefile
shader

~/.mame/osd/shader:
genc.sh
glsl_bilinear_idx16_lut.fsh
glsl_bilinear_idx16_lut.fsh.c
glsl_bilinear_rgb32_dir.fsh
glsl_bilinear_rgb32_dir.fsh.c
glsl_bilinear_rgb32_lut.fsh
glsl_bilinear_rgb32_lut.fsh.c
glsl_bilinear.vsh
glsl_general.vsh
glsl_general.vsh.c
glsl_plain_idx16_lut.fsh
glsl_plain_idx16_lut.fsh.c
glsl_plain_rgb32_dir.fsh
glsl_plain_rgb32_dir.fsh.c
glsl_plain_rgb32_lut.fsh
glsl_plain_rgb32_lut.fsh.c
glsl_plain.vsh
3) Add the following lines to the bottom of your mame.ini (may be ~/.mame/mame.ini or /etc/mame.ini)
gl_glsl                   1
gl_glsl_filter            1
glsl_shader_mame0         /home/user/.mame/osd/shader/glsl_plain
glsl_shader_mame1         /home/user/.mame/osd/CRT-geom
Edit the paths for glsl_shader_mame0/1 to match you system. I had to use absolute paths for these two lines, neither the ~ nor $HOME alias would work for loading the shaders. NOTE: You may also set gl_glsl to 0 in the ini and pass -gl_glsl on the command line when starting a game to enable GLSL for certain games. 4.) Start MAME with your favourite game to relive those days of old.

An alternate edit to CRT-geom.vsh has been kindly provided by @p_e_z_z

  // overscan (e.g. 1.02 for 2% overscan)
  overscan = vec2(1.0,1.0);
  // aspect ratio
  aspect = vec2(0.1, 0.1);
  // lengths are measured in units of (approximately) the width of the monitor
  // simulated distance from viewer to monitor
  d = 1.0;
  // radius of curvature
  R = 1.0;
  // tilt angle in radians
  // (behavior might be a bit wrong if both components are nonzero)
  const vec2 angle = vec2(0.0,0.0);
  // size of curved corners
  cornersize = 0.0005;
  // border smoothness parameter
  // decrease if borders are too aliased
  cornersmooth = 2000.0;

Square GLSL retro effects Square GLSL retro effects