Skip to content

Instantly share code, notes, and snippets.

View cdave1's full-sized avatar
💭
I may be slow to respond.

David Petrie cdave1

💭
I may be slow to respond.
View GitHub Profile
@cdave1
cdave1 / Poker tool pseudocode
Created November 26, 2010 07:14
Noodling around with an idea, code is unfinished...
struct card { short suit, short value }
struct player { card first, card second }
struct middle { card flop1, card flop2, card flop3, card turn, card river }
player players[ ]
int my_position
card cards[52]
@cdave1
cdave1 / gist:801522
Created January 29, 2011 04:10
Dot product shadow intensity lookup table...completely broken and slow
static bool hasGeneratedLookup = false;
#define DOT_LOOKUP_SIZE 1024
#define DOT_LOOKUP_BITMASK 1023
static uint8 colorDotLookup[DOT_LOOKUP_SIZE];
/*
* Below code - waste of time; too slow.
*/
inline uint8 hdColorDot(float color, float normal)
{
unsigned i;
@cdave1
cdave1 / ftglesGlueAndroid.c
Created March 29, 2011 23:58
Changes to ftglBegin and ftglEnd on android...
GLvoid ftglBegin(GLenum prim)
{
if (!ftglesQuadIndicesInitted)
{
for (int i = 0; i < FTGLES_GLUE_MAX_VERTICES * 3 / 2; i += 6)
{
int q = i / 6 * 4;
ftglesGlueArrays.quadIndices[i + 0] = q + 0;
ftglesGlueArrays.quadIndices[i + 1] = q + 1;
ftglesGlueArrays.quadIndices[i + 2] = q + 2;
@cdave1
cdave1 / gist:10563386
Created April 13, 2014 00:21
Play an mp3 with SDL2
#include "SDL2/SDL.h"
#include "SDL2/SDL_mixer.h"
static const char *MY_COOL_MP3 = "cool_tunes.mp3";
int main(int argc, char **argv) {
int result = 0;
int flags = MIX_INIT_MP3;
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
@cdave1
cdave1 / gist:e21160c63977ffe6f616
Created May 12, 2014 03:58
Pure fragment shader -- circle pattern
// circles by @davidppp
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
// total number of samples at each fragment
#define NUM_SAMPLES {{ numSamples }}
#define NUM_SPIRAL_TURNS {{ numSpiralTurns }}
#define USE_ACTUAL_NORMALS {{ useActualNormals }}
#define VARIATION {{ variation }}
uniform sampler2D sGBuffer;
@cdave1
cdave1 / build-bananapi-3.12.28.sh
Last active August 29, 2015 14:06
Experimental shell for creating an image with 3.12.28 of the kernel (image did not boot for me). REQUIRES kernel 3.12.28 from kernel.org
#!/bin/bash
rm -rf build
mkdir -p build/boot
echo "[INFO] Creating u-boot-bananapi"
if [ ! -d u-boot-bananapi ]; then
git clone https://github.com/LeMaker/u-boot-bananapi.git
elif [ -d u-boot-bananapi ]; then
( cd u-boot-bananapi && git pull )
@cdave1
cdave1 / build-banana-pi.3.4.90.sh
Created September 27, 2014 04:24
Shell script for creating banana pi image with kernel 3.4.90
#!/bin/bash
rm -rf build
mkdir -p build
echo "[INFO] Creating u-boot for bananapi"
if [ ! -d u-boot-bananapi ]; then
git clone https://github.com/LeMaker/u-boot-bananapi.git
elif [ -d u-boot-bananapi ]; then
( cd u-boot-bananapi && git pull )
bootargs=console=ttyS0,115200 console=tty0 disp.screen0_output_mode=EDID:1280x720p50 hdmi.audio=EDID:0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
aload_script=fatload mmc 0 0x43000000 script.bin;
aload_kernel=fatload mmc 0 0x48000000 uImage; bootm 0x48000000;
uenvcmd=run aload_script aload_kernel
ext2load mmc 0 0x48000000 uImage
ext2load mmc 0 0x43000000 sun7i-a20-bananapi.dtb
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait panic=10 ${extra}
bootm 0x48000000