Skip to content

Instantly share code, notes, and snippets.

@floooh
floooh / oryol_game_loop.md
Last active May 8, 2017 19:42
How the Oryol game loop and event handling works

Execution starts in a macro "OryolMain()", this contains the platform's main() function, creates an App-object and calls the App::StartMainLoop() method. There are 3 macro version, one for Windows (containing WinMain()), one for Android (android_main()) and all other platforms (vanilla main()):

https://github.com/floooh/oryol/blob/master/code/Modules/Core/Main.h

https://github.com/floooh/oryol/blob/master/code/Modules/Core/App.cc#L66

The App::StartMainLoop() has further platform-specific handling, on platforms where

@floooh
floooh / CMakeLists.txt
Last active August 11, 2019 17:30
copy asset files as fips code-gen job
# a code-gen job must be added to the application's CMakeLists.txt through a call to fips_generate()
fips_begin_app(dragons windowed)
fips_src(.)
fips_generate(files.yml TYPE filecopy OUT_OF_SOURCE ARGS "{ deploy_dir: \"${FIPS_PROJECT_DEPLOY_DIR}\" }")
# REMOVE THIS: n3h5_files(files.yml)
fips_deps(emsctest)
fips_end_app()
==== 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:
@floooh
floooh / NetClient.cc
Created January 18, 2017 16:07
NetClient.h (emscripten/osx/win)
//------------------------------------------------------------------------------
// NetClient.cc
//------------------------------------------------------------------------------
#if ORYOL_WINDOWS
#define _WINSOCK_DEPRECATED_NO_WARNINGS (1)
#include <WinSock2.h>
typedef int ssize_t;
#endif
#if ORYOL_POSIX
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;
};
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];
...
@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

@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: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: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