Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / gist:06e010e95271e9271afe
Last active August 29, 2015 14:05
nanovg emscripten/pnacl notes

Making nanovg run in emscripten didn't require any changes except for 2 bugs:

Bugs
  • the many glGetError calls killed performance, especially on Chrome; a define which turns glnvg__checkError into a no-op would be nice
  • the icon textures are non-POT, and need GL_TEXTURE_WRAP_S/GL_TEXTURE_WRAP_T set to GL_CLAMP_TO_EDGE in order to be rendered (this may have been GL state spilling over from my engine though, but I think nanovg should override this state)

General porting notes:

IO
@floooh
floooh / gist:b68a160b96775b82092a
Created January 8, 2015 20:32
Oryol clang 3.5 crash log
Process: clang-3.5 [83466]
Path: /Users/USER/*/clang-3.5
Identifier: clang-3.5
Version: 3.5.0 (???)
Code Type: X86-64 (Native)
Parent Process: clang-3.5 [83465]
Responsible: iTerm2 [65281]
User ID: 501
Date/Time: 2015-01-08 21:16:55.629 +0100
@floooh
floooh / gist:ed4eafef5e20d0057bdb
Last active August 29, 2015 14:13
Howto integrate glfw3 into a fips project

How to add the 'fipsified' glfw3 at https://github.com/floooh/fips-glfw as import to a fips project:

  • add 'fips-glfw' as import to your project's fips.yml file:
---
# external dependencies
imports:
  - fips-glfw
@floooh
floooh / gist:3b8a475d840b07d11402
Last active February 24, 2016 18:03
chdir() in OSX app bundles vs cmd line executables

Ok, about the problem that the bgfx samples built with fips-bgfx cannot load the sample data from the examples/runtime directory even though the working directory at application startup is set to that directory (see here: floooh/fips-bgfx#7). When building with the original bgfx build files, everything works fine. The only difference seems to be that bgfx builds the samples as app bundles, but fips-bgfx builds the samples as 'raw' command line exe.

There is a chdir() in the bgfx sample entry code which is supposed to change the cwd to the app bundle's resource directory (since this is where OSX resources usually are). Now the interesting thing is, that this is chdir() is ignored when the app is compiled as app bundle, and the originally set working directory (examples/runtime) is preserved. But when compiling as command line exe (like fips-bgfx does), the chdir works, changes the working

This is so far the only really annoying thing I've encountered in Rust, and which IMHO doesn't
make sense (and I guess this is this known issue: https://github.com/rust-lang/rust/issues/29975).
I have a simple struct with the Z80 CPU emulator state, most of the functions in the impl block need
to modify the content of the struct(for instance in the case of the inc8() method, set
status flags):
struct CPU {
pub reg : [i64, NUM_REGS];
...
let mut out_port = 0;
let mut out_byte = 0xFF;
let mut cpu = rz80::CPU::new();
cpu.out_fn = |port, val| {
out_port = port;
out_byte = val;
};
==== Building flatbuffers (release64) ====
==== Building protocol (release64) ====
Running pre-build commands
../bin/x64_release/flatbuffers/flatc --cpp --scoped-enums -o ../../../code/protocol/ ../../../code/protocol/protocol.fbs
==== Building net (release64) ====
protocol_message.cpp
tcp_client.cpp
In file included from ../../../code/net/tcp_client.cpp:11:
In file included from ../../../code/net/tcp_client.h:15:
In file included from ../../../code/thirdparty/asio/asio.hpp:19: