Skip to content

Instantly share code, notes, and snippets.

View ryanbartley's full-sized avatar

Ryan Bartley ryanbartley

View GitHub Profile
// just give it a path getAssetPath( "MyEnormous.obj" ) and it'll do the rest.
// the first time through will be very long. :)
geom::SourceRef getGeometry( const ci::fs::path &geomPath )
{
auto tri = TriMesh::create( TriMesh::Format().positions().normals().texCoords() );
if( geomPath.extension() == ".obj" ) {
auto binPath = geomPath;
binPath.replace_extension( "bin" );
if( !fs::exists( binPath ) ) {
ocl::printSupportedImageFormats( mClContext, CL_MEM_OBJECT_IMAGE2D );
auto imageSource = loadImage( loadAsset( "sunset.jpg" ) );
mClImage = ocl::createImage2D( imageSource, mClContext );
mClBuffer = ocl::createBuffer( imageSource, mClContext );
auto source = ocl::createSource( mClImage );
mGlTexture = gl::Texture2d::create( source );
writeImage( getAppPath(), source, ImageTarget::Options(), "png" );
@ryanbartley
ryanbartley / Timer.h
Last active January 13, 2016 18:13
Timer Impl
#include <chrono>
namespace cinder {
// nanoseconds Alias
using nanoseconds = std::chrono::nanoseconds;
/** \brief A high-resolution timer class **/
class Timer {
using clock = std::chrono::high_resolution_clock;
namespace osc {
template<typename ReceiveProtocol>
class Server {
public:
Server( asio::io_server &io = app::App::get()->io_service() );
Server( const Server &server ) = delete;
Server& operator=( const Server &server ) = delete;
Server( Server &&server );
Server& operator=( Server &&server );
#include "cinder/app/AppNative.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "cinder/qtime/QuickTimeGl.h"
#include "cinder/gl/Texture.h"
using namespace ci;
using namespace ci::app;
using namespace std;
# Computer needs to generate a secret number
secret_number = rand(5) + 1
# initialize a variable called trys that equals 0
# begin the loop
# Tell the user to guess a number between 1 and 10
puts "guess a number between 1 and 5"
# User guesses a number
user_guess = gets.to_i