Category «Linux»

Add New SSH Login to Azure Linux VM

Some time ago, I created an Ubuntu virtual machine in Azure using a password-based login. Over time, I got annoyed with having to enter the password each time I logged in, so I decided to switch over to using SSH public keys. Unfortunately, the Azure documentation regarding such a scenario assumes only that you will be creating a new virtual machine from scratch to create a public key based login. Have no fear. I have figured out how to do this without having to recreate your virtual machine.


  • Linux-based client (your computer)
  • Linux-based virtual machine in Azure with password-based login (Azure)

Create the RSA Keys on Your Computer

Azure requires RSA keys with 2048-bit encryption, so you should do this:

Just press ENTER when asked where to store the file unless you really want to put it somewhere other than the default. In most cases, the default is fine. After you pick the location, enter a good password to unlock the private key when prompted during login.

Transfer the Keys from Your Computer to Your Server

In order to copy your keys to the server on which you want to login, you will need to have a password-based login already setup. If this is your case, do the following:

Enter your server’s password-based login when prompted to begin

Continue reading

Resolution Independent 2D Rendering in SDL2

A little over a year ago, I wrote a post about how to render to a fixed, virtual resolution so that we can render independently of the actual window size resolution. That approach utilized the XNA framework to perform what we needed. Since Microsoft effectively killed XNA by pushing forward with DirectX / WinRT, myself and others have moved on to other libraries. In this post, I will show you how to do the same thing but with SDL2. Honestly, this approach is even easier (as long as you are using SDL2 that is!)

The concept of rendering to a virtually sized target is labeled as “Logical Size” in SDL2. Rendering a game to a logical size makes the scaling of that game to match different window sizes much easier. Imagine that we created our game under the assumption of 800×600 (an old school, 4:3 aspect ratio). On a user’s machine that has their system resolution set to 1920×1080, we have two choices: 1) show the game in a tiny window or 2) stretch the picture to fit the full screen. Both of these options are pretty terrible. In the first, the window will be too small to see anything useful (depending on the textures and fonts used in the game). In the second, the stretched picture will look awful because the aspect ratios do not even match. This is where SDL2’s logical rendering comes into play.

After establishing your renderer, all you really need to do is call the

Continue reading

Using SDL2-C# to Capture Text Input

A common feature of applications and video games is to allow the player to input text for various reasons. Maybe we want to allow the player to input their character’s name in an RPG, name a city in SimCity, or type a chat message to a friend in online. Using SDL2, we can take advantage of its built-in text processing system which abstracts much of the operating system event handles and character encoding mechanisms.

On consoles such as Xbox and Playstation, text input is rather simplistic and limited to visual keypads that you select via the controller. On a PC, we have the full range of widely varying keyboards from English and Spanish to Russian and Japanese. If we want our game or application to attract users on an international scale, it’s probably in your best interest to learn here and now how to use SDL2 to accomplish this goal.

At first glance, it probably seems simple to process text input. If the user presses the ‘A’ key on the keyboard, the OS will send an event that the keyboard was just pressed, the key was ‘A’, and no modifier keys were pressed (CAPS, SHIFT, CTRL, ALT, etc…). That’s it, right? Unfortunately, there are a ton of languages on this planet, and some of them have thousands of characters in them. People who type in those languages most certainly do not have thousand-letter keyboards or entire walls of their houses dedicated as a giant keyboard. This basically means that some

Continue reading

How to load a map from Tiled Map Editor and render it with SDL2

I recently created a library named SharpTiles that is heavily based on Nick Gravelyn’s TiledLib. Both libraries will allow developers to load maps from Tiled Map Editor. However, TiledLib is based around XNA while SharpTiles is based around SharpDL (an XNA-like game framework for SDL2). I will discuss more about SharpDL in another post, but you can refer to the simple code in this post to learn how to render a map with a small subset of the library.

Load a Map

  • Window is a SharpDL object that represents a SDL_Window
  • Renderer is a SharpDL object that represents a SDL_Renderer
  • TiledMap is the main object that you will use to load a map file

Continue reading

Setting Up SDL2 with Visual Studio 2012 and 2013

I have confirmed that everything below works for Visual Studio 2013.
Links updated to the latest release (2.0.3).

The Simple DirectMedia Library (SDL) version 2 has been released after a long time in development. It seems that the author has more time on his hands and more corporate backing from his new position at Valve Software. I’ve heard that they use SDL for various small time projects that don’t require heavy rendering. Even so, SDL does a formidable job at making things easy.

I wrote this guide under the following setup, but I’m sure that it can be applied to other version of Windows (and maybe even Visual Studio).

Anyway, try your setup and let me know how it goes. Follow these steps to get all setup and ready to code:

  1. Download the development libraries
  2. Download the 32-bit binary or the 64-bit binary
  3. Extract both zips to a convenient location
  4. Open Visual Studio and create an empty C++ project
  5. Right click the created project in the Solution Explorer, go to Properties
  6. Click VC++ Directories under Configuration Properties
  7. In the “Include Directorires” line, add the include directory from the extracted development library
  8. In the
Continue reading

Some Useful git Commands

git status
shows pending changes that can be added to repo

git add -A
adds all pending changed files to pending commit list

git commit -a -m “Message”
commits all pending additions to the current branch with a message of “Message”

git push
pushes current branch to default remote

git push {branch name} {remote repo name}
pushes {branch name} changes to {remote repo name}

git reset {file name}
resets a file back to previous state after adding to pending commit list

git branch {branch name}
creates a branch named {branch name}

git checkout {branch name}
switches to a branch named {branch name}

git checkout -b {branch name}
creates and switches to a branch named {branch name}

git remote add {remote repo name} {remote repo uri}
adds a reference to a remote repo that can be pushed to

Continue reading