Skip to content

Instantly share code, notes, and snippets.

Morten Nobel-Jørgensen mortennobel

Block or report user

Report or block mortennobel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View opengl-profile.cpp
#include <chrono>
#include <iostream>
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#ifdef _WIN32
#include <windows.h>
#endif
@mortennobel
mortennobel / BussIKMain.cpp
Created Mar 20, 2018
BussIK using SimpleRenderEngine
View BussIKMain.cpp
// Naive port of https://github.com/CreativeInquiry/ofxBussIK
#include <iostream>
#include "sre/Texture.hpp"
#include "sre/Renderer.hpp"
#include "sre/Material.hpp"
#include "LinearR3.h"
#include "Tree.h"
#include "Jacobian.h"
View Data oriented shared_ptr
#include <iostream>
#include <string>
#include <memory>
struct String {
std::string s;
String(std::string s)
:s(s) {
std::cout << "Constructor " << s << std::endl;
}
View fix
while (running){
frame(deltaTime);
auto tick = Clock::now();
deltaTime = std::chrono::duration_cast<FpSeconds>(tick - lastTick).count();
// todo fix busy wait
// https://forum.lazarus.freepascal.org/index.php?topic=35689.0
while (deltaTime < timePerFrame){
SDL_Delay((Uint32) ((timePerFrame - deltaTime) / 1000));
tick = Clock::now();
deltaTime = std::chrono::duration_cast<FpSeconds>(tick - lastTick).count();
@mortennobel
mortennobel / SingleFileOpenGLTex.cpp
Last active Aug 13, 2019
Single file OpenGL 3.3 / WebGL (using Emscripten) example with texture (SDL2 / SDL_Image 2)
View SingleFileOpenGLTex.cpp
//
// Compile for emscripten using
// emcc -Iinclude SingleFileOpenGLTex.cpp \
-O2 -std=c++14 -s TOTAL_MEMORY=33554432 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' --preload-file examples/data -s USE_SDL=2 -o html/SingleFileOpenGLTex.html
// where the following images must be located in a subfolder
// - examples/data/test.png
// - examples/data/cartman.png
// - examples/data/cube-negx.png
// - examples/data/cube-negz.png
//
@mortennobel
mortennobel / geometryshader.cpp
Created Mar 14, 2017
Single file geometryshader
View geometryshader.cpp
#include "SDL.h"
// OSX only - change on other platforms
#include <OpenGL/gl3.h>
#include <stdlib.h> //rand()
#include <iostream>
#include <string>
static bool quitting = false;
static SDL_Window *window = NULL;
@mortennobel
mortennobel / Handle.cpp
Created Nov 21, 2016
EntitySystem using handles
View Handle.cpp
//
// Created by Morten Nobel-Jørgensen on 20/11/2016.
//
#include "Handle.hpp"
@mortennobel
mortennobel / SingleFileOpenGLExample.cpp
Last active Nov 7, 2016
OpenGL 3.x example in a single file (SDL2.x)
View SingleFileOpenGLExample.cpp
#include "SDL.h"
// OSX only - change on other platforms
#include <OpenGL/gl3.h>
#include <stdlib.h> //rand()
#include <iostream>
#include <string>
static bool quitting = false;
static SDL_Window *window = NULL;
View UnitySocketExample.cs
using UnityEngine;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
public class HelloSocketWorld : MonoBehaviour {
public string history;
public string txt;
@mortennobel
mortennobel / encode_image.sh
Created Apr 24, 2016
Encode png images as movie
View encode_image.sh
# Loosely based on http://superuser.com/a/533706
ffmpeg -framerate 10 -i shot\ %04d.png -s:v 1280x720 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p smart-avenue-1.mp4
You can’t perform that action at this time.