Skip to content

Instantly share code, notes, and snippets.

Avatar

Morten Nobel-Jørgensen mortennobel

View GitHub Profile
@mortennobel
mortennobel / SingleFileOpenGLTex.cpp
Last active Jun 8, 2022
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
//
View drand48.c
#define RAND48_SEED_0 (0x330e)
#define RAND48_SEED_1 (0xabcd)
#define RAND48_SEED_2 (0x1234)
#define RAND48_MULT_0 (0xe66d)
#define RAND48_MULT_1 (0xdeec)
#define RAND48_MULT_2 (0x0005)
#define RAND48_ADD (0x000b)
unsigned short _rand48_seed[3] = {
@mortennobel
mortennobel / libPNGOpenGL.cpp
Last active Apr 29, 2020
Updated to libpng 1.5.15
View libPNGOpenGL.cpp
#ifdef _WIN32
#include <GL/glut.h>
#else
#include <GLUT/glut.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <png.h>
#include <iostream>
View Installing PETSc on OSX Yosemite.md
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 / AsciiArtGenerator
Created Nov 6, 2011
Create image with ASCII chars ordered by intensity
View AsciiArtGenerator
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.*;
/**
* Create an ASCII letters sorted by intensity. By including the inverse letters
* the number of combinations are increased.
*
@mortennobel
mortennobel / GLError.cpp
Last active Sep 27, 2018
Simple error check of open gl (write readable error description to cerr stream including file name and line number)
View GLError.cpp
#include "GLError.h"
#include <iostream>
#include <string>
#ifdef WIN32
# include <GL/glew.h>
#elif __APPLE__
# include <OpenGL/gl3.h>
#else
# include <GL3/gl3.h>
@mortennobel
mortennobel / Event.h
Last active Jul 3, 2018
C++11 Observer Version 2
View Event.h
//
// Event.h
//
// Created by Morten Nobel-Jørgensen on 8/18/13.
// Copyright (c) 2013 morten. All rights reserved.
// Open Source under New BSD License (http://opensource.org/licenses/BSD-3-Clause)
#pragma once
#include <iostream>
@mortennobel
mortennobel / SetPngTransparentColorGUI.java
Created Oct 14, 2012
Replace pixels with full transparency with a certain color to fix issues with resampling images
View SetPngTransparentColorGUI.java
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@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"