Skip to content

Instantly share code, notes, and snippets.


Vladimír Vondruš mosra

View GitHub Profile
mosra /
Last active May 20, 2021 — forked from ColCh/
Git pre-push hook to confirm pushing to master

Git pre-push hook

Checks if the remote branch is master, then asks a confirmation. Based on, but modified to check the remote name instead of local, making it work also for the really dangerous accidents like below:

git push -f origin e09b7418a310114f6aaf495f969c3859095a99af:master

Further info:,,,

View sdl-setwindowtitle.cpp
// g++ -std=c++11 sdl-setwindowtitle.cpp -lSDL2
#include <SDL2/SDL.h>
int main() {
SDL_Window* w = SDL_CreateWindow(
/* If you flip this, SDL_SetWindowTitle() below starts working */
#if 1
mosra / main.cpp
Created Mar 21, 2019
Triangle, but windowless
View main.cpp
#include <Magnum/DebugTools/Screenshot.h>
#include <Magnum/GL/Buffer.h>
#include <Magnum/GL/Framebuffer.h>
#include <Magnum/GL/Mesh.h>
#include <Magnum/GL/Renderbuffer.h>
#include <Magnum/GL/RenderbufferFormat.h>
#include <Magnum/Platform/WindowlessEglApplication.h>
#elif defined(CORRADE_TARGET_IOS)
#include <Magnum/Platform/WindowlessIosApplication.h>
mosra / main.cpp
Last active Feb 24, 2019
First Triangle in Vulkan
View main.cpp
#include <Corrade/Utility/Assert.h>
#include <Corrade/PluginManager/Manager.h>
#include <Magnum/Magnum.h>
#include <Magnum/ImageView.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Trade/AbstractImageConverter.h>
#include <MagnumExternal/Vulkan/flextVk.h>
#include <MagnumExternal/Vulkan/flextVkGlobal.h>
mosra / diff.patch
Created Oct 18, 2016
Quick'n'dirty NV conservative raster support
View diff.patch
diff --git a/src/MagnumExternal/OpenGL/GL/extensions.txt b/src/MagnumExternal/OpenGL/GL/extensions.txt
index 82b268d..18e158d 100644
--- a/src/MagnumExternal/OpenGL/GL/extensions.txt
+++ b/src/MagnumExternal/OpenGL/GL/extensions.txt
@@ -34,3 +34,5 @@ extension KHR_texture_compression_astc_hdr optional
extension KHR_blend_equation_advanced optional
extension KHR_blend_equation_advanced_coherent optional
extension KHR_no_error optional
+extension NV_conservative_raster optional
mosra /
Created May 25, 2015
Voldemort types in C++14

Inspired with real D language feature:

Compile in GCC/Clang with -std=c++14.

#include <iostream>
#include <typeinfo>

auto eh() {
	struct Voldemort {
mosra /
Last active Aug 29, 2015
Compile-time matrix/vector computations in Magnum

Magnum now has compile-time matrix/vector library. With full C++14 support in Clang 3.4 you can throw out nearly all manual precomputations, just slap constexpr on the result and be done with it:

#include <Magnum/Magnum.h>
#include <Magnum/Math/Matrix4.h>

using namespace Magnum;

int main() {
    constexpr auto a = Matrix4::scaling(Vector3::xScale(3.0f))*
mosra /
Last active Dec 17, 2017
cosi, minimal stuff for easier soci + picojson usage


First, create the named tuple from list of cosi::field instances. First parameter is name in resulting JSON, second is optional field name in SQL query. If not used, the same name is used for both JSON and SQL.

auto t = cosi::make(
    cosi::string_f  {"data"},
    cosi::int_f     {"integerData", "COUNT(data)"},
    cosi::double_f  {"moreData", ""}
mosra / CMakeLists.txt
Created Nov 1, 2013
Very simple 2D scenegraph example. Based on `scenegraph2D` branch of and `triangle` example at
View CMakeLists.txt
find_package(Magnum REQUIRED
add_executable(MyApplication MyApplication.cpp)
mosra / gist:6306943
Created Aug 22, 2013
The joy of backporting C++11 code to GCC 4.5
View gist:6306943
ion.h:62: error: could not convert ‘{{Magnum::Math::Matrix3< <template-parameter
-1-1> >::translation [with T = float](((const Magnum::Math::Vector2<float>&)((co
nst Magnum::Math::Vector2<float>*)(&((const Magnum::Vector2*)a)->Magnum::Math::V
ector2< <template-parameter-1-1> >::operator+ [with T = float](((const Magnum::M
ath::Vector<2ul, float>&)((const Magnum::Math::Vector<2ul, float>*)(& capDistanc
e.Magnum::Math::Vector2<float>::<anonymous>)))))))).Magnum::Math::Matrix3< <temp
late-parameter-1-1> >::operator* [with T = float](((const Magnum::Math::Matrix<3
ul, float>&)(& rotationScaling.Magnum::Math::Matrix3<float>::<anonymous>))), Mag
num::Math::Matrix3< <template-parameter-1-1> >::translation [with T = float](((c