Skip to content

Instantly share code, notes, and snippets.

@bagobor
bagobor / edtaa3func.h
Created March 7, 2018 06:59 — forked from Flix01/edtaa3func.h
A Signed Distance Font Builder for Dear ImGui
/*
* edtaa3()
*
* Sweep-and-update Euclidean distance transform of an
* image. Positive pixels are treated as object pixels,
* zero or negative pixels are treated as background.
* An attempt is made to treat antialiased edges correctly.
* The input image must have pixels in the range [0,1],
* and the antialiased image should be a box-filter
* sampling of the ideal, crisp edge.
@bagobor
bagobor / carray_streambuf.hpp
Created January 20, 2016 13:41
std::streambuff derived class for mem optimisations
class carray_streambuf : public std::streambuf {
public:
carray_streambuf(char *data, unsigned int len) {
setp(data, data+len);
setg(data, data, data + len);
}
// amount of stored (written!) data in bytes
size_t saved_bytes() const { return pptr() - pbase(); }
};
@bagobor
bagobor / lua_chunk.hpp
Created December 5, 2015 19:00
lua chunk
#pragma once
#include <string>
#include <lua/lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/detail/policy.hpp>
#include <luabind/out_value_policy.hpp>
#include <luabind/operator.hpp>
@bagobor
bagobor / vsync.txt
Created December 2, 2015 05:36 — forked from dwilliamson/vsync.txt
Windows vsync
VSync under Windows, revisited
http://www.virtualdub.org/blog/pivot/entry.php?id=157
Windowed mode, vsync stutter, DWM (Vista+)
http://armageddongames.net/showthread.php?96793-Windowed-mode-vsync-stutter-DWM-(Vista-)
DwmFlush function
https://msdn.microsoft.com/en-us/library/windows/desktop/dd389405(v=vs.85).aspx
Bug 856427 - Add vsync support on windows
@bagobor
bagobor / gist:4e1e0c47f6f6f014b5d5
Created November 13, 2015 07:34 — forked from Madsy/gist:6980061
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>
@bagobor
bagobor / build.log
Created September 9, 2015 12:31
lua-api-pp b build errors
1>------ Build started: Project: libluapp, Configuration: Debug Win32 ------
1> impl.cpp
1>d:\dev\github\lua-api-pp\luapp\lua_operations.hxx(118): error C2977: 'lua::_::Lazy': too many template arguments
1> d:\dev\github\lua-api-pp\luapp\lua_lazy.hxx(61): note: see declaration of 'lua::_::Lazy'
1> d:\dev\github\lua-api-pp\luapp\lua_operations.hxx(193): note: see reference to class template instantiation 'lua::_::lazyConcat<VT11,VT12>' being compiled
1>d:\dev\github\lua-api-pp\luapp\lua_operations.hxx(206): error C2977: 'lua::_::Lazy': too many template arguments
1> d:\dev\github\lua-api-pp\luapp\lua_lazy.hxx(61): note: see declaration of 'lua::_::Lazy'
1> d:\dev\github\lua-api-pp\luapp\lua_operations.hxx(272): note: see reference to class template instantiation 'lua::_::lazyArithmetics<T1,T2,op>' being compiled
1>d:\dev\github\lua-api-pp\luapp\lua_valueset.hxx(380): error C2572: 'lua::Valset::Valset': redefinition of default argument: parameter 1
1> d:\dev\github\lua-api-pp\luapp\lua_valueset.hxx(376):
@bagobor
bagobor / chaiscript_test.cpp
Last active September 3, 2015 09:30
chaiscript test
#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>
bool test(int* data) {
int &i = *data;
i = i + 2;
return true;
}
int _tmain(int argc, _TCHAR* argv[])
@bagobor
bagobor / selene_test.cpp
Last active September 3, 2015 08:20
[visual studio 2015]Selene error
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
struct SimpleVec2
{
float x, y;
@bagobor
bagobor / gist:d4b2bc1384cea95ed52a
Created June 14, 2015 00:07
Value/ID Handle class C++11 way
#include <algorithm>
#include <utility>
#include <iostream>
#include <memory>
struct Handle {
Handle (int val) : m_handl((int*)(void*)val, EmptyDeleter) { }
Handle(Handle&& src) : m_handl(std::move(src.m_handl)) {}
Handle(const Handle& that) = delete;