Tuesday, 22 April 2014

How to make Qt's QApplication startup incredibly slow

If you want this code:

QApplication a(argc, argv);

...to take minutes instead of seconds, just at the Qt binary path to your library search paths:

QCoreApplication::addLibraryPath( qtpath + "/bin" );

I've no idea why!

Saturday, 19 April 2014

Recursive C++ include processor for GLSL and other C-style languages

The important part here is how and where we insert #line directives. C-style preprocessors interpret this as telling them where to look, and in what source file, if there's an error or warning to be reported, e.g.

#line 12 "C:/code/media/shaders/myshader.glsl"

We put one of these at the top of each included file, plus the main file. And we put one after each included file is inlined to tell the preprocessor we're back in the parent. Thus instead of the useless GL shader compiler message:
0(4) : warning C7555: 'varying' is deprecated, use 'in/out' instead

- we get a useful one like this:
../../media/shaders/myshader.glsl(4) : warning C7555: 'varying' is deprecated, use 'in/out' instead

And in Visual Studio, you can double-click on this line in the Output window, it will zoom straight to the offending line!

void ProcessIncludes(std::string &src,std::string &filenameUtf8)
{
	size_t pos=0;
	src=src.insert(0,base::stringFormat("#line 0 \"%s\"\r\n",filenameUtf8.c_str()));

	int next=(int)src.find('\n',pos+1);
	int line_number=0;
	while(next>=0)
	{
		std::string line=src.substr(pos+1,next-pos);
		int inc=line.find("#include");
		if(inc==0)
		{
			int start_of_line=(int)pos+1;
			pos+=9;
		int n=(int)src.find("\n",pos+1);
		int r=(int)src.find("\r",pos+1);
			int eol=n;
			if(r>=0&&r<n)
				eol=r;
			std::string include_file=line.substr(10,line.length()-13);
			src=src.insert(start_of_line,"//");
			// Go to after the newline at the end of the #include statement. Two for "//" and two for "\r\n"
			eol+=4;
			std::string includeFilenameUtf8	=GetFileLoader()->FindFileInPathStack(include_file.c_str(),shaderPathsUtf8);
			std::string newsrc=loadShaderSource(includeFilenameUtf8.c_str());
			ProcessIncludes(newsrc,includeFilenameUtf8);
			//First put the "restore" #line directive after the commented-out #include.
			src=src.insert(eol,base::stringFormat("\r\n#line %d \"%s\"\r\n",line_number,filenameUtf8.c_str()));
			// Now insert the contents of the #include file before the closing #line directive.
			src=src.insert(eol,newsrc);
			next+=newsrc.length();
			line_number--;
		}
		else
			line_number++;
		pos=next;
		next=(int)src.find('\n',pos+1);
	}
}

Up-to-date (2013) Flex and Bison for Win32

http://sourceforge.net/projects/winflexbison/

Friday, 18 April 2014

Hair rendering: see Kajiya-Kay and Scheuermann (ATI)

Thursday, 27 March 2014

Start 8 Start button: the proper button image restored

Start8 is an add-on to Windows 8 that restores the start menu to the bottom-left of the Desktop, Windows 7 style. It's $5, but worth the price to get a functioning desktop OS back.

For some weird reason, Stardock, the company behind Start8, put out an update that took away the Windows 8 icon and replaced it with a selection of funny-looking alternatives. Probably a copyright thing. You can set your own image though, so I made one that looks like the Windows ogo.
Save this image to the "C:\Program Files (x86)\Stardock\Start8\StartButtons" folder
Save this image to the "C:\Program Files (x86)\Stardock\Start8\StartButtons" folder, and select Custom Image in the the Start8 options.

Unity DLL dependencies

The DLL directly referenced from Unity can be in the Assets/Plugins/x86 etc folder. The DLL's it references for some reason have to be in the main project directory.

Monday, 10 March 2014

CalDAV Google Calendar in Thunderbird

  • Open Thunderbird File->New Calendar 
  • Select On The Network 
  • Select CalDAV 
  • Set Location to: https://www.google.com/calendar/dav/SPECIAL-SAUCE-GOES-HERE/events 
The "special sauce" that takes the place of SPECIAL-SAUCE-GOES-HERE is found on your Google Calendar (gCal) account.
  • Login to your gCal account. 
  • Go To Settings 
  • Click on the Calendars tab 
  • Click on the name of the calendar you wish to add to Sunbird/Thunderbird 
  • Look for the "Calendar Address" entry, next to the XML ICAL HTML buttons is a Calendar ID in parenthesis. 

It looks something like this for all but your primary calendar: nxu54xul23v3g...@group.calendar.google.com
For your primary calendar it will just be your gCal account login: <your-name-here>@gmail.com