Skip to content

Instantly share code, notes, and snippets.

View andy-thomason's full-sized avatar

Andy Thomson andy-thomason

View GitHub Profile
@andy-thomason
andy-thomason / python_vr_triangle.py
Created July 16, 2017 16:10
Tiny VR triangle sample in Python with OpenVR
import time
import sdl2
import openvr
import numpy
from OpenGL.GL import *
from OpenGL.GL.shaders import compileShader, compileProgram
from openvr.glframework import shader_string
from sdl2 import *
trait Animal {
fn number_of_legs(&self) -> i32;
fn speak(&self) -> String;
fn eat(&mut self);
}
struct Cat {
@andy-thomason
andy-thomason / Genomics_A_Programmers_Guide.md
Created May 14, 2019 13:32
Genomics a programmers introduction

Genomics - A programmer's guide.

Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.

https://www.genomicsplc.com

@andy-thomason
andy-thomason / inverting_stb_image.cpp
Last active May 8, 2023 15:49
Inverting stbi_image using C++11 threading operations.
////////////////////////////////////////////////////////////////////////////////
//
// Example of converting stb_image to a libjpeg-style background process.
// This enables you to stream JPEG files from the internet and interleave
// decoding time without frameout on the main thread.
//
// The example uses three parts of the C++11 threads API.
// 1) std::async This is used to run the loader in its own thread.
// 2) std::mutex This is used to protect the members of the class from race
// conditions.
@andy-thomason
andy-thomason / exif.cpp
Created July 30, 2017 22:15
Example of extracting a JPEG thumbnail from a camera Exif JPEG image.
//////////////////////////////////////////////////////////////////////////////////////////
//
// Example Exif thumbnail extractor.
//
#include <iostream>
#include <fstream>
#include <vector>
import numpy as np
import pyarrow as pa
import pyarrow.feather as pf
import pandas as pd
dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8', 'f4', 'f8']
strings = ['a', 'bc', 'de', 'efgh', 'five']
cols = {d: np.ones(dtype=d, shape=(20)) for d in dtypes}
@andy-thomason
andy-thomason / webgl.html
Created July 16, 2017 10:28
WebGL triangle in 58 lines
<html>
<head>
<script>
function main() {
var canvas = document.getElementById("myGLCanvas");
try {
gl = canvas.getContext("webgl");
} catch(e) {
console.log(e);
}
@andy-thomason
andy-thomason / sdl_hello_triangle.cpp
Created July 25, 2017 10:45
Short SDL triangle example
#define GL_GLEXT_PROTOTYPES 1
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengles2.h>
int main() {
auto window = SDL_CreateWindow(
"triangle", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
);
@andy-thomason
andy-thomason / exif_example.cpp
Created July 18, 2017 09:16
Extract a thumbnail from a camera JPEG file using libexif
#include <stdio.h>
#include <libexif/exif-loader.h>
// Note: no error handling and no cleanup for clarity.
int main()
{
ExifLoader *loader = exif_loader_new();
exif_loader_write_file(loader, "IMG_20170422_132409.jpg");
ExifData *ed = exif_loader_get_data(loader);
ed = exif_loader_get_data(loader);