Skip to content

Instantly share code, notes, and snippets.

float wind = perlinNoise(vec3(texcoord.x, texcoord.y, scene.timer.seconds), vec3(FLT_MAX, FLT_MAX, scene.timer.period));
wind *= 1 - texcoord.y;
wind *= 5.0;
vec2 noise_coords = texcoord * 5 + vec2(0, scene.timer.seconds);
noise_coords.x *= 2;
noise_coords.x += wind;
float noise = perlinFbm(
vec3(noise_coords, scene.timer.seconds),
vec3(FLT_MAX, FLT_MAX, scene.timer.period),
1,
//! ZON can be serialized with `serialize`.
//!
//! The following functions are provided for serializing recursive types:
//! * `serializeMaxDepth`
//! * `serializeArbitraryDepth`
//!
//! For additional control over serialization, see `Serializer`.
//!
//! The following types and any types that contain them may not be serialized:
//! * `type`
// I'm thinking these two will resolve themselves when the others do? There
// doesn't seem to be an explicit way to make a window not key besides replacing
// it with another window, or closing it.
[...]
-> _keyWindow
-> MyWindow
[...]
-> NSDragDestination (_window)
-> MyWindow
// # To test (macOS only)
// - Copy the contents of this file into a file called main.m
// - Run `clang main.m -fobjc-arc -xobjective-c++ -framework Cocoa && ./a.out`
// in bash
// - Send me:
// + The copy pasted console output from the run
// + Your macOS version (Apple > About This Mac)
// + Your clang version (`clang --version`)
// + Whether or not your computer has a Touch Bar
//
@MasonRemaley
MasonRemaley / refresh_rate.m
Last active May 13, 2018 23:04
refresh_rate.m
// gcc refresh_rate.m -framework Cocoa -framework CoreVideo && ./a.out
//
// Prints the refresh rate of your main screen...I think.
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
int main() {
NSScreen *screen = [NSScreen mainScreen];
CGDirectDisplayID id = (CGDirectDisplayID)[
@MasonRemaley
MasonRemaley / minimal_cocoa_gl_text_entry.m
Last active November 17, 2017 03:01
Minimal cocoa text entry for OpenGL apps
// *DISCLAIMER IF YOU FOUND THIS VIA GOOGLE: I'm at the time of writing still figuring this out, it
// works for me but I don't actually know if it's correct yet*
//
// This is a minimal example of how one might accept text entry in Cocoa in an OpenGL app or
// such. Unlike using `[event characters]`, it ignores unprintable keys such as the arrow keys. It
// also allows you to type accents and such, e.g. `alt+e o`. This example contains no error
// checking, and the only way to exit it is to kill it from the command line.
//
// To execute it, run:
// `$ gcc minimal_cocoa_gl_text_entry.m -framework Cocoa && ./a.out`