A rough overview of using Nvidia Optimus on FreeBSD.
Run x11/virtualgl from ports and the rest should work.
as of 20180715, gcc47 has been removed. The following will no longer work.
Initial port/PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192617
make config for libjpeg-turbo.CC=gcc47 and CXX=g++47 beforehand. %LOCALBASE%/lib/.nvidia to %LOCALBASE%/lib/libGL.so! Don't let it do that. /etc/X11/xorg.conf.nv. Mine looks a little like this:Section "ServerLayout"
Identifier "Layout0"
Option "AutoAddDevices" "false"
InputDevice "fake" "CorePointer"
EndSection
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:01:00:0"
Option "NoLogo" "true"
Option "UseEDID" "false"
Option "ConnectedMonitor" "DFP"
EndSection
Section "InputDevice"
Identifier "fake"
Driver ""
EndSection
turn_off_nvidia.sh replacing all _OFF/DOFF/SDOF and so on to read ON instead. Execute it. Now kldload nvidiaX -conf xorg.conf.nv -sharevts -noreset :8 in bg. /opt/VirtualGL/bin/vglrun -ld /usr/local/lib/.nvidia/ -d ":8" glxgearskldunload nvidia, and execute turn_off_nvidia.sh.