Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / compile_libav.sh
Created January 8, 2013 17:04
Compilng libav with Microsoft Visual Studio 2010 / 2012
#!/bin/sh
# Compiling libav on windows
# --------------------------
# Compiling libav takes quite a bit of time and you need to setup a build
# environment. I've followed these instructions for ffmpeg:
# http://blogs.gnome.org/rbultje/2012/09/27/microsoft-visual-studio-support-in-ffmpeg-and-libav/
#
# How to
# ------
@roxlu
roxlu / VorbisWriter.cpp
Created January 4, 2013 16:34
(Work in progress) Basic audio encoding using vorbis. This code assumes 16 bit mono as input.
#include "VorbisWriter.h"
VorbisWriter::VorbisWriter()
:fp(NULL)
,is_setup(false)
{
}
VorbisWriter::~VorbisWriter() {
close();
@roxlu
roxlu / compile_icecast_mac_64.sh
Created December 27, 2012 11:35
Compiling Icecast (http://www.icecast.org/) with all dependencies on OSX (10.6.8)
#!/bin/bash
# Compile script for icecast, using these libraries:
# --------------------------------------------------
# lame-3.99.5.tar.gz
# libogg-1.3.0.tar.gz
# libsamplerate-0.1.8.tar.gz
# libtheora-1.1.1.tar.bz2
# libtool-2.2.1.10.tar.gz
# libvorbis-1.3.3.tar.gz
@roxlu
roxlu / example.h
Created December 22, 2012 19:45
Using inline shaders with macro which 'stringifies' the shader code.
#ifndef JADI_DEPTH_OF_FIELDH
#define JADI_DEPTH_OF_FIELDH
#include <jadi/Jadi.h>
#include <vector>
#define GLSL(version, shader) "#version " #version "\n" #shader
static const char* DOF_DEBUG_VS = GLSL(120,
uniform mat4 u_pm;
@roxlu
roxlu / AppDelegate.h
Created December 14, 2012 22:42
Bare openGL application template for IOS. This application templates creates a basic GL context with a framebuffer without the need of a nibb. Note: I've based this on the examples from Apple. If something is wrong or there is a better way to create a full screen GL application, please add a comment or fork this.
#import <UIKit/UIKit.h>
#import "AppViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
AppViewController* view_controller;
}
@property (strong, nonatomic) UIWindow *window;
@end
@roxlu
roxlu / Deferred.cpp
Created December 7, 2012 22:16
Deferred shader, very basic setup, just one light and only basic g-buffer.
#include "Deferred.h"
#define glGenVertexArrays glGenVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE
static void print(DeferredVertex& v) {
printf("%f, %f, %f, %f, %f, %f\n", v.x, v.y, v.z, v.nx, v.ny, v.nz);
}
Deferred::Deferred()
@roxlu
roxlu / TrailParticle.cpp
Created December 1, 2012 00:55
MOTION BLUR
#include <TrailParticle.h>
static void print(TrailVertex& v) {
printf("x: %f, y: %f, z: %f\n", v.pos.x, v.pos.y, v.pos.z);
}
TrailParticle::TrailParticle()
:drag(0.99f)
,inv_mass(1.0f)
,mass(1.0f)
@roxlu
roxlu / main.cpp
Created November 2, 2012 09:46
OpenSSL + LibUV: client https
#include <iostream>
#include <libgen.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <uv.h>
#include <vector>
#include <iterator>
#include <algorithm>
@roxlu
roxlu / Socket.cpp
Created September 12, 2012 20:53
Basic Winsock/Posix client socket wrapper (windows/mac)
#include <roxlu/io/Socket.h>
Socket::Socket() {
#ifdef _WIN32
int result = WSAStartup(MAKEWORD(2,2), &wsa_data);
if(result != 0) {
printf("Error: cannot initialize WinSock.\n");
WSACleanup();
}
#endif
@roxlu
roxlu / SnowDrawer.cpp
Created September 11, 2012 20:43
Point Sprites
#include "SnowDrawer.h"
SnowDrawer::SnowDrawer()
:allocated_vertices(500)
,vertices(allocated_vertices,SnowVertex())
,allocated_bytes(0)
,num_flakes(0)
{
}