Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Gfrerer tgfrerer

View GitHub Profile
@tgfrerer
tgfrerer / README.md
Last active May 11, 2021
Generate bitonic merge sort network based on number of sortable items n, and workgroup size.
View README.md

This command-line utility generates a bitonic merge sort network based on number of sortable items n, and workgroup size.

Choose workgroup size to be ==n for an ideal sorting network. Number of sortable elements n must be power of two.

In-depth discussion, GPU implementation, and context for this code: https://poniesandlight.co.uk/reflect/bitonic_merge_sort/

View recursive_templates.cpp
#include <iostream>
using namespace std;
#define COMPONENT( x ) \
struct x { \
static constexpr auto type_id = #x; \
}
COMPONENT( ComponentA );
@tgfrerer
tgfrerer / mip.cpp
Created Nov 27, 2018
Calculate miplevels for image input data
View mip.cpp
// Generate mipmap from input data
// adapted from https://github.com/ValveSoftware/openvr/blob/1fb1030f2ac238456dca7615a4408fb2bb42afb6/samples/hellovr_vulkan/hellovr_vulkan_main.cpp#L2271
template <typename PixelType, const size_t numChannels>
static void generate_mipmap( const PixelType *pSrc, PixelType *pDst, uint32_t const nSrcWidth, uint32_t const nSrcHeight, uint32_t *pDstWidthOut, uint32_t *pDstHeightOut ) {
*pDstWidthOut = nSrcWidth / 2;
if ( *pDstWidthOut <= 0 ) {
*pDstWidthOut = 1;
}
*pDstHeightOut = nSrcHeight / 2;
@tgfrerer
tgfrerer / drawfrustum.cpp
Last active Feb 9, 2018
simplified method to draw camera frustum in oF
View drawfrustum.cpp
void ofCamera::drawFrustum(const ofRectangle & viewport) const {
ofPushMatrix();
// In World Space, the camera frustum is the "capped pyramid" which
// contains everything which can be seen from a camera.
//
// In Clip Space, the frustum is defined as a box with dimensions: -1, -1, -1 to +1, +1, +1.
//
// Much simpler.
//
@tgfrerer
tgfrerer / main.cpp
Created Jul 28, 2017
minimal demo app showing camera frustum drawing
View main.cpp
#include "ofMain.h"
class ofApp: public ofBaseApp {
ofEasyCam cam[2];
size_t activeCam = 1;
public:
void ofApp::setup() {
cam[0].setupPerspective( false, 30, 20.f, 500.f );
View keybase.md

Keybase proof

I hereby claim:

  • I am tgfrerer on github.
  • I am tgfrerer (https://keybase.io/tgfrerer) on keybase.
  • I have a public key ASCROk4gEgu9DxcKrfoJ5u3A0OOIhkRcZ7Z2hncyv4_l7go

To claim this, I am signing this object:

View main.cpp
#include "ofMain.h"
ofPolyline polyline;
uint64_t pointFlags = -1;
class ofApp : public ofBaseApp
{
public:
View ofnode_orbit_test.cpp
#include "ofMain.h"
class ofApp : public ofBaseApp {
ofVboMesh mSphere;
ofNode mNode;
ofNode mNode1;
ofNode mNode2;
View main.cpp
#include "ofMain.h"
#include "ofApp.h"
class ofApp : public ofBaseApp {
ofEventListener listener;
ofParameter<float> param;
public:
void setup() {
@tgfrerer
tgfrerer / compile_log.txt
Last active Feb 5, 2016
testcase for oF lambda events
View compile_log.txt
1>------ Build started: Project: testEventListener, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\tim\documents\developer\of\libs\openframeworks\events\ofEvent.h(441): error C2668: 'ofEvent<ofMouseEventArgs,std::recursive_mutex>::make_function': ambiguous call to overloaded function
1> c:\users\tim\documents\developer\of\libs\openframeworks\events\ofEvent.h(398): note: could be 'std::shared_ptr<of::priv::Function<T,Mutex>> ofEvent<T,Mutex>::make_function(of::priv::BaseEvent<of::priv::Function<T,Mutex>,Mutex>::check_function<void (const void *,T &)>,int)'
1> with
1> [
1> T=ofMouseEventArgs,
1> Mutex=std::recursive_mutex
1> ]
1> c:\users\tim\documents\developer\of\libs\openframeworks\events\ofEvent.h(394): note: or 'std::shared_ptr<of::priv::Function<T,Mutex>> ofEvent<T,Mutex>::make_function(of::priv::BaseEvent<of::priv::Function<T,Mutex>,Mutex>::check_function<void (T &)>,int)'