Skip to content

Instantly share code, notes, and snippets.

View pr0g's full-sized avatar

Tom Hulton-Harrop pr0g

View GitHub Profile
@pr0g
pr0g / 1brc.cpp
Last active January 14, 2024 18:15
#include <marl/defer.h>
#include <marl/event.h>
#include <marl/scheduler.h>
#include <marl/waitgroup.h>
#include <algorithm>
#include <charconv>
#include <fstream>
#include <iostream>
#include <map>
@pr0g
pr0g / ImprovedCamera.hpp
Last active September 26, 2021 15:03
Free look and custom pivot orbit camera implementation
#include <as/as-math-ops.hpp> // https://github.com/pr0g/as
struct Camera
{
as::vec3 pivot = as::vec3::zero(); // pivot point to rotate about
as::vec3 offset = as::vec3::zero(); // offset relative to pivot
float yaw = 0.0f; // yaw rotation in radians
float pitch = 0.0f; // pitch rotation in radians
// view camera transform (v in MVP)
@pr0g
pr0g / CMakeLists.txt
Created July 13, 2020 15:50
C++ constexpr experiments
cmake_minimum_required(VERSION 3.15)
project(constexpr LANGUAGES CXX)
add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
// Derived from this Gist by Richard Gale:
// https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
// ImGui BFFX binding
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture
// identifier. Read the FAQ about ImTextureID in imgui.cpp.
// You can copy and use unmodified imgui_impl_* files in your project. See
// main.cpp for an example of using this. If you use this binding you'll need to
// call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(),
use std::collections::HashMap;
use std::fs;
#[derive(Debug)]
struct Quantity {
element: String,
count: i64,
}
#[derive(Debug)]
@pr0g
pr0g / Camera.hpp
Last active April 13, 2020 14:48
Simple FPS Camera
// glm
struct Camera
{
glm::vec3 position { 0.0f };
float yaw { 0.0f };
float pitch { 0.0f };
// pass this to the shader (the 'v' in the mvp multiplication)
glm::mat4 view() const
{