Skip to content

Instantly share code, notes, and snippets.

@tuket
tuket / tips.odin
Created April 14, 2022 07:24
Odin Tips
for v in soa_zip(_names, _surnames) {
fmt.println(v._0, " ", v._1)
}
@tuket
tuket / repro_bug_glCopyImageSubData.cpp
Created November 28, 2021 19:42
A minamal example to reproduce a bug with glCopyImageSubData
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <SDL.h>
#include <glad/glad.h>
typedef uint32_t u32;
static const char* geGlErrStr(GLenum const err)
{
@tuket
tuket / calc.comp.glsl
Created May 27, 2021 18:04
Vulkan validation error when I try to reset a commandPool after vkQueueWaitIddle
#version 450
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
layout (local_size_x = 128) in;
layout(set = 0, binding = 0) uniform Unifs {
uniform int64_t start;
uniform int64_t n;
uniform int64_t N;
} unifs;
@tuket
tuket / wgl_minimal_enum_display_devices.c
Last active February 23, 2021 11:57
WGL minamal example that enumates display devices
#include <windows.h> /* must include this before GL/gl.h */
#include <GL/gl.h> /* OpenGL header file */
#include <GL/glu.h> /* OpenGL utilities header file */
#include <stdio.h>
#pragma comment (lib, "opengl32.lib")
void display()
{
/* rotate a triangle around */
@tuket
tuket / gen_raw_elf_hello_world.c
Created February 10, 2021 22:00
Generate a raw ELF executable using C
#include <stdio.h>
#include <string.h>
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef struct Elf64Header {
@tuket
tuket / pf.asm
Created January 22, 2021 20:06
Nasm Linux - Print the contents of a file
SECTION .text
global _start ; "global" means that the symbol can be accessed in other modules. In order to refer to a global symbol from another module, you must use the "extern" keyword
_start:
mov rax, 2 ; syscall: open
mov rdi, str_testFile
mov rsi, 0 ; flags
syscall
mov rdi, rax ; the file descriptor
@tuket
tuket / sdl_ttf_hello.c
Last active September 15, 2020 23:06
SDL_TTF hello world
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
const SDL_Color WHITE = { 0xFF, 0xFF, 0xFF, 0 };
int main()
{
SDL_Window* window;
SDL_Renderer* renderer;
SDL_CreateWindowAndRenderer(200, 200, 0, &window, &renderer);
@tuket
tuket / ray_vs_circle.cpp
Created July 10, 2020 22:09
ray_vs_circle
bool rayVsCircle(float& depth,
glm::vec2 rayOrig, glm::vec2 rayDir,
glm::vec2 circlePos, float circleRad)
{
const float R = circleRad;
const glm::vec2 op = circlePos - rayOrig;
if(dot(op, op) < R*R) { // is rayOrigin inside the circle ?
depth = 0;
return true;
}
@tuket
tuket / generateIcosahedron.cpp
Last active April 12, 2021 18:28
generate icosahedron
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
constexpr float PI = glm::pi<float>();
using glm::vec3;
/*static void generateIcosahedronVerts(vec3 verts[12])
{
using glm::sqrt;
using glm::mat2;
@tuket
tuket / sdl_main.zig
Created November 12, 2019 20:57
basic SDL game loop in Zig
const std = @import("std");
const warn = std.debug.warn;
const fmt = std.fmt;
const c = @cImport({
@cInclude("SDL2/SDL.h");
});
const assert = @import("std").debug.assert;
const SDL_WINDOWPOS_UNDEFINED = @bitCast(c_int, c.SDL_WINDOWPOS_UNDEFINED_MASK);