Windows 8 Gaming

28. September 2012 12:51 by Cameron in Windows 8  //  Tags: , , , , , , ,   //   Comments

I recently installed Windows 8 Professional x64 RTM on my MSI GT70 0ND-202US and thus far I like it. I've been trying all of my games that I purchased from Steam and so far everything I've run works quite well in Windows 8. The only game I had trouble with getting to run initially was Just Cause 2. I came across this post that shows how to fix it: http://www.jc-mp.com/forums/index.php/topic,733.msg5785.html#msg5785 If you add /dxadapter=0 to the launch options for Just Cause 2, you will no longer get an error message when launching the game.

ODBC vs RESTful API

31. August 2012 00:55 by Cameron in C++, Qt  //  Tags: , , , , , , , , , ,   //   Comments

In the process of writing the IGA desktop application, I've been faced with several design decisions. One of the most challenging decisions I had to make was how I should most effectively interact with a database backend. To help with this decision, I weighed out the pros and cons of using ODBC and a RESTful web API. Each of these methods are very good for certain purposes.

ODBC

Pros

  • Cross platform support through C/C++ libraries
  • Secure using username and password (connection encrypted)

Cons

  • Some ISPs/Schools block port 1433 (used with SQL Server) or other database ports (MySQL, Postgre, etc)
  • Slow response time in some instances (running multiple queries can take a fair amount of time)

RESTful API

Pros

  • Fast response time
  • Abstracts data backend - i.e. allows for an easy switch of database servers or switch of web server languages
  • Easily allows for multiple desktop and mobile frontends by adhering the web API interface (ODBC isn't usually standard in mobile platforms)

Cons

  • Requires tighter security
  • All requests must be encrypted using SSL or  plain text is sent to the server
  • Requires some sort of authentication either by API key or other method to prevent arbitrary access to server

Ultimately, I decided to go with using a RESTful web API for maintaining separation of the database architecture from the IGA desktop application. This will allow me to change the database backend without breaking the application as long as I keep the API interface the same. Another huge factor in choosing a RESTful web API is that my school blocks port 1433 on its campus wireless networks. I want college students to be able to use the IGA desktop application while on campus so this was a necessary choice. Overall, both provide advantages and disadvantages and neither one is "better" than the other. I hope this helps people with the decision between ODBC and a RESTful API.

MSI GT70 0ND-202US Gaming Laptop/Hackbook

28. August 2012 00:51 by Cameron in   //  Tags: , , , , , , , , ,   //   Comments

I recently bought a gaming laptop from MSI on Newegg with some pretty excellent specifications:

http://www.newegg.com/Product/Product.aspx?Item=N82E16834152347

Laptop: MSI GT70 0ND-202US Z77M, Intel Core i7-3610QM 2.3GHz, 12GB DDR3 RAM, 750GB Hitachi, 250GB WD, NVIDIA GTX 675M / Intel HD 4000 (Optimus), Realtek HD Audio (voodoohda), Wireless-N Atheros 9285 Half mini PCI  Express Card - Windows 8 Professional x64 RTM, OS X Mountain Lion 10.8.2 Retail

Preinstall

To install OS X Mountain Lion, download the Mountain Lion installer from the App Store (MacOS X 10.6.8 or higher) and use Unibeast to create a USB installation disk. Once the disk is created, you can then boot from the flash drive to install Mountain Lion! At the boot prompt, be sure to boot verbose using the '-v' option and also set 'GraphicsEnabler=No' as at the time of writing this guide, the NVIDIA GTX 675M cannot be used as the primary GPU and the Intel HD 4000 will need some tweaks later to get QE/CI. Once in the installer, you will need to choose where to install OS X Mountain Lion. You can install to your existing disk on a separate partition or install to a secondary disk (recommended). You will need to make sure that the hard drive you are installing ML to is using the GUID partitioning map and not MBR. If you need MBR, you'll need to patch the installer.

Postinstall

Multibeast

Wifi

The MSI GT70 0ND-202US comes stock with an Intel Centrino Wireless-N 2330 mini PCI Express card which will need to be subbed out with another compatible card. Swapping cards is fairly simple. All you need to do is pop up the speaker panel and disconnect the existing card and replace with the new one. One thing that you must do is make sure the Wifi LED is lit, otherwise, you won't be able to use the card. Here's a complete guide on how to choose an appropriate replacement card and how to get it working: http://www.tonymacx86.com/network/58146-guide-airport-half-mini-pcie.html

Intel HD 4000 QE/CI

Using the MacBook Pro 9,1 SMBIOS, LegacyAGPM.kext, 1920x1080x32, and DSDT injection for 01660004 you can achieve QE/CI. It should also be noted that I have removed AppleIntelSNBFramebuffer.kext as it is not needed with the Intel HD 4000 (probably could stop the kext from loading with DSDT later). Here's the DSDT patch for injecting the ig-platform-id:

into method label _DSM parent_adr 0x00020000 remove_entry;
into device name_adr 0x00020000 insert
begin
        Method(_DSM,4,NotSerialized)\n
        {\n
                Store(Package(0x02)\n
                 {\n
                                "AAPL,ig-platform-id",\n
                                Buffer(0x04)\n
                                {\n
                                   0x04,0x00,0x66,0x01\n
                                },\n
                        },Local0)\n
                DTGP (Arg0,Arg1,Arg2,Arg3,RefOf(Local0))\n
                Return(Local0)\n
        }\n
end


Using DSDT Editor, you'll have to apply the above patch as well as the DTGP patch from the patches directory.

Sound

VoodooHDA 2.7.2 - note, you'll have to edit the Info.plist in VoodooHDA.kext so that there isn't a hissing sound coming from the VoodooHDA prefpane. 

USB 3.0 fix (temporary)

One thing that I have found is that if you remove AppleUSBXHCI.kext from the plugins in IOUSBFamily.kext, it will treat USB 3.0 ports as just USB 2.0 ports and crashing no longer happens. This is a temporary fix until full USB 3.0 support exists (possibly in a later update). Make a backup of your existing IOUSBFamily.kext and then do the edits and re-install using Kextbeast.

Kexts

 Here's the voodoo kexts that I use for my laptop. Included is a kext for the battery, audio, and trackpad (multitouch).

voodoo_kexts.zip (212.01 kb)

 Here's my patched DSDT. As I make edits to my DSDT, I'll upload this attachment. I hope this helps for anyone with my laptop or similar.

dsdt.aml (47.02 kb)

 

 

Authenticate with ASP.NET membership provider using Qt and C++

5. July 2012 00:42 by Cameron in   //  Tags: , , , , , ,   //   Comments

Today, I was looking at a method of authenticating users in the IGA desktop application using the website's membership provider. I remembered a post I made a while back on Stack Overflow about how to authenticate users with Ignite OpenFire and in the answer, there was some Java code showing how to correctly hash a password with a salt and compare it with the membership table. I ventured into porting the algorithm to C++ and was successful! Here's the C++ code for anyone interested:

QString hashPassword(QString password, QString salt)
{

    // get utf-16 representation of password

    QByteArray passwordBytes((const char*) (password.utf16()), password.size() * 2);

    // get utf-16 representation of salt

    QByteArray saltBytes((const char*) (salt.utf16()), salt.size() * 2);

    // decode base64 salt byte array

    QByteArray saltDecodedBytes = QByteArray::fromBase64(saltBytes);

    QByteArray dst;

    dst.append(saltDecodedBytes);

    dst.append(passwordBytes);



    QByteArray hashed = QCryptographicHash::hash(dst, QCryptographicHash::Sha1);

    return QString::fromLatin1(hashed.toBase64().data());
}

Please note that in order for this to work, your passwords must be hashed. I had to convert any non-hashed passwords using an automated script that I found on Stack Overflow. It's pretty straight forward. Just add a second provider that uses hashed passwords and get the passwords from the encrypted/clear text provider and change them using the hashed provider. Be sure to set your default provider to the hashed provider so that you won't have to run this script at a later point. I had to modify the code that I found from Stack Overflow a bit to use a try catch block around the user.GetPassword() method as some passwords may already have been hashed and can't be decrypted. Here's the C# code for anyone interested:

void HashAllPasswords()
{          
	SqlMembershipProvider hashedProvider = (SqlMembershipProvider)Membership.Providers["HashedProvider"];
	SqlMembershipProvider encryptedProvider = (SqlMembershipProvider)Membership.Providers["EncryptedProvider"];
	if (encryptedProvider == null || hashedProvider == null) return;
	Dictionary<string, string> passwords = new Dictionary<string, string>();
	int unimportant;
	foreach (MembershipUser user in encryptedProvider.GetAllUsers(0, Int32.MaxValue, out unimportant))
	{
		try
		{
			passwords.Add(user.UserName, user.GetPassword());
		}
		catch (Exception e)
		{
		}
	}

	using (var conn = new SqlConnection(
		   ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString))
	{
		conn.Open();
		using (var cmd = new SqlCommand(
			   "UPDATE [aspnet_Membership] SET [PasswordFormat]=1", conn))
			cmd.ExecuteNonQuery();
	}

	foreach (var entry in passwords)
	{
		var resetPassword = hashedProvider.ResetPassword(entry.Key, null);
		hashedProvider.ChangePassword(entry.Key, resetPassword, entry.Value);
	}
}

Improving speed of iterating a result set from a QSqlQuery

4. July 2012 16:22 by Cameron in C++, Qt  //  Tags: , , , , , , , ,   //   Comments

Today, I had to figure out why it was taking so long to iterate a result set using a QSqlQuery. A query that I ran in about 1 second from SQL Server Management Studio was taking 15 seconds to complete from my C++ application. I found that if you don't set ForwardOnly to true using setForwardOnly(true), it will drastically decrease performance of iterating through the query's results. You should also prepare the query before executing. After applying those changes, I got my query to run in under a second! Huge difference! You can see an example of how to connect to a SQL Server database and query a table using the QODBC3 driver. The speed improvements should also apply to SQLite databases.

QString connectionTemplate = "DRIVER={SQL SERVER};SERVER=server;DATABASE=Users;";
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3", "db");
db.setDatabaseName(connectionTemplate);
db.setUserName("sa");
db.setPassword("password");
if (db.open()) {
	qDebug() << "OK!";
	QSqlQuery * query = new QSqlQuery(db);
	query->setForwardOnly(true);
	query->prepare("SELECT [UserName]"
				   "  FROM [dbo].[Users]");
	QTime begin = QTime::currentTime();
	if(query->exec())      {
		while(query->next())
		{
			QString userName = query->value(0).toString();
			qDebug() << userName;
		}
		QTime end = QTime::currentTime();
		qDebug() << "finished in " + QVariant(end.second() - now.second()).toString() + " seconds";
	}
	db.close();
}
else {
	qDebug() << db.lastError().text();
}

Started Development of a Collapsible Frame Qt Widget

5. May 2012 22:14 by Cameron in C++, Qt  //  Tags: , ,   //   Comments

Today, I started development of a collapsible frame Qt widget. I needed a widget that could show/hide its contents by clicking on an open/close button but couldn't find a solution online so I decided to create my own. The code is still a work in progress, but the basis of the code involves the use of nested layouts to achieve the hide/show effect. I had to write a custom clickable label class and subclass QLabel as QLabel doesn't have a clicked() signal. I'm using style sheets to apply the icon to the QLabel so that it has the correct image based on open/close and hover over states. The code is available on github under the Apache 2.0 license. Feel free to check out the code and see if you'd like to fork it yourself and contribute.

https://github.com/pcmantinker/Qt-Collapsible-Panel

Neo4j and SQL Server 2008 R2

Lately, I've been researching graph databases (NOSQL) as an alternative to traditional relational databases. The performance increase from a graph database compared to a relational database is phenomenal. To get my website rolling, I'm planning on using SQL Server 2008 R2 with the Microsoft Entity Framework. Once the data models are in place, I can then work on writing a SQL to graph database server application for migrating my data model into a graph database. There are several .NET libraries available for interfacing with Neo4j's REST API and the data migration should be trivial. My database migration tool will consist of using the Entity Framework to connect to SQL Server 2008 R2 and one of the .NET frameworks for manipulating Neo4j's REST API. I'll continue to post updates as they become available.

Qt Cross Platform Notification System

25. March 2012 16:30 by Cameron in C++, Qt  //  Tags: , , , , ,   //   Comments

I've been working on a cross-platform notification system built on Qt which is modeled after Mac OS X's Growl notification system. This is for use in a project that I'm currently working on. You may view the source code here: https://github.com/pcmantinker/Tray-Notification-System

I am still playing around with the window flags for the notification system as sometimes when a new notification is shown, within the Windows operating system, it steals focus from full screen applications. If you have any suggestions, feel free to let me know in the comments. Also, feel free to fork my repository and contribute to the code base if you're interested.

Unity 3D Game Project

5. March 2012 13:11 by Cameron in Programming  //  Tags: , , , , , , , ,   //   Comments

This semester, at Louisiana State University, I'm taking a video game design class and our goal is to make a 3D stereoscopic game using the Unity 3D engine. I'm working with a group of students from the University of Illinois at Chicago and one other member from LSU. So far, it's proven to be a very interesting class. We've pitched our storyboard ideas in front of our peers and our professors to get a good sense of what we should do next. Ultimately, we decided on doing a hang gliding game influenced by the PilotWings series. I have always loved the Pilot Wings games and I can remember the hours of fun I used to have playing PilotWings for the SNES. Today, I have Pilot Wings Resort for the Nintendo 3DS and thoroughly enjoy the game play. Our game, while having some similarities to Pilot Wings, will be unique and have its own twist. We're still working out all of the logistics of the game play, but we have some good ideas thus far.

I've been focusing on simulating hang glider flight physics using Unity 3D's physics engine and later I will help with composing the soundtrack of the game. I've setup a prototype of the game where the player is positioned in the middle of a canyon and has the ability to tilt left and right as well as climb and descend. I'm still working on making the movement more fluid, but the basic concept of flight is represented in the prototype. My colleagues are working on randomizing the terrain and managing the world objects for powerups and obstacles.

Once we have a presentable prototype, it will be fun to compose the soundtrack for the game. I've been playing piano for the past 15 years and I love to compose my own music. Some of the songs I compose are strictly solo piano while others have multiple parts to add depth to the sound.

I will keep this blog updated as more progress is made on the game project front. I'll also be sure to upload some images of the prototype at some point.

Qt Application Development in Mac OS X Lion

1. February 2012 01:52 by Cameron in Qt, Mac OS X, C++  //  Tags: , , , , ,   //   Comments

I've been working on some code using the QtSDK lately and I've been researching how to deploy applications for Mac OS X 10.6 and above. Luckily, it's pretty simple to deploy applications as the QtSDK includes a tool called macdeployqt. The tool copies all required Qt frameworks to the app bundle and re-assigns the library reference paths for the app to use the libraries within the app bundle and not the user's system directory (/usr/lib). It doesn't copy 3rd party libraries that aren't in the /usr/lib directory so you will have to manually add those.

Please note that macdeployqt on Qt 4.7.x doesn't seem to assign the correct library paths when linking against QtWebKit. This is a known bug that was fixed in Qt 4.8.0.

Also, if you want to insure that your app will not have problems on Snow Leopard, be sure to add this to your .pro file: 

macx:QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.6.sdk

This tells Qt to use the Snow Leopard SDK instead of the Lion SDK. If you build your application with the 10.6 SDK, it will work with Mac OS X 10.6 or higher.

One last thing is that there seems to be a problem with Xcode 4 and Qt Creator not being able to find g++-4.2 which is installed with older versions of Xcode. A work around for this until a new version of Qt Creator:

sudo ln -s /usr/bin/g++ /usr/bin/g++-4.2

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

I hope this helps anyone experiencing the same issues.

 

EDIT:
As of the February 1, 2012 QtSDK update, it appears as though the problems with g++ and using macdeployqt have been fixed. Please be sure to update to the latest SDK release. 

Month List

Tag cloud