Skip to content

Instantly share code, notes, and snippets.

@StonedXander
StonedXander / shader.cpp
Created October 21, 2012 17:42
Shader support
#include <shader.hpp>
#include <iostream>
namespace Graphic {
Shader::Shader(const char *vs, const char *fs) {
vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShaderID, 1, &vs, NULL);
glCompileShader(vertexShaderID);
class CameraHandler {
public:
CameraHandler();
Handler<CameraHandler> *getArcballHandler();
void handleKey(Handler<CameraHandler> *, int, int);
void handleMouseButton(Handler<CameraHandler> *, int, int);
void handleMousePosition(Handler<CameraHandler> *, int, int);
void handleMouseWheel(Handler<CameraHandler> *, int);
@StonedXander
StonedXander / server.c
Created April 28, 2012 13:16
An attempt of crappy IM server
// Let's make a server, Posix Style !
#include <iostream>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
@StonedXander
StonedXander / Makefile
Created April 17, 2012 19:39
Some VBO Stuff
microengine.o: microengine.h microengine.c
g++ -c microengine.C -I. -I../common
main.o: microengine.h main.c
g++ -c main.c -I. -I../common
all: main.o microengine.o
g++ main.o microengine.o -lGL -lglfw -lm -lpthread -o speedcoding
@StonedXander
StonedXander / Makefile
Created March 15, 2012 14:08
GL Textured Font
font.o: font.h font.c
g++ -c font.c -I.
main.o: main.c font.h
g++ -c main.c -I.
all: main.o font.o
g++ main.o font.o -o speedcoding -lexpat -lglfw -lSOIL
@StonedXander
StonedXander / consumer.hpp
Created December 22, 2011 10:54
Simple Consumer
/**
* Consumer generic class.
* Delegates the following services:
* - evaluate : returns if the run method must be exited.
* - process : process the item buffer.
* - compute : compute the internal state.
* The 'target' concept must implement the method:
* bool swap(I **, unsigned *);
* and the constructor :
* T::T(K *);
@StonedXander
StonedXander / gist:1509901
Created December 22, 2011 10:52
Simple Thread class
/*
* thread.h
* by Stoned Xander (2011)
*/
#ifndef THREAD_H_
#define THREAD_H_
#ifdef WITH_PTHREAD
#include <pthread.h>
@StonedXander
StonedXander / gist:973262
Created May 15, 2011 15:57 — forked from BlockoS/gist:973257
Just a simple maze generator
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
typedef struct {
unsigned int x;
unsigned int y;
unsigned char direction;
} Coordinate;
@StonedXander
StonedXander / gist:972568
Created May 14, 2011 20:00
Priority Queue Solver
#define DEVEL_BUFFER_SIZE 128
/**
* Priority queue solver.
* <P> implements the concept of ordered list.
* <T> implements the concept of weighted solution.
* <E> is an environment object (should be reentrant).
*/
template <class P, class T, typename E> void solve(T**seeds,
int seedSize,