Skip to content

Instantly share code, notes, and snippets.

@floooh
floooh / oryol_getattriblocation.md
Last active August 29, 2015 14:02
How to use ORYOL_USE_GLGETATTRIBLOCATION

Set ORYOL_USE_GLGETATTRIBLOCATION cmake option to ON to activate alternative vertex attribute binding code-path using glGetAttribLocation instead of glBindAttribLocation. This is necessary on platforms where GL_MAX_VERTEX_ATTRIBS is smaller then Oryol's VertexAttr::NumVertexAttrs (16). Currently the only known platform where this is the case is the Raspberry Pi where GL_MAX_VERTEX_ATTRIBS is 8. Using this code path is mutually exclusive with vertex-array-objects, because of this ORYOL_USE_GLGETATTRIBLOCATION cannot be used on platforms which use the GL 3+ core profile (e.g. OSX).

How to configure the build process:

> oryol clean all
> oryol select [config]
> oryol config

This should start ccmake or cmake-gui.

@floooh
floooh / oryol_shaders.glsl
Last active August 29, 2015 14:01
Testing Oryol shader template syntax
only exactly one @ tag per line
@block MyTransform
@uniform mat4 mvp ModelViewProj
vec4 transform(vec4 pos) {
return mvp * pos;
}
@end
@vs MyVertexShader
@floooh
floooh / gist:10591621
Created April 13, 2014 16:39
GLSL Macros
#if ORYOL_OPENGLES2
strBuilder.Append("#define ORYOL_OPENGLES2 (1)\n");
if (GL_VERTEX_SHADER == glShaderType) {
strBuilder.Append("#define VS_INPUT(type,name) attribute type name\n");
strBuilder.Append("#define VS_OUTPUT(type,name) varying type name\n");
}
if (GL_FRAGMENT_SHADER == glShaderType) {
strBuilder.Append("precision mediump float;\n");
strBuilder.Append("#define FS_INPUT(type,name) varying type name\n");
strBuilder.Append("#define TEXTURE2D(x,y) texture2D(x,y)\n");
@floooh
floooh / atomic_test.cpp
Created April 8, 2014 17:35
C++ atomic test for emscripten
//------------------------------------------------------------------------------
// test C++11 atomics
// compile native version with:
// clang -std=c++11 -Wno-format atomic_test.cpp
// compile emscripten version with:
// emcc -std=c++11 -Wno-format atomic_test.cpp
//------------------------------------------------------------------------------
#include <atomic>
#include <cstdio>