Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dghost on github.
  • I am dghost (https://keybase.io/dghost) on keybase.
  • I have a public key whose fingerprint is E2F4 2793 82B3 F1E1 043C 856B AC12 24F2 F037 F489

To claim this, I am signing this object:

@dghost
dghost / gist:87274204fc3fe744214c
Last active July 17, 2021 02:03
Load a BMP with white pixels transparent using SDL2
SDL_Surface* GLimp_LoadIcon(char *name)
{
int32_t size;
SDL_Surface *result = NULL;
void *buffer = NULL;
// load the BMP using engine-specific load call
size = FS_LoadFile(name,&buffer);
if (buffer)
{
SDL_RWops *rw;
@dghost
dghost / gist:f80e58e93c1f5a67254e
Last active January 29, 2019 03:45
FindSteamworks.cmake - quick and dirty CMake support for the Steamworks SDK
# Locate Steamworks library
# This module defines
# STEAMWORKS_LIBRARY, the name of the library to link against
# STEAMWORKS_INCLUDE_DIR, the directory containing steam/steam_api.h
# STEAMWORKS_FOUND, if false, do not try to link to Steamworks
#
# If a path is set in the SteamworksDIR environment variable it will check there
#
# This has been tested on OS X
# This may or may not with Linux - it should, but i think it could be broken easily
@dghost
dghost / gist:13be7161005e7c817e39
Created March 2, 2015 10:41
FindOVR.cmake - quick and dirty attempt to wrangle libovr on Linux and OS X
# Locate OVR library
# This module defines
# OVR_LIBRARY, the name of the library to link against
# OVR_INCLUDE_DIR, the directory containing OVR.h
# OVR_CAPI_INCLUDE_DIR, the directory containing OVR_CAPI.h
# OVR_FOUND, if false, do not try to link to OVR
#
# If a path is set in the OVRDIR environment variable it will check there
#
# This has been tested on OS X
@dghost
dghost / gist:20ee2f55deb89861230b
Last active August 29, 2015 14:15
Load BMFont Text format files into a Python dictionary...
# loads a BMFont Text format glyph atlas into a dictionary
# see https://71squared.com/blog/bitmap-font-file-format for more info
def loadGlyphAtlas(filename):
atlas = {}
for line in open(filename):
attributes = line.split(" ")
attributes = [x for x in attributes if x != '' and x != '\n']
dictkey = attributes[0]
if dictkey in atlas:
attribdict = atlas[dictkey]
@dghost
dghost / gist:8ea97e3d4f55590d75e0
Last active August 29, 2015 14:04
SDL2 / Rift Direct HMD / GL Context Troubles
#define GLEW_STATIC
#include "GL/glew.h"
// Uncomment your platform
#define OVR_OS_WIN32
//#define OVR_OS_MAC
//#define OVR_OS_LINUX
#include "OVR_CAPI_GL.h"
#include "Kernel/OVR_Math.h"
#include "SDL.h"
#include "SDL_syswm.h"