Skip to content

Instantly share code, notes, and snippets.

@floooh
floooh / zig_test_debugging_vscode.md
Last active April 30, 2024 15:33
How to debug Zig tests in VSCode

Tested on macOS:

  1. Install the CodeLLDB VSCode extension. Unlike the debugger in the C/C++ extension, this allows to set breakpoints inside Zig "test" blocks (in the MS C/C++ extension debugger, breakpoints inside test blocks will be disabled once the debugger starts for unknown reasons.
  2. When compiling the test, tell it to also emit a binary: zig test -femit-bin=zig-out/bin/my-test src/bla.zig, otherwise there will be no executable to debug.
  3. The compiled test executable expects the path to the Zig executable as first command line argument, the launch.json file needs to be setup accordingly (note the args item):
@floooh
floooh / gfx.json
Created November 7, 2023 10:10
sokol_gfx.h auto-generated API JSON
{
"module": "gfx",
"prefix": "sg_",
"dep_prefixes": [],
"decls": [
{
"kind": "struct",
"name": "sg_buffer",
"fields": [
{
@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>
@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
@floooh
floooh / CMakeUserPresets.json
Created January 6, 2023 19:48
my generated cmake presets file
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "default",
@floooh
floooh / gist:360e884ea45c9868039c9ddb1343750d
Created December 5, 2017 13:01
emscripten/posix socket client example
//------------------------------------------------------------------------------
// NetClient.cc
//------------------------------------------------------------------------------
#if ORYOL_WINDOWS
#define _WINSOCK_DEPRECATED_NO_WARNINGS (1)
#include <WinSock2.h>
typedef int ssize_t;
#endif
#if ORYOL_POSIX
@floooh
floooh / hello.c
Created March 7, 2021 17:56
C-on-ObjC experiments...
// which is then used like this
// (helper functions like oc_alloc() and oc_alloc_init() will move into a header later)
#include <stdio.h>
#include <assert.h>
#include "hello_macos.h"
Class app_delegate_class;
id app_delegate;
@floooh
floooh / project.pbxproj
Created February 27, 2022 11:46
Fixed Xcode project file for DeferredLighting sample
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
3A2F3F23226FE35A000FACA9 /* AAPLRenderer_TraditionalDeferred.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AE0241720584D0F00D9006B /* AAPLRenderer_TraditionalDeferred.m */; };
@floooh
floooh / imgui_buffer_update.md
Last active February 9, 2022 12:26
How I update vertex/index buffers for Dear Imgui

My Dear Imgui render loop looks a bit unusual because I want to reduce calls to WebGL as much as possible, especially buffer update calls.

This means:

  • only one buffer each for all per-frame vertex- and index-data
  • only one update call each per frame for vertex- and index-data (with my own double-buffering, since buffer-orphaning doesn't work on WebGL, and with this I'm also independent from any 'under-the-hood' magic a GL driver might or might not perform)