Skip to content

Instantly share code, notes, and snippets.

@Phildo
Phildo / lotterymodel.cpp
Created July 13, 2014 21:34
example lottery model kata
/*
This is an example of modelling someone's lottery ticket collection.
I find this an interesting/worthwhile problem domain as the constraints are easy to understand,
but detials in both design and implementation prove more difficult than intuition might suggest.
Also, it is a sufficiently isolated to tend well towards existing as a TDD kata.
The constraints are as follows:
1. A lottery ticket takes the form of 6 balls. The first 5 range from 1-59, and the final ranges from 1-35.
/*
This file attempts to use stb_voxel_render.h to minimally create a voxel mesh.
The resuting mesh should be a simple voxel sphere w/ 32 unit diameter.
(This will serve as the testing ground for implementing GL_EXT_multiview into
stb_voxel_render.h, whose progress can be found on the voxel_vr branch of this fork:
https://github.com/Phildo/stb/tree/voxel_vr )
*/
#define STBVOX_CONFIG_MODE 0
//generated via stb_voxel_render.h stbvox_get_vertex_shader() using the following #defines:
//
//#define STBVOX_CONFIG_MODE 0
//#define STBVOX_CONFIG_DISABLE_TEX2
//
#version 150
in uvec4 attr_face;
in uint attr_vertex;
uniform vec3 transform[3];
uniform vec4 camera_pos;
cmake_minimum_required(VERSION 3.17)
include(FetchContent)
project(GnomeTower
VERSION 0.0.1
DESCRIPTION "Lead your gnome civilization to the skies"
LANGUAGES CXX
)
#
@Phildo
Phildo / darray
Last active October 10, 2020 23:17
#pragma once
#include <initializer_list>
template<class T>
class DArray
{
public:
size_t size = 0;
@Phildo
Phildo / repro.cpp
Created February 2, 2022 18:57
pass by value bug in msvc
//this repro mangles the value of v.y in the pass_and_log function
//prints 0.20000 0.00000
//should print 0.20000 0.10000
//compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30139 for x64 (VS 2019 latest as of 2/1/22)
//compile command: cl /O2 /Ob1 repro.cpp
#include <cstdio>
struct vec2 { float x; float y; };