Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View EddyLuten's full-sized avatar

Eddy Luten EddyLuten

View GitHub Profile
@EddyLuten
EddyLuten / NaturalTimeSpan.py
Created December 13, 2013 22:18
Little helper used to parse a natural time string such as "7 seconds" and convert the textual representation into seconds. This could be reduced into a single function, but this is how it was originally used.
import re
class NaturalTimeSpan:
time = 0
def __init__(self, time_string):
BAD_STRING = 'Unsupported format string provided: %s'
matches = re.search('^(?P<quantity>\d+)\s+(?P<format>second|minute|hour|day|week|year)s?$', time_string)
if not matches:
@EddyLuten
EddyLuten / chapter.1.1.c
Last active August 29, 2015 14:00
Chapter 1, Snippet 1 - OpenGLBook.com
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
#define WINDOW_TITLE_PREFIX "Chapter 1"
int
CurrentWidth = 800,
CurrentHeight = 600,
@EddyLuten
EddyLuten / chapter.1.2.c
Last active August 29, 2015 14:00
Chapter 1, Snippet 2 - OpenGLBook.com
void Initialize(int argc, char* argv[])
{
GLenum GlewInitResult;
InitWindow(argc, argv);
GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult) {
fprintf(
@EddyLuten
EddyLuten / chapter.1.3.c
Last active August 29, 2015 14:00
Chapter 1, Snippet 3 - OpenGLBook.com
int
CurrentWidth = 800,
CurrentHeight = 600,
WindowHandle = 0;
unsigned FrameCount = 0;
@EddyLuten
EddyLuten / chapter.1.4.c
Created April 21, 2014 02:27
Chapter 1, Snippet 4 - OpenGLBook.com
void Initialize(int, char*[]);
void InitWindow(int, char*[]);
void ResizeFunction(int, int);
void RenderFunction(void);
void TimerFunction(int);
void IdleFunction(void);
@EddyLuten
EddyLuten / chapter.1.5.c
Created April 21, 2014 02:30
Chapter 1, Snippet 5 - OpenGLBook.com
glutReshapeFunc(ResizeFunction);
glutDisplayFunc(RenderFunction);
glutIdleFunc(IdleFunction);
glutTimerFunc(0, TimerFunction, 0);
@EddyLuten
EddyLuten / chapter.1.6.c
Created April 21, 2014 05:14
Chapter 1, Snippet 6 - OpenGLBook.com
++FrameCount;
@EddyLuten
EddyLuten / chapter.1.7.c
Created April 21, 2014 05:15
Chapter 1, Snippet 7 - OpenGLBook.com
void IdleFunction(void)
{
glutPostRedisplay();
}
void TimerFunction(int Value)
{
if (0 != Value) {
char* TempString = (char*)
malloc(512 + strlen(WINDOW_TITLE_PREFIX));
@EddyLuten
EddyLuten / chapter.2.1.c
Created April 21, 2014 06:10
Chapter 2, Snippet 1 - OpenGLBook.com
GLuint
VertexShaderId,
FragmentShaderId,
ProgramId,
VaoId,
VboId,
ColorBufferId;
@EddyLuten
EddyLuten / chapter.2.2.c
Last active August 29, 2015 14:00
Chapter 2, Snippet 2 - OpenGLBook.com
const GLchar* VertexShader =
{
"#version 400\n"\
"layout(location=0) in vec4 in_Position;\n"\
"layout(location=1) in vec4 in_Color;\n"\
"out vec4 ex_Color;\n"\
"void main(void)\n"\
"{\n"\