Skip to content

Instantly share code, notes, and snippets.

@andrewfb
andrewfb / StreamingBuffer.cpp
Created February 26, 2019 01:47
Implementation of cinder::StreamingBuffer
StreamingBuffer::StreamingBuffer( size_t blockSizeBytes )
: mBlockSize( std::max<size_t>( blockSizeBytes, 1 ) )
{
allocateNewWriteBlock();
mReadOffset = 0;
}
void StreamingBuffer::pushFront( const void *data, size_t dataSize )
{
std::lock_guard<std::mutex> lock( mMutex );
@andrewfb
andrewfb / StreamingBuffer.h
Created February 26, 2019 01:46
Interface of cinder::StreamingBuffer
class CI_API StreamingBuffer {
public:
StreamingBuffer( size_t blockSizeBytes = 65536 );
StreamingBuffer( const StreamingBuffer &rhs ) = delete;
StreamingBuffer( StreamingBuffer &&rhs ) = delete;
void pushFront( const void *data, size_t sizeBytes );
size_t popBack( void *output, size_t maxSize );
size_t getSize() const;
@andrewfb
andrewfb / gist:5338181
Created April 8, 2013 16:30
Demonstrates using params::InterfaceGl with multiple windows.
#include "cinder/app/AppBasic.h"
#include "cinder/Rand.h"
#include "cinder/params/params.h"
#include <list>
using namespace ci;
using namespace ci::app;
using namespace std;
// We'll create a new Cinder Application by deriving from the AppBasic class
@andrewfb
andrewfb / gist:1872308
Created February 20, 2012 23:36
Convert a cinder::Shape2d into C++ code that generates its equivalent
void outputCinderCode( const Shape2d &shape, const std::string &name )
{
app::console() << "Shape2d " << name << ";" << std::endl;
for( vector<Path2d>::const_iterator pathIt = shape.getContours().begin(); pathIt != shape.getContours().end(); ++pathIt ) {
app::console() << name << ".appendContour( Path2d() );" << std::endl;
size_t pt = 0;
app::console() << name << ".getContours().back().moveTo( " << pathIt->getPoints()[0].x << ", " << pathIt->getPoints()[0].y << " );" << std::endl;
pt++;
for( std::vector<Path2d::SegmentType>::const_iterator segIt = pathIt->getSegments().begin(); segIt != pathIt->getSegments().end(); ++segIt ) {
if( *segIt == Path2d::CLOSE )