Skip to content

Instantly share code, notes, and snippets.

@MartinBspheroid
MartinBspheroid / vectorArrayManager
Created October 14, 2013 09:00
Vector array for particle systems etc.
for(vector<bloomPop>::iterator it = bloomPool.begin(); it != bloomPool.end();){ // loop through vector with iterator
it->update(); // update all objects in vector
if(it->time < 0){ /// if condition matches...
it = bloomPool.erase(it); // ..go to hell..
}else{
++it; // ..or keep counting and continue!
}
}
@MartinBspheroid
MartinBspheroid / grainnoise.frag
Created November 18, 2013 19:02
GLSL noise one-liner
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
@MartinBspheroid
MartinBspheroid / vectorArrayManager2
Created January 25, 2014 13:25
Vector Array Manager 2 - C++11 compatible
auto i = std::begin(inv);
while (i != std::end(inv)) {
// do some stuff
if (blah)
i = inv.erase(i);
else
++i;
}
@MartinBspheroid
MartinBspheroid / gist:8782425
Created February 3, 2014 11:35
OF Hide console for VS2012
// in main.cpp
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
@MartinBspheroid
MartinBspheroid / gist:8902181
Last active November 16, 2022 05:39
openFrameworks hacks (win64)
// TESTED ON nightly-build ver 0.8 (of_v20130813) in Visual Studio 2012 - Win64
// MAKE APP ALWAYS ON TOP
HWND AppWindow = GetActiveWindow();
SetWindowPos(AppWindow, HWND_TOPMOST, NULL, NULL, NULL, NULL, SWP_NOMOVE | SWP_NOSIZE);
// DISABLE FUNCTION DESCRIBED ABOVE
HWND AppWindow = GetActiveWindow();
@MartinBspheroid
MartinBspheroid / gist:9742374
Last active August 29, 2015 13:57
Cinder-RuttEtra
#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
#include "cinder\Capture.h"
#include "cinder\Surface.h"
#include "cinder/gl/Texture.h"
#include "cinder/MayaCamUI.h"
#include "cinder/Camera.h"
#include "cinder\Utilities.h"
#include "cinder/params/Params.h"
#include "cinder/ip/EdgeDetect.h"
@MartinBspheroid
MartinBspheroid / gist:9900219
Created March 31, 2014 19:25
FMOD waveforms in Cinder
void Player::getWaveformPreview(vector <Vec2f> &preview, unsigned int size){
if (size == 0)
{
return;
}
preview.clear();
peak = 0;
void *waveData;
void *pointer2;
@MartinBspheroid
MartinBspheroid / gist:9920572
Created April 1, 2014 18:52
Usefull C++ stuff
double PI = 4.0 * atan(1.0); // precise PI calculation
@MartinBspheroid
MartinBspheroid / ciAngel_Bind_StdVector.h
Created April 8, 2014 09:23
std::vector bindings for AngelScript
/*
std::vector binding library for AngelScript
Copyright (c) 2004 Anthony "JM" Casteel
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
@MartinBspheroid
MartinBspheroid / BullDog
Last active August 29, 2015 14:27
minimal autoreloading in Cinder it's called BullDog, LOL!!!!
/// minimal autoreloading in cinder
/// it's called BullDog, LOL!!!!
struct wFile
{
time_t time;
fs::path path;
std::function<void()> callback;
wFile(time_t t, fs::path p, std::function<void()> c) {
time = t;
path = p;