Skip to content

Instantly share code, notes, and snippets.

View finlaybob's full-sized avatar

Neil Finlay finlaybob

  • Edinburgh, Scotland
View GitHub Profile
@finlaybob
finlaybob / FuctionPointers.cpp
Last active October 8, 2015 01:48
My code from learning about function pointers.
#include <map>
#include <iostream>
#include <string>
using namespace std;
typedef void (*FuncPtr)(string,string);
typedef std::map<std::string, FuncPtr> FuncPtrMap;
void abFunc(string a,string b){
@finlaybob
finlaybob / main.cpp
Created August 5, 2012 11:50
std::function<> and lambdas
#include <map>
#include <functional>
#include <string>
#include <iostream>
using namespace std;
function<void(string,string)> func;
void actualABFunc(string a, string b){
@finlaybob
finlaybob / Shifters.hpp
Created August 11, 2012 17:55
Shifters. Because I hate the word "tween"
#pragma once
#ifndef SHIFTERS_H
#define SHIFTERS_H
/**
* This work is licensed under a Creative Commons,
* Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* You may copy, tweak, and build upon this work non-commercially
* as long as 1. The author is credited and 2. You license the modified
#pragma once
#ifndef SHIFTERS_H
#define SHIFTERS_H
/**
* This work is licensed under a Creative Commons,
* Attribution-NonCommercial-ShareAlike 3.0 Unported License.
* http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* You may copy, tweak, and build upon this work non-commercially
* as long as 1. The author is credited and 2. You license the modified
@finlaybob
finlaybob / UIWindow.cpp
Created August 29, 2012 14:12
SDL_ttf with OpenGL 3.3
#include "UIWindow.h"
UIWindow::UIWindow(int x, int y, int width, int height,string fontName):
x(x),y(y),height(height),width(width)//,titleFontName(fontName)
{
this->myType = Utils::UI_WINDOW;
//build window
@finlaybob
finlaybob / gist:4090330
Created November 16, 2012 19:52
Timing code
auto t1 = Clock::now();
app->update(0);
app->display();
auto t2 = Clock::now();
auto tt = (t2-t1);
elapsed = (float)tt.count()/1000000.0f;
app->fpsUpdate(elapsed);
/////////////////////////////////////////////////////////////////////////////////////////
// OpenGL4 Vertex Shader
#version 400
layout (location = 0) in vec3 a_pos;
layout (location = 1) in vec3 a_nor;
layout (location = 2) in vec3 a_uvs;
layout (location = 3) in vec3 a_tan;
layout (location = 4) in vec3 a_bin;
uniform mat4 Projection;
@finlaybob
finlaybob / normalmap.vert
Created March 10, 2013 00:36
Normal Map Vertex Shader
#version 400
layout (location = 0) in vec3 attribPosition;
layout (location = 1) in vec3 attribNormal;
layout (location = 2) in vec2 attribTexCoord;
layout (location = 3) in vec3 attribTangent;
layout (location = 3) in vec3 attribBinormal;
uniform mat4 mvp;
uniform mat4 mvm;
uniform mat3 nm;
@finlaybob
finlaybob / normalmap.frag
Created March 10, 2013 00:37
Normal Map Fragment Shader
#version 400
layout( location = 0 ) out vec4 frag_main;
struct PointLight{
vec3 position;
vec3 ambient;
vec3 diffuse;
vec3 specular;
float shininess;
float intensity;
};
@finlaybob
finlaybob / teapot.h
Created March 19, 2015 20:16
teapot mesh
struct TeapotPatch
{
bool mirrorZ;
int indices[16];
};
// Static data array defines the bezier patches that make up the teapot.
const TeapotPatch TeapotPatches[] =
{