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: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 / 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 / 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;
include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
std::mutex mtx;
std::mutex mtx2;
std::condition_variable cv;
std::condition_variable cv2;
bool threadsRunning = false;
@galek
galek / imgui_node_graph_test.cpp
Created December 5, 2015 20:38 — forked from ocornut/imgui_node_graph_test.cpp
Node graph editor basic demo for ImGui
// Creating a node graph editor for ImGui
// Quick demo, not production code! This is more of a demo of how to use ImGui to create custom stuff.
// Better version by @daniel_collin here https://gist.github.com/emoon/b8ff4b4ce4f1b43e79f2
// See https://github.com/ocornut/imgui/issues/306
// v0.02
// Animated gif: https://cloud.githubusercontent.com/assets/8225057/9472357/c0263c04-4b4c-11e5-9fdf-2cd4f33f6582.gif
// NB: You can use math functions/operators on ImVec2 if you #define IMGUI_DEFINE_MATH_OPERATORS and #include "imgui_internal.h"
// Here we only declare simple +/- operators so others don't leak into the demo code.
static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
@galek
galek / Lua.cc
Last active January 28, 2016 02:56 — forked from alex-ac/Lua.cc
Lua C++ wrapper. C++11 templates street magic.
#include <Lua.hh>
extern "C" {
#include <lualib.h>
#include <lauxlib.h>
};
using namespace util;
int Lua::call(lua_State *vm) {