Skip to content

Instantly share code, notes, and snippets.

View phmongeau's full-sized avatar
🤖

Philippe Mongeau phmongeau

🤖
View GitHub Profile
@mmozeiko
mmozeiko / pcg32.h
Last active February 5, 2024 10:46
simple standalone C headers for PCG random number generator
#pragma once
#include <stdint.h>
#define PCG_DEFAULT_MULTIPLIER_64 6364136223846793005ULL
#define PCG_DEFAULT_INCREMENT_64 1442695040888963407ULL
typedef struct {
uint64_t state;
} pcg32;
@mmozeiko
mmozeiko / x11_opengl.c
Last active July 19, 2023 06:02
setting up and using modern OpenGL 4.5 core context on X11 with EGL
// example how to set up OpenGL core context on X11 with EGL
// and use basic functionality of OpenGL 4.5 version
// to compile on Ubuntu first install following packages: build-essential libx11-dev libgl-dev libegl-dev, then run:
// gcc x11_opengl.c -o x11_opengl -lm -lX11 -lEGL
// important extension functionality used here:
// (4.3) KHR_debug: https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt
// (4.5) ARB_direct_state_access: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_direct_state_access.txt
// (4.1) ARB_separate_shader_objects: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_separate_shader_objects.txt

Multi-dimensional array views for systems programmers

As C programmers, most of us think of pointer arithmetic for multi-dimensional arrays in a nested way:

The address for a 1-dimensional array is base + x. The address for a 2-dimensional array is base + x + y*x_size for row-major layout and base + y + x*y_size for column-major layout. The address for a 3-dimensional array is base + x + (y + z*y_size)*x_size for row-column-major layout. And so on.

@phmongeau
phmongeau / ik_fk_snap.mel
Created April 21, 2013 04:14
IK_FK snap
float $arm1RX = `getAttr JT_L_ikArm_1.rx`;
float $arm1RY = `getAttr JT_L_ikArm_1.ry`;
float $arm1RZ = `getAttr JT_L_ikArm_1.rz`;
setAttr JT_L_fkArm_1.rx $arm1RX;
setAttr JT_L_fkArm_1.ry $arm1RY;
setAttr JT_L_fkArm_1.rz $arm1RZ;
@phmongeau
phmongeau / EX_L_footRoll
Last active December 16, 2015 11:29
foot roll maya expression
if(RG_L_footIcon_1.ballX < 0) {
JT_L_heelCtrl_1.rotateX = RG_L_footIcon_1.ballX;
JT_L_toesTipCtrl_1.rotateX = 0;
}
else if (RG_L_footIcon_1.ballX < 50) {
JT_L_heelCtrl_1.rotateX = 0;
JT_L_toesTipCtrl_1.rotateX = 0;
JT_L_ballCtrl_1.rotateX = 1 - RG_L_footIcon_1.ballX;
}
else {
@alols
alols / softwrapcmd.vim
Created December 1, 2011 21:38
SoftWrap vim command
" Turn hard wrapped text into soft wrapped.
" This command will join all lines within a range that are not separated
" by empty lines. Automatic word wrap must be off (set fo-=a).
" Useful if you need to copy and paste into a word processor.
command! -range=% SoftWrap
\ <line2>put _ |
\ <line1>,<line2>g/.\+/ .;-/^$/ join |normal $x