Skip to content

Instantly share code, notes, and snippets.

View gpakosz's full-sized avatar

Grégory Pakosz gpakosz

View GitHub Profile
@gpakosz
gpakosz / NVIDIA-GeForce-GT-750M.txt
Created February 17, 2017 08:55
RealtchVR OpenGL Extension Viewer report for NVIDIA GeForce GT 750M (Late 2013 MacBook Pro)
Renderer: NVIDIA GeForce GT 750M OpenGL Engine
Vendor: NVIDIA Corporation
Memory: 2048 MB
Version: 4.1 NVIDIA-10.10.14 310.42.25f02
Device: MacBookPro11,3
Shading language version: 4.10
Max texture size: 16384 x 16384
Max vertex texture image units: 16
@gpakosz
gpakosz / main.cpp
Created March 7, 2017 12:55
uint64_t getChronometerTime() in ms
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
LARGE_INTEGER frequency; // init with QueryPerformanceFrequency(&frequency) e.g. at beginning of main()
#endif // or go wild and put that in the constructor of a dedicated static object
#ifndef _WIN32
#if defined (CLOCK_MONOTONIC)
#include <time.h>
#else
@gpakosz
gpakosz / main.c
Created October 27, 2017 22:17
memcmp() and sizeof()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdbool.h>
struct Foo
{
int i;
@gpakosz
gpakosz / ln.sh
Created February 22, 2018 09:35
A shell ln() function that defers to mklink on Windows
case $(uname -s) in
*MINGW*)
ln() {
options="$1"
target="$2"
link="$3"
if ! [ -L "$link" ] && [ -d "$link" ]; then
link="$link/$(basename "$target")"
fi
@gpakosz
gpakosz / rand.c
Created November 8, 2018 12:30
PCG32 based floating point random number generation
/**
* Generates a pseudorandom number, in the [0, 1[ interval.
* @param rng Pointer to the pseudorandom number generator.
*/
static inline float rand_f(pcg32_random_t* rng)
{
const uint32_t max = 1 << 24;
uint32_t r = pcg32_random_r(rng);
r &= max - 1;
return r * 1.0f / max;