Skip to content

Instantly share code, notes, and snippets.

Daniel Gibson DanielGibson

Block or report user

Report or block DanielGibson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sdl_fullscreentest.c
// can be built with:
// $ gcc -o sdl2test `sdl2-config --cflags` sdl_fullscreentest.c `sdl2-config --libs`
// will try to create a fullscreen window with 1920x1080 by default,
// but accepts commandline arguments to use a different resolution, like
// $ ./sdl2test 2560 1440
// will create testlog.txt and write some info there
#include <SDL.h>
#include <unistd.h>
@DanielGibson
DanielGibson / flexarr.cpp
Last active Jan 11, 2019
C++ Flexible Array example
View flexarr.cpp
/*
* (C) 2019 Daniel Gibson
*
* This software is dual-licensed to the public domain and under the following
* license: you are granted a perpetual, irrevocable license to copy, modify,
* publish, and distribute this file as you see fit.
* No warranty implied; use at your own risk.
*/
#include <stdlib.h> // size_t
@DanielGibson
DanielGibson / warptest.c
Created May 6, 2018
testcase for SDL2 bug #4152 (and the old #3931)
View warptest.c
// gcc -Wall -o warptest `sdl2-config --cflags` warptest.c `sdl2-config --libs`
#include <stdio.h>
#include <SDL.h>
static FILE* outfile = NULL;
static void UpdateWinTitle(int accumX, int accumY, SDL_Window* win)
{
char buf[128];
@DanielGibson
DanielGibson / al_funcs.h
Last active Apr 10, 2018
OpenAL function in X-Macros, can be used to define and load function pointers etc
View al_funcs.h
/*
* All function names and corresponding pointer-to-function-types
* from the OpenAL headers, wrapped in a magic macro so it can be used for whatever.
*
* Idea for the magic X macro from Walter Bright:
* http://www.drdobbs.com/cpp/the-x-macro/228700289
*
* To use this, you have to #define the AL_X_MAGIC(fn, fnptrt)
* macro for the AL_H_FUNCS and ALC_H_FUNCS and the
* ALEXT_X_MAGIC(fn, fnptrt, ext) macro for the ALEXT_H_FUNCS and EFX_H_FUNCS
@DanielGibson
DanielGibson / GOG-Q2-Trackmapping.txt
Last active Jun 10, 2018
GOG Quake2 Trackname mapping to Yamagi Quake2 Tracks
View GOG-Q2-Trackmapping.txt
GOG music/Track02.ogg to Track11.ogg => baseq2/music/02.ogg .. 11.ogg
Track12.ogg .. Track21.ogg => rogue/music/02.ogg .. 11.ogg
For xatrix it's like to following
(xatrix track number => Q2/Ground Zero(GZ) Track number => GOG Track number)
02 => Q2:09 => Track09
03 => GZ:03 => Track13
04 => GZ:04 => Track14
05 => Q2:07 => Track07
@DanielGibson
DanielGibson / extract_daikatana_gog.sh
Created Jan 24, 2018
A shellscript that extracts Daikatana from the GOG Inno Setup installer into the current directory
View extract_daikatana_gog.sh
#!/bin/sh
INSTALLER_PATH="$1"
print_usage () {
echo "Usage: "
echo " $0 /path/to/setup_daikatana_2.0.0.3.exe"
}
print_bug_info () {
@DanielGibson
DanielGibson / TestMouseWarp.cpp
Last active May 6, 2018
Test "SetCursorPos() doesn't always generate mouse events"
View TestMouseWarp.cpp
// This is mostly generated by Visual Studio 2013, I marked all places I changed/added with // DG: ...
// this probably doesn't build as is; I didn't know how to create a portable Visual Studio "solution"
// or which parts of the project folder are relevant..
// when running this, you can quit with Alt+F4
// TestMouseWarp.cpp : Defines the entry point for the application.
//
#include <windowsx.h>
@DanielGibson
DanielGibson / SDL_mouse.c
Last active Dec 6, 2017
test sdl relative mouse input with mouse warping
View SDL_mouse.c
// in src/events/SDL_mouse.c added some SDL_Log() calls to SDL_PrivateSendMouseMotion():
#include "SDL_log.h"
static int
SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
int posted;
int xrel;
int yrel;
@DanielGibson
DanielGibson / guess_libstdcpp_ver.c
Last active Jun 29, 2017
Find out which version of libstdc++.so.6, libgcc_s.so.1 and libSDL2-2.0.so.0 is installed on a (x86 or x86_64) Linux system
View guess_libstdcpp_ver.c
/*
* Try to find out the libstdc++.so.6 version on the (x86 or x86_64) Linux
* system this is executed on.
* (you could then use that information to decide whether to use LD_PRELOAD
* or LD_LIBRARY_PATH to make a C++ program launched from here use a newer
* version of libstdc++.so.6 that you provide)
*
* (C) 2017 Daniel Gibson
*
* LICENSE
View testrapidjson.cpp
// this is hacky and assumes messages.json is <64k bytes. that's the case for
// https://github.com/kamalmarhubi/one-second/blob/master/setup/protobuf/message.json
#include "rapidjson/document.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
size_t numIterations = 1;
You can’t perform that action at this time.