Skip to content

Instantly share code, notes, and snippets.

View thebirk's full-sized avatar

Aleksander Birkeland thebirk

View GitHub Profile
@thebirk
thebirk / freetype.go
Created July 29, 2018 18:16
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 {
#assert(false);
}
FT_Library_ :: struct {}
@thebirk
thebirk / buildnum.c
Created July 7, 2018 21:26
Simple build number counter.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
if(argc != 2) {
printf("Usage: buildnum <file>\n");
return 1;
}
@thebirk
thebirk / vars.bat
Created March 22, 2018 19:39
A faster vcvarsall x64 for Visual Studio 2017 located on the C drive. Is specific to many versions and likely to break
@echo off
set CommandPromptType=Native
set DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\
set ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs
set Framework40Version=v4.0
set FrameworkDir=C:\Windows\Microsoft.NET\Framework64\
set FrameworkDir64=C:\Windows\Microsoft.NET\Framework64\
set FrameworkVersion=v4.0.30319
set FrameworkVersion64=v4.0.30319
set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt;
@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)
@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,
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 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_;
@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_;
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
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