Skip to content

Instantly share code, notes, and snippets.

Avatar

Morten Nobel-Jørgensen mortennobel

View GitHub Profile
@mortennobel
mortennobel / ascii-2d.cpp
Last active Aug 29, 2015
ASCII visualization (used for debugging 2d scalar fields)
View ascii-2d.cpp
#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 Aug 29, 2015
almostEqualFloatingpoint
View floatingpoint.h
// 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 Aug 29, 2015
Simple Obj File Loader
View ObjFile.cpp
//
// 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
OS/X SDL2 Test
View sdl.cpp
#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
Simple space partition algorithm which stores two Z planes and swaps between these two planes
View MCSpacePartition.cs
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>
View MarchingCubes.cs
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};
View main.cpp
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 Nov 6, 2014
Hello Modern OpenGL World (OSX, OGL3.2, GLUT, C++11)
View main.cpp
//
// 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>
View sdl2-biicode.cpp
// 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[]) {
View PerformanceTool.h
//
// 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:
//