View stb_truetype_usage.cpp
stbtt_fontinfo ttf_info;
MemoryPtr ttf_file = read_file_to_memory(file_name);
ASSERT(ttf_file.ptr);
stbtt_InitFont(&ttf_info, ttf_file.ptr, stbtt_GetFontOffsetForIndex(ttf_file.ptr, 0));
f32 scale_factor = stbtt_ScaleForPixelHeight(&ttf_info, pixel_height);
i32 ascent, descent, line_gap;
stbtt_GetFontVMetrics(&ttf_info, &ascent, &descent, &line_gap);
View vimrc
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'Valloric/YouCompleteMe'
Plugin 'gilligan/vim-lldb'
View Dumb_varient.hpp
// This really isn't safe.
class var
{
public:
explicit var()
{
}
template<typename T, typename... Args>
View rbez.rb
# Ruby 1.9
def casteljau_bez(t, control_points, i = 1)
print "b#{i} : "
nextset = []
(control_points.length - 1).times do |p|
View gist:1888308
for(unsigned int i = 0; i < verts.size(); ++i)
{
unsigned int e = i;
float fault = m_faultsize;
if(leftOrRightOfFault(ax, ay, bx, by, i % sizeOfRow, i / sizeOfRow)) {
vert[e].position.y += fault;
} else {
vert[e].position.y -= fault;
}
View gist:1672200
// Fill buffers //
getRenderer()->setShader(m_shaders[0]);
getRenderer()->setShader3f("camPos", &m_camera.getPosition());
getRenderer()->setShader4x4f("viewProj", &m_camera.getViewProjectionMatrix());
TextureID bufferRTs[] = { baseRT, normalRT };
getRenderer()->changeRenderTargets(bufferRTs, 2, depthRT);
getRenderer()->setShader4x4f("world", &m_box->getWorldMatrix());
View p_impl.hpp
class Foo
{
class Pimpl;
std::unique_ptr<Pimpl> p_impl;
public:
// .... //
View C++.sublime-build
{
"cmd": ["g++", "$file", "-o", "$file_base_name", "-I/usr/local/include"],
"selector": "source.c++",
"windows":
{
"cmd": ["cl", "/Fo${file_path}", "/O2", "$file"]
}
}
View README.markdown

Simple C++ Unit Testing

About

There are loads of C++ unit testing frameworks out there, I created this one because I was doing lots of small projects on a varity of platforms, which included 10 year old compilers. This testing facility aims to be simple to use and simple to install, only using a single header file and basic features.

Features

  • Single header.
View TargerLoader.cpp
// TargaLoader.cpp
#include <TargaLoader.hpp>
#include <fstream>
namespace Foo
{
TargaTextureLoader::TargaTextureLoader() :
m_data(NULL)