Skip to content

Instantly share code, notes, and snippets.

View ncannasse's full-sized avatar

Nicolas Cannasse ncannasse

View GitHub Profile
package h3d.anim;
class Joint {
public var index : Int;
public var name : String;
public var bindIndex : Int;
public var splitIndex : Int;
public var defMat : h3d.Matrix; // the default bone matrix
public var transPos : h3d.Matrix; // inverse pose matrix

Haxe FrontEnd

Reads haxelib-lock.json (if exists)

Reads <file> (if called with -lock-file <file>) which will partially override haxelib-lock.json

Takes arguments (hxml files or anything else)

Expand hxml files to their actual content

abstract MyArray<T>(#if java java.NativeArray<T> #else Array<T> #end) {
public inline function new(size:Int) {
#if java
this = new java.NativeArray(size);
#else
this = new Array();
if( size > 0 ) this[size-1] = cast null;
#end
}
abstract MyArray<T>(#if java java.NativeArray<T> #else Array<T> #end) {
public inline function new(size:Int) {
#if java
this = new java.NativeArray(size);
#else
this = new Array();
if( size > 0 ) this[size-1] = cast null;
#end
}
package domkit;
using StringTools;
enum abstract MToken(Int) {
var IGNORE_SPACES;
var BEGIN;
var BEGIN_NODE;
var BEGIN_CODE;
var CODE_IDENT;
# go to Northgard install dir
cd "~/Library/Application Support/Steam/SteamApps/common/Northgard/osx"
# fallback fo newest dir
cd "~/Library/Application Support/Steam/steamapps/common/Northgard/osx"
# remove shipped libraries which requires AVX CPU support
rm -rf libmbed* libogg* libvorbis* libopenal* libpng* libSDL* libturbojpeg*
# download and install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install required libraries
brew install libpng jpeg-turbo libvorbis sdl2 mbedtls openal-soft libuv
class NormalShader2D extends hxsl.Shader {
static var SRC = {
@:import h3d.shader.Base2d;
@param var normalMap : Sampler2d;
function fragment() {
var n = unpackNormal(normalMap.get(calculatedUV));
var light = vec3(1,2,3).normalize();
var lum = light.dot(n).saturate();
pixelColor.rgb *= lum;
}
package haxe;
/**
If haxe.MainLoop is kept from DCE, then we will insert an haxe.EntryPoint.run() call just at then end of main().
This class can be redefined by custom frameworks so they can handle their own main loop logic.
**/
class EntryPoint {
/**
Wakeup a sleeping run()
@ncannasse
ncannasse / MainLoop.hx
Created March 6, 2016 16:09
version 2, adds delay()
package haxe;
class MainEvent {
var f : Void -> Void;
var prev : MainEvent;
var next : MainEvent;
public var nextRun(default,null) : Float;
public var priority(default,null) : Int;
package haxe;
class MainEvent {
var f : Void -> Void;
var prev : MainEvent;
var next : MainEvent;
public var priority(default,null) : Int;
public function new(f,p) {