Skip to content

Instantly share code, notes, and snippets.

View mjakeman's full-sized avatar

Matt Jakeman mjakeman

View GitHub Profile
# MSVC Build Tools Access Script
# Adds VC environment variables to the currently active Powershell Shell
# Location of vswhere.exe (at this location since VS 2015.2)
$vswhere = ${env:ProgramFiles(x86)} + "\Microsoft Visual Studio\Installer\vswhere.exe"
# Initialises a new shell with access to the MSVC Build Tools
# From https://github.com/microsoft/vswhere/wiki/Find-VC
$path = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
// Destroy Notify Demo
// Adapted from GTK 3 Tutorial
//
// Compile with:
// gcc `pkg-config --cflags gtk+-3.0` -o destroy-notify destroy-notify.c `pkg-config --libs gtk+-3.0`
//
// Output:
// $ ./destroy-notify
// Source Func
// Destroy Notify
@mjakeman
mjakeman / distribute-windows-msys2.md
Last active May 22, 2024 05:44
An easy way to distribute GTK applications and dependenices on Windows

Distribute GTK Apps with Windows (MSYS2)

Make sure package mingw-w64-x86_64-gtk3 is installed. Build your project with a custom prefix (e.g. ~/my-gtk-app-prefix). Navigate to this directory such that you have subdirectories 'bin', 'lib', 'share', etc containing the executable to distribute.

1. Dependent DLLs

The following command copies all dependent DLLs to the current directory:

@mjakeman
mjakeman / gobject-list-properties-signals.c
Created January 14, 2022 16:38
A quick snippet for listing all the properties and signals of a GObject. Something I've ended up using far more often than you would think.
// We have an object of type MyObject called 'obj'
// To use:
// replace 'obj' with your var name
// replace 'MY_TYPE_OBJECT' with the object's gtype
// snip
guint n_props;
GParamSpec **params = g_object_class_list_properties (G_OBJECT_GET_CLASS (obj), &n_props);
for (guint i = 0; i < n_props; i++)
@mjakeman
mjakeman / inkscape-gtk4.md
Created October 25, 2022 16:27
Let's port inkscape to gtk4
@mjakeman
mjakeman / inkscape-ide-setup.md
Created October 26, 2022 22:43
Inkscape CLion setup

Setting up Inkscape with CLion

These instructions are for macOS:

CMake options:

First set up cmake to check homebrew for dependencies.

We do this inside Preferences->Build, Execution, Deployment->CMake.

@mjakeman
mjakeman / zig-wishlist.md
Created February 2, 2024 01:31
Matthew's Zig Wishlist

Matthew'z Zig Wishlist

From creating my 3D pixel game engine.

Pain Points:

  • Lack of easy polymorphism: I currently used tagged unions and it's fine-ish, but having interfaces or traits in the language would make it infinitely more ergonomic to use.
  • Casting is a nightmare: There really needs to be a shorter way to cast from int -> float and vice-versa. Compare C's (float) with Zig's @as(f32, @floatFromInt(...)). If I could write @floatFromInt(f32, ...) it would already be much better.

Nice to have:

  • Comptime methods: I wanted to add swizzling methods for my custom vector struct, however you cannot generate methods at compile time (?). It would be nice to have a function e.g. Vector(dimension, components) which can then generate swizzle methods for each combination of components. I imagine calling vec.xyzz() and having that method be generated and even inlined at compile time.
  • Easier way to do vector maths: I currently call vec.mul(other) but it would be nice to write vec * other. Th
@mjakeman
mjakeman / zig-NSGLGetProcAddress-OpenGL-Loader-function.md
Created February 27, 2024 12:18
This loads OpenGL symbols in Zig on macOS so you can pass it to `gl.load(...)`.

Bit of a mouthful. This loads OpenGL symbols in Zig on macOS so you can pass it to gl.load(...).

Use it with https://github.com/MasterQ32/zig-opengl and a windowing system of your choice (e.g. GTK).

Loosely adapted from Apple Docs: https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_entrypts/opengl_entrypts.html#//apple_ref/doc/uid/TP40001987-CH402-SW6

License: Whatever you want (CC-0/Public Domain/Unlicense/etc)

const dyld = @cImport(@cInclude("mach-o/dyld.h"));