Skip to content

Instantly share code, notes, and snippets.

@roxlu
roxlu / CMakeLists.txt
Created May 30, 2013 14:32
CMake: how to copy a Framework on Mac to the install directory (${roxlu_app_install_dir}) and change the @executable_path so that your application can link with it
# EXPERIMENTAL: Copy frameworks from extern/lib/mac/frameworks, to the install dir and set the @executable paths
# frameworks from the extern/lib/mac/frameworks dir
# ----------------------------------------------------------------------------
foreach(framework_name in ${roxlu_frameworks})
set(framework_dir ${roxlu_base_dir}/extern/lib/mac/frameworks/${framework_name}.framework)
if(IS_DIRECTORY ${framework_dir})
set(framework_dest_dir ${roxlu_app_install_dir}/lib/)
set(framework_file ${framework_dest_dir}${framework_name}.framework/${framework_name})
get_filename_component(framework_file ${framework_file} ABSOLUTE)
@roxlu
roxlu / YUV420PGrabber.cpp
Created July 2, 2013 08:36
OpenGL RGB > YUV420P shader/class (doesn't do much more. implementation/usage is up to you)
#include <assert.h>
#include <roxlu/core/Utils.h>
#include <roxlu/core/Log.h>
#include "YUV420PGrabber.h"
YUV420PGrabber::YUV420PGrabber()
:y_prog(0)
,y_vert(0)
,y_frag(0)
,uv_prog(0)
@roxlu
roxlu / openframeworks_fbo_test.cpp
Created June 26, 2012 08:50
Raw FBO, openFrameworks
#include "testApp.h"
#include "Error.h"
//--------------------------------------------------------------
void testApp::setup(){
ofEnableNormalizedTexCoords();
ofDisableArbTex();
int w = ofGetWidth();
int h = ofGetHeight();
@roxlu
roxlu / X264Encoder.cpp
Created June 26, 2013 21:01
X264 encoder example
#include <roxlu/core/Log.h>
#include <roxlu/core/Utils.h>
#include <video/X264Encoder.h>
X264Encoder::X264Encoder()
:in_width(0)
,in_height(0)
,in_pixel_format(AV_PIX_FMT_NONE)
,out_width(0)
,out_height(0)
@roxlu
roxlu / Spline.h
Created December 4, 2013 17:35
Catmull Rom spline interpolation
#ifndef ROXLU_SPLINEH
#define ROXLU_SPLINEH
#include <vector>
/**
* Catmull Rom interpolation.
* --------------------------
* Catmull Rom interpolation works with 4 points, there the
* local "t" value is used to interpolate between points B and C. The
@roxlu
roxlu / ssl_test2.c
Created March 28, 2014 15:12
Compact example of how to use openSSL with self signed (no password) keys/certificates, DTLS and memory BIOs
/*
Create server/client self-signed certificate/key (self signed, DONT ADD PASSWORD)
openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -keyout client-key.pem -out client-cert.pem
openssl req -x509 -newkey rsa:2048 -days 3650 -nodes -keyout server-key.pem -out server-cert.pem
*/
#include <stdio.h>
@roxlu
roxlu / RendezVousClient.cpp
Created May 25, 2016 19:34
STUN + RendezVous Server / Cliet
#include <poly/Log.h>
#include <RendezVousClient.h>
#include <RendezVousTypes.h>
namespace poly {
/* -------------------------------------------------------------- */
RendezVousClientSettings::RendezVousClientSettings()
:rv_port(0)
@roxlu
roxlu / list.txt
Created January 25, 2013 19:22
List of compiler targets. Use for example: ./configure --target=x86-darwin11-gcc
armv5te-android-gcc armv5te-linux-rvct armv5te-linux-gcc
armv5te-none-rvct
armv6-darwin-gcc armv6-linux-rvct armv6-linux-gcc
armv6-none-rvct
armv7-android-gcc armv7-darwin-gcc armv7-linux-rvct
armv7-linux-gcc armv7-none-rvct
mips32-linux-gcc
ppc32-darwin8-gcc ppc32-darwin9-gcc ppc32-linux-gcc
ppc64-darwin8-gcc ppc64-darwin9-gcc ppc64-linux-gcc
sparc-solaris-gcc
@roxlu
roxlu / TestPattern.cpp
Created September 5, 2013 18:12
Example usage of X264. We create a raw YUV pattern and encode it with x264.
#include <cmath>
#include <assert.h>
#include <core/TestPattern.h>
TestPattern::TestPattern()
:w(0)
,h(0)
,frame_num(0)
,duration(0)
@roxlu
roxlu / Weather.cpp
Created January 6, 2014 11:11
CURL retrieve HTML into string
size_t weather_write_data(void* ptr, size_t size, size_t nmemb, void* str) {
std::string* s = static_cast<std::string*>(str);
std::copy((char*)ptr, (char*)ptr + (size + nmemb), std::back_inserter(*s));
return size * nmemb;
}
std::string weather_download_yahoo_rss() {
std::string result;
std::string url = "http://weather.yahooapis.com/forecastrss?w=10242&u=c"; // w=10242 is Aberaron