Skip to content

Instantly share code, notes, and snippets.

View galek's full-sized avatar
🧭
I'm ready for new discoveries

Nikolay Galko galek

🧭
I'm ready for new discoveries
View GitHub Profile
@galek
galek / game_loop.cpp
Last active August 29, 2015 14:20 — forked from jakemco/game_loop.cpp
const int TICKS_PER_SECOND = 25;
const int MS_PER_TICK = 1000 / TICKS_PER_SECOND;
const int MAX_SKIPPED_FRAMES = 5;
void EngineInstance::run() {
this->last_tick_time = getTime() - TICKS_PER_SECOND;
while (this->shouldKeepRunning()) {
this->checkForUpdate();
@galek
galek / gist:bd1e38e03022ada4b1ef
Created May 14, 2015 22:36
manacher algorithm linear time longest palindromic substring
//Based on http://www.geeksforgeeks.org/manachers-algorithm-linear-time-longest-palindromic-substring-part-4/
// A C program to implement Manacher’s Algorithm
#include <stdio.h>
#include <string.h>
char text[100];
int min(int a, int b)
{
int res = a;
if (b < a)
@galek
galek / gist:aa13b202cdd60d8f9986
Last active August 29, 2015 14:26 — forked from od0x0/gist:965399
How I Load a .ogg into OpenAL Using stb_vorbis
typedef struct{
ALuint ID;
stb_vorbis* stream;
stb_vorbis_info info;
ALuint buffers[2];
ALuint source;
ALenum format;
@galek
galek / gist:2b7070933c5ec91088d7
Last active August 29, 2015 14:27 — forked from bagobor/gist:6452933
opengl txaa?
#version 330 core
#extension GL_ARB_shading_language_420pack: require
#extension GL_ARB_separate_shader_objects: require
#extension GL_ARB_shader_image_load_store: require
#extension GL_ARB_bindless_texture: require
#define ENABLE_BINDLESS_TEX
#define FRAGMENT_SHADER 1
#define ps_main main
#define PS_FST 0
#define PS_WMS 0
@galek
galek / Tree_Gen.ms
Last active March 24, 2022 14:55 — forked from bagobor/Tree_Gen.ms
TreeGen for 3DSMax written by Ryan James Smith aka "Virtuosic" on polycount forums.
/*
TreeGen for 3DSMax written by Ryan James Smith aka "Virtuosic" on polycount forums.
This is creative commons, edit and redistribute as you please, just remember to give original credit
also, if you add some cool stuff, email me at virtuosicrjs@gmail.com and let me know what you did so
i can be jealous i didn't think of it... Oh, and if you add something cool, sign your name below mine :D
*/
@galek
galek / gist:c037a36d705d149b11eb
Created October 22, 2015 14:05 — forked from rygorous/gist:4172889
SSE/AVX matrix multiply
#include <immintrin.h>
#include <intrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
union Mat44 {
float m[4][4];
__m128 row[4];
};
@galek
galek / EarlyZ.txt
Created October 27, 2015 04:28
EarlyZ on old hardware
http://www.gamedev.net/topic/622047-early-z/
@galek
galek / pbr.glsl
Created November 4, 2015 11:10
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@galek
galek / gist:1cebfb2dd6af67ac884b
Created November 14, 2015 06:49 — forked from bagobor/gist:4e1e0c47f6f6f014b5d5
Working multi-threading two-context OpenGL example with GLFW 3.0.3 and GLEW 1.8
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <cmath>
#include <cstdio>
#include <limits>
#include <chrono>
#include <thread>
#include <mutex>
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_EXT_gpu_shader4 : enable
uniform sampler2D u_texture;
uniform vec2 g_Resolution;
varying vec2 v_texCoords;