Skip to content

Instantly share code, notes, and snippets.

View hamsham's full-sized avatar

Miles Lacey hamsham

View GitHub Profile
@stuartjmoore
stuartjmoore / gist:1076642
Created July 11, 2011 19:46
Render Sphere in OpenGL ES for iOS, converted from http://www.codesampler.com/oglsrc/oglsrc_9.htm
void renderSphere(float cx, float cy, float cz, float r, int p)
{
float theta1 = 0.0, theta2 = 0.0, theta3 = 0.0;
float ex = 0.0f, ey = 0.0f, ez = 0.0f;
float px = 0.0f, py = 0.0f, pz = 0.0f;
GLfloat vertices[p*6+6], normals[p*6+6], texCoords[p*4+4];
if( r < 0 )
r = -r;
@hi2p-perim
hi2p-perim / ssecheck.cpp
Last active June 16, 2024 06:55
Check SSE/AVX instruction support.
/*
Check SSE/AVX support.
This application can detect the instruction support of
SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, SSE5, and AVX.
*/
#include <iostream>
#ifdef _MSC_VER
#include <intrin.h>
#endif
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active July 15, 2024 12:10
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@XProger
XProger / powf_fast.c
Last active January 10, 2024 19:33
fast powf function (IEEE-754 hack)
float powf_fast(float a, float b) {
union { float d; int x; } u = { a };
u.x = (int)(b * (u.x - 1064866805) + 1064866805);
return u.d;
}
@Reedbeta
Reedbeta / cool-game-programming-blogs.opml
Last active May 5, 2024 18:07
List of cool blogs on game programming, graphics, theoretical physics, and other random stuff
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Graphics, Games, Programming, and Physics Blogs</title>
</head>
<body>
<outline text="Tech News" title="Tech News">
<outline type="rss" text="Ars Technica" title="Ars Technica" xmlUrl="http://feeds.arstechnica.com/arstechnica/index/" htmlUrl="https://arstechnica.com"/>
<outline type="rss" text="Polygon - Full" title="Polygon - Full" xmlUrl="http://www.polygon.com/rss/index.xml" htmlUrl="https://www.polygon.com/"/>
<outline type="rss" text="Road to VR" title="Road to VR" xmlUrl="http://www.roadtovr.com/feed" htmlUrl="https://www.roadtovr.com"/>
@velipso
velipso / faster_atan2.c
Last active March 25, 2024 12:50
Faster atan2 algorithm (worse accuracy)
// public domain
//
// algorithm adopted from:
// https://dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization/
//
// when ran without arguments, it simply calculates the maximum error between
// the functions below and atan2f
//
// it tests all (x,y) values from -100.00 to +100.00
//
@XProger
XProger / quat_quat2.cpp
Created August 22, 2017 20:26
quaternions and dual-quaternions
// quat
const quat quat::IDENTITY(0.0f, 0.0f, 0.0f, 1.0f);
const quat quat::ZERO(0.0f, 0.0f, 0.0f, 0.0f);
quat::quat() {}
quat::quat(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
quat::quat(const vec3 &axis, float angle) {
angle *= 0.5f;
float s = sinf(angle);
@rizalp
rizalp / disable_spectre.md
Last active May 22, 2023 22:07
Disable Spectre/Meltdown Mitigation

In /etc/default/grub, modify:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off tsx=on tsx_async_abort=off mitigations=off"

Then sudo update-grub