OpenGL FreeGlut in Visual Studio 2015

Starting an OpenGL project in VS 2015 is really easy, thanks to the NupenGL.Core nuget package.

Here are really quick steps to start your first OpenGL project using the FreeGlut library to provide a Window toolkit.

Open Visual Studio 2015 Community Edition and create a new Visual Studio C++ Windows Console Application.


Keep it simple. Choose an empty project template.


Install the NupenGL.Core nuget package. From Visual Studio, Go to Tools \ NuGet Package Manager \ Manage Nuget Packages for this solution. Search for “NupenGL” and install the package.


Add a new C or C++ file. Here is some sample code

#include <gl/freeglut.h>

void init();
void display(void);
void centerOnScreen();
void drawObject();

//  define the window position on screen
int window_x;
int window_y;

//  variables representing the window size
int window_width = 480;
int window_height = 480;

//  variable representing the window title
char *window_title = "Sample OpenGL FreeGlut App";

//  Program Main method.
void main(int argc, char **argv)
	//  Connect to the windowing system + create a window
	//  with the specified dimensions and position
	//  + set the display mode + specify the window title.
	glutInit(&amp;argc, argv);
	glutInitWindowSize(window_width, window_height);
	glutInitWindowPosition(window_x, window_y);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);

	//  Set OpenGL program initial state.

	// Set the callback functions

	//  Start GLUT event processing loop

//  Set OpenGL program initial state.
void init()
	//  Set the frame buffer clear color to black. 
	glClearColor(0.0, 0.0, 0.0, 0.0);

//  This function is passed to glutDisplayFunc in order to display 
//	OpenGL contents on the window.
void display(void)
	//  Clear the window or more specifically the frame buffer...
	//  This happens by replacing all the contents of the frame
	//  buffer by the clear color (black in our case)

	//  Draw object

	//  Swap contents of backward and forward frame buffers

//  Draws our object.
void drawObject()
	//  Draw Icosahedron

//  This function sets the window x and y coordinates
//  such that the window becomes centered
void centerOnScreen()
	window_x = (glutGet(GLUT_SCREEN_WIDTH) - window_width) / 2;
	window_y = (glutGet(GLUT_SCREEN_HEIGHT) - window_height) / 2;

After this, you should be able to build and run without any issues. Your application should look something like this:


You can find a Visual Studio 2015 project that uses many of the FreeGlut features on this Github repository.

ASP.NET vNext – Identity 3.0 (beta6) in MVC 6 (beta6) Spa – Using Integer Keys Instead of Strings

After looking all over the place and not finding anything specific for Identity 3.0, I got inspired to write this blog post on how to use bigint primary keys for the Identity tables instead of nvarchar(450). The official ASP .Net Identity web site has a good list of resources, but that are mostly 2.0 specific. Also, not much can be inferred from the tests on the aspnet/Identity project on Github,

There is already a blog post written by John Atten on “Extending Identity Models and Using Integer Keys Instead of Strings“, but it is targeted for ASP.NET Identity 2.0 and doesn’t work with ASP.NET Identity 3.0 beta6. Luckily, the steps to enable this scenario in Identity 3.0 are much easier and are finally being documented here.

First, extend the IdentityUser and IdentityRole and explicitly specify a type of long instead of string. For context, if you look at the definition of IdentityUser, you’ll see that it inherits from IdentityUser<string>.

public class ApplicationUser : IdentityUser<long>

public class ApplicationRole : IdentityRole<long>

Next, update your db context to be aware of the user/role and unqiue key changes.

public class ApplicationDbContext: 
    IdentityDbContext<ApplicationUser, ApplicationRole, long>

Next step, in Startup.cs file, ConfigureServices method, make sure the AddIdentity method points to the new user and role types. In addition, make sure the AddEntityFrameworkStores method specifies a long type.

services.AddIdentity<ApplicationUser, ApplicationRole>()
    .AddEntityFrameworkStores<ApplicationDbContext, long>()

At last, in your AccountController, make sure UserManagerSignInManager and RoleManager are bound to the right types.

UserManager<ApplicationUser> userManager;
SignInManager<ApplicationUser> signInManager;
RoleManager<ApplicationRole> rolesManager;

That’s it. If you look at this and the steps you had to follow in Identity 2.0, you’ll be able to easily tell how much the Identity framework architecture has improved in 3.0.


Using Event Receivers in SharePoint Foundation 2010

I have been working with Nick Gattuccio on authoring a two-part MSDN article about using event receivers in SharePoint 2010. The first part provides a thorough explanation of what events are and how they can be developed and deployed in SharePoint. The second part provides practical examples using Visual Studio 2010.

Title: Using Event Receivers in SharePoint Foundation 2010 (Part 1 of 2)

Title: Using Event Receivers in SharePoint Foundation 2010 (Part 2 of 2)

Let me know how useful this is to you.

SharePoint Detector – Chrome Extension

Ever wondered whether a site is built on top of SharePoint? Now, there is an easy way to find out. Install the “SharePoint Detector” Chrome extension located at, and you will get the SharePoint icon displayed in Chrome’s address bar every time you browse to a SharePoint site. You can then click on the SharePoint icon and choose to share the site by email, on your WordPress blog, LinkedIn, Twitter, Facebook and\or StumbleUpon.

For example, here is what happens when you browse to

If you decide to share on Twitter, you will get the following popup.

You can edit it as you like then post to your Twitter account. Same goes for all the other different methods of sharing..

Enjoy sharing SharePoint!

Visual Studio 2010 – Unattended Silent Install

You can find on MSDN How to: Create and Run an Unattended Visual Studio Setup. This post focuses on unattended installation of VS 2010 product only (without SDK) along with screenshots and hints on what to avoid. Below are the steps I have followed to create a silent unattended installation script for VS 2010.

  • Create the VS 2010 unattend configuration file
    <path to VS installation folder>\setup\setup.exe /createunattend c:\VS2010Config.ini

    Note: Make sure you run the \setup\setup.exe and not \setup.exe directly.

  • The wizard will launch… Accept license terms, select the feature you want to install, then click Save Settings.
  • Once you click “Save Settings”, the VS config file will be created at c:\VS2010Config.ini
  • Now, do the unattended installation with the command below
    <path to VS installation folder>\setup\setup.exe /unattendfile c:\VS2010Config.ini

As you can see, the steps are pretty straight-forward. Enjoy!

SQL Server 2008 R2 – Unattended Silent Install

There is existing documentation on MSDN about How to: Install SQL Server 2008 R2 from the Command Prompt, but this post focuses on creating a silent unattended install of SQL Server 2008 R2 (Standard or Enterprise) using a configuration file. With the instructions below, you’ll be able to create a new customized SQL silent installation in minimal time. Note that the configuration below doesn’t work with the Express edition of SQL Server 2008 R2.

  • Run setup.exe
  • Click on the installtion tab
  • Click “New Installation”
  • Go through the wizard: Enter product key, accept license, install setup support files, and select the features you want to install:
  • Continue the installation until you reach the “Ready To Install” step. Notice the path to the configuration file highlighted below in blue.

  • Now that you have the configuration file, copy it to your own folder or network share where you want to start the unattended installation.
  • Cancel setup since we’re interested in the unattended silent mode of installation; not the UI one.
  • Edit the configuration file as follows:
    • Set QUIET to “True”. This specifies that Setup will run in a quiet mode without any user interface (i.e. unattended installation)
    • Set SQLSYSADMINACCOUNTS to “BUILTIN\ADMINISTRATORS”. This will ensure that administrators on the machine are added as members of the sysadmin role. You can set its value based on your needs (Ex: SQLSYSADMINACCOUNTS=”domain\YourUser”), but this is the more generic approach.
    • Add PID and set its value to your product license key. If your setup.exe already comes preloaded with the key, there is no need to add this option to the configuration file.
    • Add IACCEPTSQLSERVERLICENSETERMS and set its value to “True”. This is to required to acknowledge acceptance of the license terms when the /Q (i.e. QUIET) parameter is specified for unattended installations.
    • Remove the ADDCURRENTUSERASSQLADMIN parameter. The reason is that this parameter can’t be used when SQLSYSADMINACCOUNTS is specified, and it only applies to Express installations.
    • Remove the UIMODE parameter as it can’t be used with the QUITE parameter.
    • Remove INSTALLSHAREDDIR, INSTALLSHAREDWOWDIR, INSTANCEDIR parameters since we want to install on the default installation directories.
    • That’s it. If you want to change the features that this setup will install, there is no need to go with the full steps again. You can simply change the value for the FEATURES parameter. For example, the features I selected (shown in first screenshot above) will generate FEATURES=SQLENGINE,SSMS,ADV_SSMS in the configuration file.  You can change that based on your needs. The full list of available feature parameters and their descriptions is located here.

After getting the configuration file ready, you’ll need to create a batch file that will run the silent unattended setup. Simply, create a new file  “InstallSQL2008R2.bat” with extension = “.bat” with the following content, and make sure you replace <path to SQL setup folder> and <path to config file> with the proper values.

@ECHO off
echo Installing SQL Server 2008 R2
time /t
"<path to SQL setup folder>\setup.exe" /ConfigurationFile="<path to config file>"
time /t

All we’re doing in the script above is running SQL setup.exe and passing the configuration file as an argument to it. You can download both the batch and config files here.