Skip to content

Instantly share code, notes, and snippets.

View mortennobel's full-sized avatar

Morten Nobel-Jørgensen mortennobel

View GitHub Profile
@mortennobel
mortennobel / ascii-2d.cpp
Last active August 29, 2015 13:56
ASCII visualization (used for debugging 2d scalar fields)
#include <string>
#include <array>
#include <algorithm>
#include <functional>
using namespace std;
// assumes that values returned by data is normalized between 0.0 and 1.0
string get_grayscale_image(int width, int height, function<float(int,int)> data){
const int size = 10;
@mortennobel
mortennobel / floatingpoint.h
Last active August 29, 2015 14:00
almostEqualFloatingpoint
// from https://code.google.com/p/googletest/source/browse/trunk/include/gtest/internal/gtest-internal.h
#pragma once
#include <ctype.h>
#include <float.h>
#include <string.h>
#include <iomanip>
#include <limits>
#include <set>
@mortennobel
mortennobel / ObjFile.cpp
Last active August 29, 2015 14:01
Simple Obj File Loader
//
// Created by Morten Nobel-Jørgensen on 06/05/14.
// Copyright (c) 2014 Morten Nobel-Joergensen. All rights reserved.
//
#include "ObjFile.h"
#include <fstream>
#include <sstream>
@mortennobel
mortennobel / sdl.cpp
Created May 13, 2014 15:41
OS/X SDL2 Test
#include <stdio.h>
#include <stdlib.h>
/* If using gl3.h */
/* Ensure we are using opengl's core profile only */
#define GL3_PROTOTYPES 1
#include <OpenGL/gl3.h>
#include <iostream>
#include <SDL2/SDL.h>
@mortennobel
mortennobel / MCSpacePartition.cs
Created May 21, 2014 08:58
Simple space partition algorithm which stores two Z planes and swaps between these two planes
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Simple space partition algorithm which stores two Z planes and swaps between these two planes
/// </summary>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TRIANGLE {
public Vector3[] p = {Vector3.zero,Vector3.zero,Vector3.zero};
}
public class GRIDCELL {
public Vector3[] p = {Vector3.zero,Vector3.zero,Vector3.zero,Vector3.zero,Vector3.zero,Vector3.zero,Vector3.zero,Vector3.zero};
@mortennobel
mortennobel / main.cpp
Created July 31, 2014 14:50
deprecated
Based on http://stackoverflow.com/a/21265197/420250
#ifdef __GNUC__
#define DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED
#endif
@mortennobel
mortennobel / main.cpp
Created November 6, 2014 22:36
Hello Modern OpenGL World (OSX, OGL3.2, GLUT, C++11)
//
// Single file OpenGL example
//
// Created by Morten Nobel-Jørgensen on 06/11/14.
// Copyright (c) 2014 morten. All rights reserved.
//
#include <OpenGL/gl3.h>
#include <GLUT/glut.h>
#include <string>
// Example program:
// Using SDL2 to create an application window
#include "SDL.h"
#include <iostream>
#include <ostream>
#include "SDL_opengl.h"
int main(int argc, char* argv[]) {
//
// PerformanceTool.h
//
// Created by Morten Nobel-Jørgensen on 1/23/13.
// Copyright (c) 2013 Morten Nobel-Joergensen. All rights reserved.
//
// Create simple performance meassures in ms
//
// Usage:
//