Skip to content

Instantly share code, notes, and snippets.

@tuket
tuket / imgui.glsl
Created November 24, 2022 22:00
change imgui shader
View imgui.glsl
precision highp float;
layout (location = 0) in vec2 Position;
layout (location = 1) in vec2 UV;
layout (location = 2) in vec4 Color;
uniform mat4 ProjMtx;
out vec2 Frag_UV;
out vec4 Frag_Color;
void main()
{
Frag_UV = UV;
@tuket
tuket / enet_example.cpp
Created November 17, 2022 15:36
Simple ENet example
View enet_example.cpp
#include <stdio.h>
#include <thread>
#include "enet.h"
const uint16_t THE_PORT = 55555;
static void sendString(ENetPeer* peer, const char* str)
{
ENetPacket* packet = enet_packet_create(str, strlen(str) + 1, ENET_PACKET_FLAG_RELIABLE);
enet_peer_send(peer, 0, packet);
@tuket
tuket / possible_bug.md
Last active November 8, 2022 10:11
Bug report for Nvidia
View possible_bug.md

Hello, I'm a software developer and I'm using Vulkan. After updating my drivers, I noticed that I started getting some errors from the Khronos validation layers. After lots of time debugging, I think I found the issue. I had to compile the Validation Layers in debug mode in order to find out.

The problem is in the vkCreateInstance function. If you set VkInstanceCreateInfo.VkApplicationInfo.apiVersion = VK_API_VERSION_1_0 ...

when you get to the Validation Layer callback:

VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,

@tuket
tuket / main.cpp
Created October 25, 2022 11:45
OpenGL sRGB experiment
View main.cpp
#include "utils.hpp"
#include <GLFW/glfw3.h>
constexpr int W = 800;
constexpr int H = 600;
GLFWwindow* window;
namespace shader_srcs
{
@tuket
tuket / latlong_tile.py
Last active October 17, 2022 13:53
Google Maps: Get tile image from latlong coordinate
View latlong_tile.py
import math
def latlongToTile(latlongDegs, zoom):
n = 2 ** zoom
latRads = math.radians(latlongDegs[0])
tileX = n * ((latlongDegs[1] + 180.0) / 360.0)
tileY = n * (1.0 - (math.log(math.tan(latRads) + 1.0/math.cos(latRads)) / math.pi)) / 2.0
return (int(tileX), int(tileY))
def latlongToUrl(latlongDegs, zoom):
@tuket
tuket / example1.cpp
Created September 14, 2022 07:39
vulkan example that shouldn't be working
View example1.cpp
#include <stdio.h>
#include <assert.h>
#include <vulkan/vulkan.h>
#include <glm/glm.hpp>
#include <GLFW/glfw3.h>
#include <stb_image.h>
typedef uint8_t u8;
typedef int32_t i32;
typedef int64_t i64;
@tuket
tuket / windows_cpuid_shellcode.cpp
Last active August 20, 2022 21:50
windows cpuid shellcode
View windows_cpuid_shellcode.cpp
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <Windows.h>
static const char cpuidCode[] =
{
0x48, 0x89, 0xCE, // mov rsi, rcx
0x31, 0xC0, // xor eax, eax
0x0F, 0xA2, // cpuid
@tuket
tuket / tips.odin
Created April 14, 2022 07:24
Odin Tips
View tips.odin
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
View repro_bug_glCopyImageSubData.cpp
#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
View calc.comp.glsl
#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;