Skip to content

Instantly share code, notes, and snippets.

View demonixis's full-sized avatar

Yannick Comte demonixis

View GitHub Profile
@demonixis
demonixis / Babylon.Ejecta.js
Last active August 29, 2015 13:56
A wrapper to use Babylonjs with Ejecta on iOS
var useLegacyShader = false;
var ShaderResources = {
blurPixelShader:"#ifdef GL_ES\nprecision mediump float;\n#endif\n\n// Samplers\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\n// Parameters\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nvoid main(void)\n{\n float weights[7];\n weights[0] = 0.05;\n weights[1] = 0.1;\n weights[2] = 0.2;\n weights[3] = 0.3;\n weights[4] = 0.2;\n weights[5] = 0.1;\n weights[6] = 0.05;\n\n vec2 texelSize = vec2(1.0 / screenSize.x, 1.0 / screenSize.y);\n vec2 texelStep = texelSize * direction * blurWidth;\n vec2 start = vUV - 3.0 * texelStep;\n\n vec4 baseColor = vec4(0., 0., 0., 0.);\n vec2 texelOffset = vec2(0., 0.);\n\n for (int i = 0; i < 7; i++)\n {\n baseColor += texture2D(textureSampler, start + texelOffset) * weights[i];\n texelOffset += texelStep;\n }\n\n gl_FragColor = baseColor;\n}",
convolutionPixelShader:"#ifdef GL_ES\nprecision mediump float;\n#endif\n\n// Samplers\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\
@demonixis
demonixis / AtlantisGameMain.cpp
Created February 16, 2014 17:50
Using Atlantis Framework to draw a background and a player. This sample work on all platforms where SDL2 is supported.
#include "SDL.h"
#include "Game.h"
#include "Graphics/SpriteBatch.h"
#include "Vector2.h"
#include "Color.h"
#include "Graphics/Texture2D.h";
using namespace Atlantis::Framework;
using namespace Atlantis::Framework::Graphics;
using namespace Atlantis::Framework::Input;
@demonixis
demonixis / QtCreatorProject.pro
Created February 16, 2014 17:59
My QtCreator project file to use with SDL2
TEMPLATE = app
CONFIG += console
QMAKE_CXXFLAGS += -std=c++11
CONFIG -= app_bundle
CONFIG -= qt
win32 {
INCLUDEPATH += ../ThirdParty/windows/include
LIBS += -LC:../ThirdParty/windows/lib -lSDL2 -lSDL2_image -lSDL2_ttf
}
unix:!macx {
@demonixis
demonixis / TilemapSample.js
Created March 16, 2014 13:24
How to load a tilemap and add a player with AtlantisEngine.js
// The Game class
var TilemapGame = function () {
Atlantis.GameApplication.call(this, 640, 480);
this.content.rootDirectory = "Content/";
this.spriteBatch = new Atlantis.SpriteBatch(this.graphicsDevice);
this.tilemap = null;
this.camera = new Atlantis.Camera2D();
this.player = new Atlantis.Sprite("Player.png");
this.player.move(15, 25);
this.camera.follow(this.player);
typeof(+undefined|0)
typeof(+NaN|0)
typeof(+null|0)
typeof(+0|0)
typeof(+[]|0)
typeof(+{}|0)
typeof(+"2"|0)
typeof(+1|0)
// +yourValue|0
@demonixis
demonixis / SceneBabylon.js
Last active August 29, 2015 14:00
This scene is working finel on Windows and Linux but there are lighting issue when we set the receiveShadows flags to true on an object. In this demo the ground's bottom must be highlited but it's not on Windows Phone 8.1 and Mac OS X.
'use strict';
window.onload = function () {
var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);
var scene = new BABYLON.Scene(engine);
// CAMERA
var camera = new BABYLON.ArcRotateCamera("ArcRotateCamera", 1, 0.8, 10, new BABYLON.Vector3(15, 1, 15), scene);
camera.minZ = 0.1;
@demonixis
demonixis / RestoreMBR
Created May 11, 2014 08:29
Restore MBR (Windows)
bootrec /fixmbr
bootrec /fixboot
# or
bootsect /nt60 sys /mbr # (can add /force at the end)
@demonixis
demonixis / SceneObject.fx
Last active August 29, 2015 14:04
A shader to render a textured scene object with a shadow map in a XNA/MonoGame application
float4x4 World;
float4x4 View;
float4x4 Projection;
float4x4 lightView;
float4x4 lightProjection;
float3 lightPosition;
float3 lightRadius = float3(100.0, 100.0, 100.0);
float shadowMapSize = 512;
float bias = 7.0 / 1000.0;
@demonixis
demonixis / ShadowMap.fx
Created July 19, 2014 09:08
A shadow map shader to use in a XNA/MonoGame application.
float4x4 World;
float4x4 View;
float4x4 Projection;
struct VertexShaderInput
{
float4 Position : POSITION0;
};
struct VertexShaderOutput
@demonixis
demonixis / git-clone-nohistory
Created August 7, 2014 10:05
Git clone without history
git clone --depth=1 https://provider.com/user/repo.git