Skip to content

Instantly share code, notes, and snippets.

View mosra's full-sized avatar

Vladimír Vondruš mosra

View GitHub Profile
@mosra
mosra / gist:6306943
Created August 22, 2013 13:14
The joy of backporting C++11 code to GCC 4.5
/home/mosra/Code/magnum/src/DebugTools/Implementation/CapsuleRendererTransformat
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
@mosra
mosra / magnum-repl.md
Last active December 18, 2015 07:39
Clang-based in-game "REPL" console

Clang-based in-game "REPL" console

Goals

  • Use as much existing functionality as possible for implementation
  • No new APIs, no new language bindings
  • Use Clang for state-of-the-art C++11 support and diagnostics
  • Keep It Simple, Stupid
@mosra
mosra / README.md
Last active April 11, 2023 03:16
Most Obscure Features of C++
void RigidBodyGroup::physicsStep(GLfloat timeDelta) {
for(RigidBody* body: bodies) {
/* Compute force at current position */
body->force = _gravity;
body->physicsStep();
GLfloat accelerationHalfTimeDelta = (body->force/(body->_mass*2))*timeDelta;
/* New position */
body->transformation()[3].setXyz(body->transformation()[3].xyz() + (body->velocity + accelerationHalfTimeDelta)*timeDelta);
@mosra
mosra / gist:2629906
Created May 7, 2012 19:42
Attribute-less vertex shader
#version 330
uniform mat4 transformationMatrix;
uniform mat4 projectionMatrix;
out vec2 texCoord;
const vec2 data[4] = vec2[](
vec2(-1.0, 1.0),
vec2(-1.0, -1.0),
@mosra
mosra / benchmark.cpp
Created January 16, 2012 23:21
Tipsify benchmark
queue<unsigned int> cache;
unordered_set<unsigned int> map;
size_t misses = 0;
size_t maxSize = 24;
for(unsigned int index: builder.indices()) {
if(map.find(index) != map.end()) continue;
/* Not in cache */
++misses;
@mosra
mosra / Big.h
Created December 27, 2011 16:00
#ifndef BigFoot_Big_h
#define BigFoot_Big_h
#include <string>
#include <algorithm>
#include "TypeTraits.h"
#include "BigPrivate.h"
/** @brief BigFoot, aribitrary length integer library */
@mosra
mosra / Bourne.cpp
Created November 21, 2011 22:26
Bourne, a JSON parser library
#include "Bourne.h"
#define forever for(;;)
using namespace std;
namespace Bourne {
void AbstractValue::ignorespace(istream& in) {
while(isspace(in.peek()))
@mosra
mosra / fullheight.html
Created September 6, 2011 18:34
Nested table layouts with enabled elasticity
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- kate: indent-width 1 -->
<!--
State:
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- FF, Webkit, Opera: OK
- IE8, IE9: takes height: 100% as 100% viewport height, thus enabling
unnecessary scrollbar.
(no doctype)
@mosra
mosra / scrollarea.html
Created August 31, 2011 18:55
Flexible height scroll area
<html>
<body>
<style>
.scrollable {
height: 100%;
overflow: auto;
}
html, body {
min-height: 100%;
margin: 0px;