Skip to content

Instantly share code, notes, and snippets.

Geoff Catlin gcatlin

Block or report user

Report or block gcatlin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am gcatlin on github.
  • I am gcatlin (https://keybase.io/gcatlin) on keybase.
  • I have a public key ASDOkhxPwBV28ND_Pzm3rzNcVWViUFUakYvCgFb8dC-kiQo

To claim this, I am signing this object:

@gcatlin
gcatlin / glfw-opengl-example.c
Last active May 22, 2019
Minimal C GLFW OpenGL example
View glfw-opengl-example.c
//
// cc glfw-opengl-example.c glad.c -lglfw
//
#include "glad.h" // https://glad.dav1d.de/
#include <GLFW/glfw3.h>
static void quit(GLFWwindow *window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GLFW_TRUE);
@gcatlin
gcatlin / sdl-opengl-example.c
Last active Nov 30, 2018
Minimal C SDL2 OpenGL example
View sdl-opengl-example.c
//
// cc main.c glad.c -lSDL2
//
#include "glad.h" // https://glad.dav1d.de/
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <stdbool.h>
int main()
{
@gcatlin
gcatlin / glfw-metal-example.m
Last active May 22, 2019
Minimal C GLFW Metal example
View glfw-metal-example.m
//
// cc glfw-metal-example.m -lGLFW -framework AppKit -framework Metal -framework QuartzCore
//
#define GLFW_INCLUDE_NONE
#define GLFW_EXPOSE_NATIVE_COCOA
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
@gcatlin
gcatlin / sdl-metal-example.m
Last active Aug 20, 2019
Minimal C SDL2 Metal example
View sdl-metal-example.m
//
// cc sdl-metal-example.m -framework SDL2 -framework Metal -framework QuartzCore
//
#include <SDL2/SDL.h>
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
int main (int argc, char *args[])
{
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
@gcatlin
gcatlin / core-audio-sine-wave.c
Last active Mar 7, 2019
Core Audio sine wave example
View core-audio-sine-wave.c
// To run:
// clang core-audio-sine-wave.c -framework AudioUnit && ./a.out
#include <AudioUnit/AudioUnit.h>
#define SAMPLE_RATE 48000
#define TONE_FREQUENCY 440
#define M_TAU 2.0 * M_PI
OSStatus RenderSineWave(
void *inRefCon,
@gcatlin
gcatlin / build.sh
Created Jul 13, 2015
Dynamic loading/unloading of Go shared library
View build.sh
#!/bin/sh
go build -buildmode=c-shared lib.go
clang main.m -g -Wall -Werror -Wfatal-errors -pedantic -Wno-c11-extensions -Wno-unused-variable -Wno-unused-function -o main.out
@gcatlin
gcatlin / triangle.go
Created Jan 12, 2015
Go SDL2 OpenGL minimal example
View triangle.go
package main
import (
"runtime"
"github.com/go-gl/gl"
"github.com/veandco/go-sdl2/sdl"
)
func main() {
@gcatlin
gcatlin / multiple-error-handlers.php
Created May 30, 2013
Adds support for multiple error handlers in PHP
View multiple-error-handlers.php
<?php
function append_error_handler($handler) {
set_error_handlers(array(set_error_handler($handler), $handler));
}
function prepend_error_handler($handler) {
set_error_handlers(array($handler, set_error_handler($handler)));
}
@gcatlin
gcatlin / ShutdownFunctionManager.php
Created May 30, 2013
Simple PHP shutdown function manager
View ShutdownFunctionManager.php
<?php
class ShutdownFunctionManager {
protected $callbacks = array();
protected $registered = false;
public function __construct($auto_register = true) {
if ($auto_register) {
$this->register();
}
You can’t perform that action at this time.