Skip to content

Instantly share code, notes, and snippets.

@kaneta1992
kaneta1992 / emscripten_gl.c
Created June 28, 2015 16:49
emscriptenOpenGLES2.0初期化サンプル
#include <stdio.h>
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <emscripten.h>
int main()
{
//キャンバスサイズ指定
emscripten_set_canvas_size(256,256);
//ディスプレイ取得
@kaneta1992
kaneta1992 / three.js memo
Created January 10, 2016 10:59
three.js glsl組み込み定義
1: precision highp float;
2: precision highp int;
3: #define SHADER_NAME ShaderMaterial
4: #define VERTEX_TEXTURES
5: #define GAMMA_FACTOR 2
6: #define MAX_DIR_LIGHTS 0
7: #define MAX_POINT_LIGHTS 0
8: #define MAX_SPOT_LIGHTS 0
9: #define MAX_HEMI_LIGHTS 0
10: #define MAX_SHADOWS 0
@kaneta1992
kaneta1992 / relation_list.sh
Last active August 26, 2016 07:30
シェーダーの依存ファイルを調べたかった時に書いた
#!/bin/bash
IFS=$'\n'
declare -a KNOWN_LIST=()
function func() {
echo "${KNOWN_LIST[*]}" | grep $1 > /dev/null && return
KNOWN_LIST+=($1)
echo $1
for filename in $(cat $1 | grep "#include" | sed 's/'\''/"/g;' | cut -d'"' -f2); do
@kaneta1992
kaneta1992 / やりたいことリスト.md
Last active January 15, 2018 07:41
できないって言うな!できる できる できる!

言語

  • golang
  • ruby
  • javascript
  • C#

エンジン

  • Unity

フレームワーク

  • ruby on rails
  • Echo(golang)
#pragma comment(lib,"d3d11.lib")
#include <d3d11.h>
D3D_DRIVER_TYPE g_driverType;
D3D_FEATURE_LEVEL g_featureLevel;
ID3D11Device* g_pd3dDevice = nullptr;
ID3D11DeviceContext* g_pImmediateContext = nullptr;
HRESULT InitDevice()
{
#include <d3d11.h>
D3D_DRIVER_TYPE g_driverType;
D3D_FEATURE_LEVEL g_featureLevel;
ID3D11Device* g_pd3dDevice = nullptr;
ID3D11DeviceContext* g_pImmediateContext = nullptr;
typedef HRESULT (__stdcall *FPD3D11CREATEDEVICE)(
IDXGIAdapter *pAdapter,
D3D_DRIVER_TYPE DriverType,
package main
import (
"log"
"syscall"
"unsafe"
)
type IUnknown struct {
v *IUnknownVTable
@kaneta1992
kaneta1992 / float_pack.cpp
Created January 13, 2019 17:49
GLSLで使いたいのでビット演算を使わずにfloatをunsigned char 4つにパック・アンパックする
#include <cmath>
#include <limits>
#include <iostream>
struct ivec4 {
unsigned char x, y, z, w;
};
float fract(float x) {
return x - std::floorf(x);
vec4 pack(float val) {
// 符号取得
float s = sign(val);
// 絶対値
val *= s;
// 指数取得
float e = floor(log2(val));
// 仮数取得
float m = val / pow(2.0, e);
// vec4にパックする
#include <iostream>
#include <cmath>
using namespace std;
float gauss(float sigma, float x)
{
float sigma2 = sigma * sigma;
return exp(-(x * x) / (2.0f * sigma2));
}