Skip to content

Instantly share code, notes, and snippets.

@progschj
progschj / vorbisplay.c
Created October 13, 2012 19:54
A Simple Ogg Vorbis Player using libvorbisplay and OpenAL
#include <stdlib.h>
#include <stdio.h>
#include <AL/alut.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
char pcmout[16*1024];
void check_error()
{
@progschj
progschj / glwt_event.h
Created November 10, 2012 14:47
GLWT event prototype
#define GLWT_EVENT_INPUT 1
#define GLWT_EVENT_WINDOW 2
#define GLWT_EVENT_HOTPLUG 3
#define GLWT_EVENT_INPUT_KEY 1
#define GLWT_EVENT_INPUT_BUTTON 2
#define GLWT_EVENT_INPUT_ABS 3
#define GLWT_EVENT_INPUT_REL 4
#define GLWT_EVENT_WINDOW_RESIZE 1
@progschj
progschj / A.cpp
Last active December 11, 2015 07:09
Testcase for Luabridge Placing luabridge "registration" into different translation units can lead to types not being recognized correctly
#include "A.hpp"
#include <iostream>
#include <string>
#include <LuaBridge/LuaBridge.h>
std::string A::getName() const { return std::string("A"); }
void A::register_lua(lua_State *L)
#include <iostream>
#include <memory>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <LuaBridge/LuaBridge.h>
@progschj
progschj / TwinStick.cpp
Created March 26, 2013 10:05
A simple multiplayer "twin stick shooter" done during 3h hours at a gamespace.ch meet and make. I started with this: https://github.com/progschj/OpenGL-Examples/blob/master/02indexed_vbo.cpp and just added stuff from there. It has only been tested with two wireless xbox360 controllers.
/* 3h Twin stick shooter
* Autor: Jakob Progsch
*/
#include <GL3/gl3w.h>
#include <GL/glfw.h>
#include <iostream>
#include <string>
#include <vector>
@progschj
progschj / on_destroy.hpp
Created April 8, 2013 00:14
Helper class to use "RAII" with nonpointer objects
#ifndef ON_DESTROY_H
#define ON_DESTROY_H
#include <functional>
#include <utility>
class on_destroy {
public:
on_destroy() { }
template<class F, class... Args>
@progschj
progschj / gist:5868976
Created June 26, 2013 16:30
WiP orbital mechanics code
#include <iostream>
#include <cmath>
#include <utility>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
const double G = 6.674e-11; // gravitational constant
const double PI = 3.14159265358979323846;
@progschj
progschj / kepler.cpp
Created October 21, 2013 15:00
Some code to calculate closed form Kepler orbits and comparing the solution of a numerical integrator.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <utility>
#include <glm/glm.hpp>
const double G = 6.674e-11; // gravitational constant
const double PI = 3.14159265358979323846;
@progschj
progschj / pngraymarcher.cpp
Created November 21, 2013 20:29
I was supposed to write a png writing function for our students to output grid data from a diffusion simulation. This is the example code to go along with it... (it's a raymarcher with antialiasing and reflections).
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
int write_png(const char *file_name, int width, int height, unsigned char *data) {
@progschj
progschj / hash_map2d.c
Created December 25, 2013 22:45
A 2d Hash map
#include "hash_map2d.h"
#include <stdlib.h>
static unsigned hash_map2d_hash(int x, int y) {
unsigned h = 65521u*x + 101u*y;
return h;
}
static hash_map2d_entry* hash_map2d_alloc(int capacity) {