Skip to content

Instantly share code, notes, and snippets.

EXT_INSTANCE_ARRAY_MATRIX

Introduces the "arrayMatrix" instance subtype.

Parameters:

Name Type Description
group GROUP Group to be instanced, required
array.transform ARRAY1D of FLOAT32_MAT4 Array of transforms, required
array.id ARRAY1D of UINT32 optional array of ids
#ifndef MATH_UTIL_H
#define MATH_UTIL_H
#include <math.h>
#include <float.h>
static const float PI = 3.14159265358979323846f;
static inline float dot3(const float *a, const float *b) {
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
/* OpenGL example code - Compute Shader N-body
*
* N-body simulation with compute shaders.
*
* Autor: Jakob Progsch
*/
#include <GLXW/glxw.h>
#include <GLFW/glfw3.h>
#ifndef FIXED_H
#define FIXED_H
typedef int64_t fixed_t;
static const fixed_t fixed_precision = 20ll;
static const fixed_t fixed_one = 1ll<<fixed_precision;
static const fixed_t fixed_half = 1ll<<(fixed_precision-1);
static const double fixed_factor = fixed_one;
static const double fixed_inverse_factor = 1.0/fixed_factor;
#include "glterm.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <png.h>
#include "glterm.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <png.h>
@progschj
progschj / instruction_table.h
Created January 20, 2014 10:19
WiP x64 instruction encoding
typedef enum mnemonic_enum_t {
UNKNOWN=0,
ADC=1,
ADD,
AND,
BSF,
BSR,
BSWAP,
BT,
BTC,
@progschj
progschj / hash_map2d.c
Created December 25, 2013 22:45
A 2d Hash map
#include "hash_map2d.h"
#include <stdlib.h>
static unsigned hash_map2d_hash(int x, int y) {
unsigned h = 65521u*x + 101u*y;
return h;
}
static hash_map2d_entry* hash_map2d_alloc(int capacity) {
@progschj
progschj / pngraymarcher.cpp
Created November 21, 2013 20:29
I was supposed to write a png writing function for our students to output grid data from a diffusion simulation. This is the example code to go along with it... (it's a raymarcher with antialiasing and reflections).
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
int write_png(const char *file_name, int width, int height, unsigned char *data) {
@progschj
progschj / kepler.cpp
Created October 21, 2013 15:00
Some code to calculate closed form Kepler orbits and comparing the solution of a numerical integrator.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <utility>
#include <glm/glm.hpp>
const double G = 6.674e-11; // gravitational constant
const double PI = 3.14159265358979323846;