Skip to content

Instantly share code, notes, and snippets.

SHADERS
When not explicity specifying what texture target to use, OF uses GL_TEXTURE_RECTANGLE_ARB by default.
This results in shaders having to use sampler2DRect for the texture type and real texture coordinates.
By calling ofDisableArbTex() texture targets are switched to GL_TEXTURE_2D.
This results in shaders having to use sampler2D as texture type and Normalized coordinates.
@bgstaal
bgstaal / gist:5665027
Created May 28, 2013 18:37
Float to buffer to string back to float
float f = -0.123456;
size_t n = sizeof(f); //number of bytes in a float
unsigned char buffer[n]; //create buffer of n bytes
memcpy(&buffer, &f, n); // copy underlying bytes from float to buffer
string str((char *)buffer, n); //instantiate new string with contents of buffer
float f2;
memcpy(&f2, str.data(), n); //copy bytes from string data prop to f2
printf("%f\n", f2); // prints -0.123456
@bgstaal
bgstaal / jQuery.clicktouch
Created May 9, 2012 07:10
Overrides bind and unbind of "click" events and adds touch event handlers where available to avoid 300ms delays on certain devices
(function ($)
{
var superBind = $.fn.bind;
var superUnbind = $.fn.unbind;
var touchHandlersKey = "clicktouchHandlers";
// override bind
$.fn.bind = function ()
{
var $window = $(window);
@bgstaal
bgstaal / tree.js
Created April 25, 2012 10:38
Make tree structure from map object
var tree = function(map)
{
var treeStructure = {};
var names;
var name;
var i;
var numNames;
var currentObject = treeStructure;
var lastIndex;