Phat JS Demo

August 21st, 2014

Here’s something different.

Been working on the HTML5 side of my library code, and I kinda made this little demo for fun. Music is Garth Knight’s track Activate the Cage.

Ludum Dare 30 is this weekend. Hoo boy! Running that crazyfest is keeping me sooo busy. :)

Dialogs as Functions

July 16th, 2014

This is just an idea I’ve had. I wanted to write it down in some meaningful way so that I can rediscover it later. This is less a C++’ism, and more a JavaScript/Squirrel’ism.

* * *

In any situation where your user interface presents a popup dialog, that process of presenting the dialog should be a function call. Here is pseudocode:

The general idea here is that there should be 2 ways to use the function: 1. Without arguments, to bring up the entry dialog; 2. With arguments, to bypass the entry dialog (for macro/scripting use). The data in extracted from the function arguments, or the shown dialog, and the action is taken place.

Args should be the language equivalent of an object (JavaScript, Squirrel, etc). Alternatively, an array of objects could work too, but named elements would result in nicer code. Like above, it’s assumed a Yes/No/Cancel dialog would store a boolean named State to tell you which (Yes or No) was picked.

The above assumes a synchronous environment, where it’s safe to give a function “ShowDialog_YesNoCancel” full control.

In an asynchronous environment, you’ll want to use something like a Deferred or Future. If there are no arguments, the ShowDialog function will provide the object you bind your State handling function to. Otherwise, bind it to one that will succeed.

Alternatively, there are probably nice ways to handle this using coroutines or generators.

Checking Symbols GCC and Clang

June 20th, 2014

Just a short one.

Reference: http://stackoverflow.com/questions/4548702/whats-the-equivalent-of-cpp-dd-for-clang

Gives you list of all symbols defined by compilers. It’s interesting, that you have to feed it something (anything blank) to get this output though. /dev/null, or pipe in a blank echo (echo “” | gcc -dM -E -), etc.

Works with NaCl (pnacl-clang), Emscripten (emcc), and pretty much every GCC toolchain known to man.

Setting up NaCL and SDL (on a fresh Ubuntu)

June 6th, 2014

Some notes on getting NaCl working. Of course, things didn’t work out-of-the box.

Install nacl_sdk

Grab and follow the instructions here:

https://developer.chrome.com/native-client/sdk/download

i.e. download and do the following:

Install 32bit Headers

‘cmon, everybody runs 64bit Linux these days (in my case Ubuntu 14.04 64bit). You need the 32bit libraries for anything to build though.

Source: http://stackoverflow.com/questions/23661718/native-client-tutorial-cant-find-libstdc

Follow Tutorial

‘make serve’ will now work.

https://developer.chrome.com/native-client/devguide/tutorial/tutorial-part1

Test2 probably wont run though. I haven’t checked, but I think it may not be a pnacl file (pnacl is necessary to run in a stock Chrome).

EDIT: The problem with Test2 is that newlib is the first Toolchain. If you modify the Makefile by making pnacl the first VALID_TOOLCHAINS (or commenting out the line entirely), and change index.html, the data-tools attribute of the body tag, make pnacl first, it will work correctly.

Now, lets see how far we get compiling SDL NaCL.

Set Environment Variables for SDL

Reference: https://hg.libsdl.org/SDL/file/ae720d61d14d/README-nacl.txt

Do something like the following.

‘readlink -f’ takes a path and converts it in to an absolute path (by following symlinks, ..’s, etc). If you’re on Windows, substitute it for the absolute path to your pepper directory. Mine is /home/mike/Work/Build/nacl_sdk/pepper_35

And of course, edit your pepper version accordingly (35 or whatever).

Build SDL2 in NaCL mode

SDL must be built outside the main SDL directory. I like to call my SDL directory “SDL2″, and do builds in directories like “SDLBuild”. I invoke my build like follows:

Notably, I’m putting the output (make install) inside the SDL subdirectory of the pepper SDK folder.

The Makefile

EDIT: For the makefile to work, I had to make a few changes. Here is the full modified makefile.

The changes are lines 19 and 20. Line 22 is new, as are lines 67 and 68. The last 2 lines are a hack to make “make serve” work the same as it does in the NaCl demos.

Here’s a diff.

For reference, my old notes (before I got it working by changing the makefile):

Okay, this didn’t actually work. I’m not sure exactly how it’s supposed to be configured, but it’s not configured correctly. It should only be used as a reference. Some other notes of things I had to do to get it to work:

naclbuild script

Alternatively, once the environment is set correctly (I think just NACL_SDK_ROOT) it’ll work. In the ‘build-tools’ folder is a script ‘naclbuild’. Run that, and it’ll put some output in the Build folder. Once it finishes, it gives you a string to copy+paste in to your shell. Do it.

Vine Videos: https://vine.co/v/MDnA1x9aPMe, https://vine.co/v/MDn6I6UFWPF

Currently works on Desktop Chrome, and Chrome OS. Will not work on Android (yet).

PPTP Connecting from Ubuntu 14.04

May 17th, 2014

So I was having troubles opening a VPN connection from Ubuntu 14.04. I could VPN just fine on my iPad and Android devices, but I was having no luck on Ubuntu. Looking at my /var/log/syslog, and after much Googling, it seems my problem was ‘secrets’/keyring related.

Setting up a PPTP VPN connection is easy.

VPN3

What I was lacking was one very specific checkbox with many implications, none of which were spelled out. The important one is that “Available to All Users” skips the secrets check, and instead prompts you for a password. That’s better than no VPN at all. :)

VPN1

My advanced settings look something like this, thanks to other tutorials I stumbled across:

VPN2

Notably, no PAP, as that’s very insecure. The rest of the options, I haven’t tried otherwise. What’s important to me is I can now connect to my VPN.

Setting up a remote PPTP server

May 17th, 2014

So I’ve been working on netcode recently. LAN/Local testing is only so effective, when the real internet is so laggy. Ideally, if I could be in 2 places at once, I could test the game under a more natural lagged internet.

So that’s what I’ve done. I’ve split in two and sent my other half down south… okay no. I recently set up an inexpensive unmanaged BuyVM VPS server (256 MB RAM, Dual Core) in Las Vegas running a trimmed down version of Ubuntu 14.04 Server. From where I’m at (2 hours south of Toronto), the ping between myself and the Las Vegas server is around 100ms.

Like always, here are my notes.

Setting up BuyVM Server as a PPTP VPN

Setting up, I started by “Reinstalling” a fresh Minimized Ubuntu 14.04 64bit Server. At the time, Ubuntu 14.04 wasn’t yet available as a pre-install. It was something I had to do after creating my account.

From that fresh install, I need to first do an APT update:

Next, install IPTABLES.

Follow these instructions:

https://help.ubuntu.com/community/PPTPServer

At the very end though, we’re setting the IPTables in “/etc/rc.local”. Do this instead:

The change is the first line. We’re not binding to an interface, but setting a source.

Done. Can now VPN using the PPTP protocol, and route all your internet traffic through it.

Reference: http://wiki.buyvm.net/doku.php/ipsec (combined the Ubuntu notes and this)

* * *

To connect: Use the server IP address, login and password set in the secrets file.