Skip to content

Instantly share code, notes, and snippets.

@sherjilozair
sherjilozair / main.c
Last active April 30, 2024 12:52
Minimal SDL2 + OpenGL3 example
#include <SDL2/SDL.h>
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
#include <GL/gl.h>
#endif
#include <stdbool.h>
#define CODE(...) #__VA_ARGS__
@sherjilozair
sherjilozair / celeste.lua
Created June 17, 2018 19:18
Source code for pico-8 version of Celeste
-- ~celeste~
-- matt thorson + noel berry
-- globals --
-------------
room = { x=0, y=0 }
objects = {}
types = {}
freeze=0
@sherjilozair
sherjilozair / sdl-sokol-sprite.c
Created June 9, 2018 14:05
Minimal sprite rendering example with SDL2 for windowing, sokol_gfx for graphics API using OpenGL 3.3 on MacOS
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include <sokol_gfx.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define CODE(...) #__VA_ARGS__
// Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// replace all -1 with 0
for i in 0..input.len() {
for j in 0..input[i].len() {
if input[i][j] == -1 {
input[i][j] = 0;
}
}
}
// check if any greater than 9, set them to -1
// and call update on valid neighbours and diagonals
for i in 0..input.len() {
for j in 0..input[i].len() {
if input[i][j] > 9 {
input[i][j] = -1;
if i > 0 {
input[i - 1][j] = update(input[i - 1][j]);
}
// check if any greater than 9, set them to -1
// and increase neighboring and diagonal numbers
for i in 0..input.len() {
for j in 0..input[i].len() {
if input[i][j] > 9 {
input[i][j] = -1;
if i > 0 {
input[i - 1][j] += 1;
}
if i < input.len() - 1 {
We can't make this file beautiful and searchable because it's too large.
6.889945268630981445e-02 -2.861346602439880371e-01 -3.925032168626785278e-02 -3.623076677322387695e-01 1.960779875516891479e-01 -3.475854694843292236e-01 -2.716838195919990540e-02 7.233723998069763184e-01 -6.847973912954330444e-02 3.357532024383544922e-01 -5.403805524110794067e-02 -1.776816993951797485e-01 1.282918453216552734e-01 5.336205288767814636e-02 1.645264923572540283e-01 -5.097864195704460144e-02 -1.420844942331314087e-01 3.146397769451141357e-01 -6.186333950608968735e-03 6.532677263021469116e-02 -9.640390425920486450e-02 1.565462164580821991e-02 8.701873570680618286e-02 -7.057786732912063599e-02 -2.249079942703247070e-01 4.932923614978790283e-01 -2.855118922889232635e-02 -3.776965737342834473e-01 -2.141559422016143799e-01 -2.595035135746002197e-01 7.454491406679153442e-02 -4.764346778392791748e-02 8.831843733787536621e-02 2.022788524627685547e-01 1.004968211054801941e-01 -5.296880006790161133e-01 -2.188143581151962280e-01 2.983406484127044678e-01 4.443191289901733398e-01 -1.773966312408447266e+00 -7
asdasd