Skip to content

Instantly share code, notes, and snippets.

View madebyjeffrey's full-sized avatar

Jeffrey Drake madebyjeffrey

View GitHub Profile
#include "Shader.h"
using namespace std;
Shader::Shader() : program(0), shaders(vector<GLuint>())
{
// do not create program here, because it will be initialized before gl context
// program = glCreateProgram();
}
layout(location = 0) in vec4 position;
uniform mat4 viewportTranslation;
uniform mat4 projectionMatrix;
void main()
{
vec4 p2;
In file included from /Users/drakej/Projects/Spider-Fish/glfw-src/Spider-Fish/main.cpp:11:
/Users/drakej/Projects/Spider-Fish/glfw-src/Spider-Fish/SpiderFish.h:40:21: error: implicit instantiation of undefined template 'std::__1::array<float, 4>' [3]
array<float, 4> viewport;
^
/Developer/usr/bin/../lib/c++/v1/__tuple:66:59: note: template is declared here [3]
template <class _Tp, size_t _Size> struct _LIBCPP_VISIBLE array;
template <typename T>
struct tvec4
{
enum ctor{null};
typedef T value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type value_size();
@madebyjeffrey
madebyjeffrey / gist:1249924
Created September 29, 2011 03:42
Error reading in function file
function [x, y] = graph (varargin)
list = varargin{1};
for i = 2:length(varargin)
cat(1, list, varargin{i});
endfor
x = list(1:rows(list), 1);
y = list(1:rows(list), 2);
x = cat(1, x, x(1));
y = cat(1, y, y(1));
@madebyjeffrey
madebyjeffrey / particles.f03
Created September 14, 2011 02:40
Particle Simulation
program particles
! ten particles in a field of 10000 x 10000
! base velocity is 10 x 10
integer, parameter :: p = 10, &
fx = 10000, fy = 10000, &
bx = 10, by = 10, &
steps = 10000
real, parameter :: radius = 5
subroutine step(positions, velocities)
real, dimension(p,2), intent(inout) :: positions, velocities
! verify lengths (? unnecessary?)
if (size(positions, 1) .ne. size(velocities, 1)) then
print *, "The sizes of two arrays are not the same"
end if
! move the particles to the new position
do i = 1, size(positions, 1)
@madebyjeffrey
madebyjeffrey / zzing
Created August 1, 2011 00:09
math.clamp
function math.clamp(v, min, max)
if v > max then
return max
elseif v < min then
return min
else
return v
end
end
require("string")
state = {}
function love.load()
state.size = { cx = love.graphics.getWidth(), cy = love.graphics.getHeight() }
-- ball is a position, a mass, and a velocity
state.ball = { position = { x = state.size.cx / 2, y = state.size.cy / 2 },
mass = 50,
@madebyjeffrey
madebyjeffrey / gist:1064261
Created July 5, 2011 04:48
Intrinsic Neon functions
float inputX[4] = { 2, 4, 8, 16 };
float inputY[4] = { 2, 4, 8, 16 };
float resultZ[4] = { 0, 0, 0, 0 };
float32x4_t sample1, sample2, result;
sample1 = vld1q_f32(inputX);
sample2 = vld1q_f32(inputY);
result = vmulq_f32(sample1, sample2);