Skip to content

Instantly share code, notes, and snippets.

View ryanbartley's full-sized avatar

Ryan Bartley ryanbartley

View GitHub Profile
# 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
#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;
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 );
@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;
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" );
// 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 ) ) {
@ryanbartley
ryanbartley / HelloBatch.cpp
Created May 19, 2016 21:13
Helper files getting into OpenGL and Cinder
#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class HelloTriangleApp : public App {
public:
GLTFAnimationFlattener(COLLADAFW::Node *node) {
this->_transformsOrder = std::shared_ptr <std::vector<std::string> > (new std::vector<std::string>);
const COLLADAFW::TransformationPointerArray& transformations = node->getTransformations();
size_t transformationsCount = transformations.getCount();
int index = 0;
std::cout << "--------------------------------------------------------------------------------------" << std::endl;
this->_hasAnimatedScale = this->_hasAnimatedTranslation = this->_hasAnimatedRotation = false;
this->_targetUID = node->getOriginalId();
std::cout << "Target UID; " << this->_targetUID << " name: " << node->getName() << " trans count: " << transformationsCount << std::endl;
<animation id="Cube_location_X">
<source id="Cube_location_X-input">
<float_array id="Cube_location_X-input-array" count="4">0.04166662 0.5416667 1.083333 1.666667</float_array>
<technique_common>
<accessor source="#Cube_location_X-input-array" count="4" stride="1">
<param name="TIME" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Cube_location_X-output">
std::vector<SdfText::InstanceVertex> SdfText::getGlyphVertices( const SdfText::Font::GlyphMeasures &glyphMeasures, const DrawOptions &options, const std::vector<ColorA8u> &colors )
{
const auto& textures = mTextureAtlases->mTextures;
const auto& glyphMap = mTextureAtlases->mGlyphInfo;
const auto& sdfScale = mTextureAtlases->mSdfScale;
const auto& sdfPadding = mTextureAtlases->mSdfPadding;
if( textures.empty() ) {
return std::vector<SdfText::InstanceVertex>();
}