Skip to content

Instantly share code, notes, and snippets.

View thebirk's full-sized avatar

Aleksander Birkeland thebirk

View GitHub Profile
@thebirk
thebirk / queue.go
Last active September 29, 2017 14:37
Non-working queue written in Odin
// IMPORTANT: THIS IS A NON WORKING EXAMPLE
// ATTENTION: THIS IS NOT WORKING
import "core:fmt.odin";
QueueNode :: struct(T: type) {
data: T,
prev: int,
used: bool = false,
}
@thebirk
thebirk / al.go
Created October 9, 2017 09:50
OpenAL binding for Odin - odin-lang.org
when ODIN_OS == "windows" {
foreign_library openal "OpenAL32.lib";
} else {
_ := compile_assert(false);
}
/*
ALboolean -> u8
ALchar -> u8
ALbyte -> i8
@thebirk
thebirk / floatingbar.js
Last active December 4, 2017 10:57
Pls never forget
window.addEventListener("scroll", function() {
var spoiler = document.getElementById("spoiler2");
var div = document.getElementsByClassName("problem")[0];
var divs = document.querySelectorAll(".divspoiler");
var spoilers = document.querySelectorAll("input[id^=\"spoiler\"]");
//console.log(labels);
var divsfratop = [];
divs.forEach(function(item, index) {
This file has been truncated, but you can view the full file.
; ModuleID = 'test.bc'
source_filename = "odin-module"
; Function Attrs: nounwind
declare void @llvm.assume() #0
; Function Attrs: nounwind
declare void @llvm.debugtrap() #0
; Function Attrs: noreturn nounwind
This file has been truncated, but you can view the full file.
; ModuleID = 'test.bc'
source_filename = "odin-module"
; Function Attrs: nounwind
declare void @llvm.assume(i1) #0
; Function Attrs: nounwind
declare void @llvm.debugtrap() #0
; Function Attrs: noreturn nounwind
@thebirk
thebirk / freetype.go
Created February 22, 2018 10:16
Basic freetype binding for Odin
using import "core:c.odin"
foreign import ftlib "freetype271.lib";
/*
when ODIN_OS == "windows" do foreign import ftlib "freetype271.lib";
else do _ :: compiler_assert(false);
*/
FT_Library_ :: struct {}
FT_Library :: ^FT_Library_;
@thebirk
thebirk / freetype.go
Created February 22, 2018 17:51
Mostly working packing, just handle memory and check for duplicate packed chars
using import "core:c.odin"
foreign import ftlib "freetype271.lib";
/*
when ODIN_OS == "windows" do foreign import ftlib "freetype271.lib";
else do _ :: compiler_assert(false);
*/
FT_Library_ :: struct {}
FT_Library :: ^FT_Library_;
This file has been truncated, but you can view the full file.
target triple = "x86_64-pc-windows-msvc"
%..opaque = type {};
%..string = type {i8*, i64} ; Basic_string
%..rawptr = type i8* ; Basic_rawptr
%..complex32 = type {half, half} ; Basic_complex32
%..complex64 = type {float, float} ; Basic_complex64
%..complex128 = type {double, double} ; Basic_complex128
%..any = type {%..rawptr, %Type_Info*} ; Basic_any
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
@thebirk
thebirk / freetype.go
Created March 7, 2018 03:15
Basic texture atlas using freetype in odin
// Store the glyph index in the font for faster kerning lookup?
Glyph :: struct {
bearingX, bearingY: int,
width, height: int,
advanceX: int,
}
Font :: struct {
face: FT_Face,
contex: stbrp_context,
@thebirk
thebirk / lang.cpp
Last active March 14, 2018 13:15
Toy compiler WIP
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#ifdef _WIN32
# define _strdup strdup
# define NORETURN __declspec(noreturn)