Skip to content

Instantly share code, notes, and snippets.

View adventureloop's full-sized avatar

Tom Jones adventureloop

View GitHub Profile
@adventureloop
adventureloop / gist:2267501
Created March 31, 2012 18:49
Block types header
#ifndef Cubeworld_BlockTypes_h
#define Cubeworld_BlockTypes_h
enum BLOCK_TYPES
{
BLOCK_AIR,
BLOCK_SOLID,
BLOCK_GRASS,
BLOCK_DIRT,
BLOCK_WATER,
@adventureloop
adventureloop / gist:3436682
Created August 23, 2012 13:38
Collision Detection
public boolean collidesWithPoint(int x,int y)
{
if(x < this.x || x > this.x + width)
return false;
if(y < this.y || y > this.y + height)
return false;
return true;
}
66 ctx.clearRect(0,0,640,400);
67
68 ctx.save();
69
70 var tmpPos = programmer.position;
71 ctx.translate(tmpPos.x,tmpPos.y);
72 programmer.draw();
73
74 ctx.restore();
75
typedef struct
{
position v;
colour c;
normal n;
textureCoord t;
} vertex;
glVertexAttribPointer(0,4,GL_FLOAT,GL_FALSE,
sizeof(vertex),
#version 330
in vec4 position;
in vec4 color;
in vec3 normal;
in vec2 textureCoord;
out vec4 outColor;
uniform mat4 perspectiveMatrix;
function love.draw()
love.graphics.clear()
love.graphics.reset()
love.graphics.setColor(255,0,0);
love.graphics.print('Hello world',200,200)
love.graphics.translate(150,210);
drawStuff()
local framebuffer1 = love.graphics.newCanvas();
local framebuffer2 = love.graphics.newCanvas();
local framebuffer3 = love.graphics.newCanvas();
local pos = {x = 20,y = 20}
local drawLines = true
local effect = fishEye
local barrel
local blur
#include <iostream>
#include <SOIL/SOIL.h>
using namespace std;
int
main(int argc,char **argv)
{
cout << "SOIL Demo" << endl;
#define GLFW_INCLUDE_GL3
#include <GL/glfw.h>
#include <SOIL/SOIL.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int
void Texture::flipImageData(unsigned char *data,int width,int height)
{
int x,y;
int size = (width * height)-1; //Indices start at 0
width = (width < 0) ? 0 : width;
height = (height < 0) ? 0 : height;
cout << "Image width: " << width << " height: " << height << endl;
for(y = 0; y < height/2;y++) {
cout << "y: " << y << " height - y " << height - y << endl;