diff -burN orig/vncviewer/argsresources.c new/vncviewer/argsresources.c
--- orig/vncviewer/argsresources.c	2005-07-04 13:40:22.000000000 -0400
+++ new/vncviewer/argsresources.c	2007-02-15 14:38:36.000000000 -0500
@@ -1,3 +1,6 @@
+/* Copyright (c) H. Andres Lagar-Cavilla, University of Toronto, 2006-2007
+ * Modifications to vncviewer code made in the context of the vmgl project
+ */
 /*
  *  Copyright (C) 2002-2003 Constantin Kaplinsky.  All Rights Reserved.
  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
@@ -225,7 +228,11 @@
    XtOffsetOf(AppData, grabKeyboard), XtRImmediate, (XtPointer) False},
 
   {"autoPass", "AutoPass", XtRBool, sizeof(Bool),
-   XtOffsetOf(AppData, autoPass), XtRImmediate, (XtPointer) False}
+   XtOffsetOf(AppData, autoPass), XtRImmediate, (XtPointer) False},
+   
+  {"glStubPort", "GlStubPort", XtRInt, sizeof(int),
+   XtOffsetOf(AppData, glStubPort), XtRImmediate, (XtPointer) 7000},
+
 };
 
 
@@ -253,7 +260,8 @@
   {"-nojpeg",        "*enableJPEG",         XrmoptionNoArg,  "False"},
   {"-nocursorshape", "*useRemoteCursor",    XrmoptionNoArg,  "False"},
   {"-x11cursor",     "*useX11Cursor",       XrmoptionNoArg,  "True"},
-  {"-autopass",      "*autoPass",           XrmoptionNoArg,  "True"}
+  {"-autopass",      "*autoPass",           XrmoptionNoArg,  "True"},
+  {"-glStubPort",     "*glStubPort",        XrmoptionSepArg, 0},
 
 };
 
diff -burN orig/vncviewer/Imakefile new/vncviewer/Imakefile
--- orig/vncviewer/Imakefile	2003-03-12 11:20:28.000000000 -0500
+++ new/vncviewer/Imakefile	2007-02-15 14:38:35.000000000 -0500
@@ -1,3 +1,5 @@
+## Copyright (c) H. Andres Lagar-Cavilla, University of Toronto, 2006-2007
+## Modifications to vncviewer code made in the context of the vmgl project
 
 #ifdef SunArchitecture
 EXTRA_DEFINES = -D__EXTENSIONS__
@@ -12,7 +14,8 @@
 
 ZLIB_INC = -I/usr/local/include
 JPEG_INC = -I/usr/local/include
-INCLUDES = -I../include -I. $(ZLIB_INC) $(JPEG_INC) -I/usr/include
+VMGLSTUB_INC = -I../../cr/stub-daemon/libvmglstubdaemon
+INCLUDES = -I../include -I. $(ZLIB_INC) $(JPEG_INC) $(VMGLSTUB_INC) -I/usr/include
 VNCAUTH_LIB = ../libvncauth/libvncauth.a
 ZLIB_LIB = -L/usr/local/lib -lz
 #ifdef OSF1Architecture
@@ -21,9 +24,10 @@
 #else
 JPEG_LIB = -L/usr/local/lib -ljpeg
 #endif
+VMGLSTUB_LIB = ../../cr/dist/lib/libvmglstubdaemon.a -lpthread
 
 DEPLIBS = XawClientDepLibs $(VNCAUTH_LIB)
-LOCAL_LIBRARIES = XawClientLibs $(VNCAUTH_LIB) $(ZLIB_LIB) $(JPEG_LIB)
+LOCAL_LIBRARIES = XawClientLibs $(VNCAUTH_LIB) $(ZLIB_LIB) $(JPEG_LIB) $(VMGLSTUB_LIB)
 
 SRCS = \
   argsresources.c \
diff -burN orig/vncviewer/vncviewer.c new/vncviewer/vncviewer.c
--- orig/vncviewer/vncviewer.c	2004-01-13 09:22:05.000000000 -0500
+++ new/vncviewer/vncviewer.c	2007-02-15 14:38:36.000000000 -0500
@@ -1,3 +1,6 @@
+/* Copyright (c) H. Andres Lagar-Cavilla, University of Toronto, 2006-2007
+ * Modifications to vncviewer code made in the context of the vmgl project
+  */
 /*
  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
  *
@@ -115,6 +118,11 @@
 
   DesktopInitAfterRealization();
 
+  /* Spawn daemon thread to listen to vmgl libs */
+  if (appData.glStubPort == 7000)
+    appData.glStubPort += (vncServerPort-5900);
+  daemonStart(desktopWin, (unsigned short) appData.glStubPort, NULL);
+
   /* Tell the VNC server which pixel format and encodings we want to use */
 
   SetFormatAndEncodings();
diff -burN orig/vncviewer/vncviewer.h new/vncviewer/vncviewer.h
--- orig/vncviewer/vncviewer.h	2004-03-11 13:14:40.000000000 -0500
+++ new/vncviewer/vncviewer.h	2007-02-15 14:38:35.000000000 -0500
@@ -1,3 +1,6 @@
+/* Copyright (c) H. Andres Lagar-Cavilla, University of Toronto, 2006-2007
+ * Modifications to vncviewer code made in the context of the vmgl project
+  */
 /*
  *  Copyright (C) 2000, 2001 Const Kaplinsky.  All Rights Reserved.
  *  Copyright (C) 2000 Tridia Corporation.  All Rights Reserved.
@@ -40,6 +43,8 @@
 #include "rfbproto.h"
 #include "caps.h"
 
+#include "vmgl-stub-daemon.h"
+
 extern int endianTest;
 
 #define Swap16IfLE(s) \
@@ -110,6 +115,9 @@
   Bool useX11Cursor;
   Bool autoPass;
 
+  /* vmgl */
+  int glStubPort;
+
 } AppData;
 
 extern AppData appData;
