Skip to content

Instantly share code, notes, and snippets.

View Robadob's full-sized avatar

Robert Chisholm Robadob

View GitHub Profile
\usepackage{titling}
\newcommand{\subtitle}[1]{%
\posttitle{%
\par\end{center}
\begin{center}\Large#1\end{center}
\vskip0.5em}%
}
@Robadob
Robadob / flat.frag
Last active March 13, 2016 16:50
Simple flat shading pair
#version 120
varying vec3 u_normal;
void main()
{
//Calculate face normal
vec3 N = normalize(cross(dFdx(u_normal), dFdy(u_normal)));//Face Normal
//This sets the Light source to be the camera
vec3 L = normalize(vec3(0,0,0)-u_normal);
vec3 diffuse = gl_Color.xyz * max(dot(L, N), 0.0);
@Robadob
Robadob / README.cpp
Created March 13, 2016 20:47
OpenGL bug?
//1. Create a shader program with the below frag and vertex shaders
//2. Call the below method passing "_projectionMat" as the uniformName (and the shaderPrograms ID)
//3. glGetUniformLocation() correctly identifies the location as 2
//4. glGetActiveUniform() incorrectly identifies the type as GL_SAMPLER_CUBE, instead of GL_FLOAT_MAT4
//5. Removing the explicit uniform locations from the vertex shader fixes this, therefore is layout(location for a uniform undefined behaviour, or is this a bug?
std::pair<int, GLenum> findUniform(const char *uniformName, int shaderProgram)
{
int result = GL_CALL(glGetUniformLocation(shaderProgram, uniformName));
if (result > -1)
#ifdef _DEBUG //VS standard debug flag
inline static void HandleGLError(const char *file, int line) {
GLuint error = glGetError();
if (error != GL_NO_ERROR)
{
printf("%s(%i) GL Error Occurred;\n%s\n", file, line, gluErrorString(error));
#if EXIT_ON_ERROR
getchar();
exit(1);
@Robadob
Robadob / Camera.cpp
Last active September 14, 2016 14:05
No Clip Style camera controller
#include "Camera.h"
#include <glm/gtx/rotate_vector.hpp>
/*
Initialises the camera located at (1,1,1) directed at (0,0,0)
*/
Camera::Camera()
: Camera(glm::vec3(1, 1, 1))
{}
@Robadob
Robadob / Instanced_Rot3D_Up.vert
Last active October 19, 2016 09:55
3D Rotation inside a vertex shader, where the models remains upright
#version 430
//gl_InstanceID //attribute in uint agent_index;
in vec3 _vertex;
out vec3 u_normal;
uniform mat4 _modelViewMat;
uniform mat4 _projectionMat;
uniform samplerBuffer _texBuf; //Position
rd build /s /q
#ifndef __header_cuh_
#define __header_cuh_
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
//Cuda call
inline void HandleCUDAError(const char *file,
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
//#include <cuda_gl_interop.h>
#include "FLAMEGPU.h"
#include <cstdio>
#include "header.h"
//#include "visualisation/GlobalsController.h"
#include "navigationhost.h"
@Robadob
Robadob / lsfm.js
Last active September 21, 2017 14:33
Last FM Scrobble Purge - Deletes all scrobbles from a page of https://www.last.fm/user/<username>/library?page=1
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},sl