Skip to content

Instantly share code, notes, and snippets.

View blockspacer's full-sized avatar
:octocat:

Devspace blockspacer

:octocat:
  • Google
  • USA
View GitHub Profile
@blockspacer
blockspacer / Mutex.h
Created February 27, 2019 14:55 — forked from bstaletic/Mutex.h
Clang thread safety annotations
#ifndef BENCHMARK_MUTEX_H_
#define BENCHMARK_MUTEX_H_
#include <mutex>
// Enable thread safety attributes only with clang.
// The attributes can be safely erased when compiling with other compilers.
#if defined(__clang__) && (!defined(SWIG))
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
#else
@blockspacer
blockspacer / build-qt-wasm.sh
Created March 4, 2019 07:58 — forked from cajus/build-qt-wasm.sh
Building Qt for WebAssembly
# Get dependencies in place (example for Debian based systems)
sudo apt-get build-dep --yes qt5-default
sudo apt-get install --yes libxcb-xinerama0-dev git python cmake default-jre
# Install Emscripten
git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source emsdk_env.sh
@blockspacer
blockspacer / SingleFileOpenGLTex.cpp
Created March 26, 2019 07:58 — forked from mortennobel/SingleFileOpenGLTex.cpp
Single file OpenGL 3.3 / WebGL (using Emscripten) example with texture (SDL2 / SDL_Image 2)
//
// Compile for emscripten using
// emcc -Iinclude SingleFileOpenGLTex.cpp \
-O2 -std=c++14 -s TOTAL_MEMORY=33554432 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' --preload-file examples/data -s USE_SDL=2 -o html/SingleFileOpenGLTex.html
// where the following images must be located in a subfolder
// - examples/data/test.png
// - examples/data/cartman.png
// - examples/data/cube-negx.png
// - examples/data/cube-negz.png
//
// g++ `pkg-config cairo-ft --cflags --libs` -lglut main.cpp
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#ifdef _MSC_VER
#include <windows.h>
#include <cairo.h>
#pragma comment(lib, "cairo.lib")
@blockspacer
blockspacer / main.c
Created April 12, 2019 05:55 — forked from mochja/main.c
Yoga + OpenGL Example
#include <GLFW/glfw3.h>
#include <yoga/Yoga.h>
#include <stdlib.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
@blockspacer
blockspacer / enum_bitmask.hpp
Created April 18, 2019 15:53 — forked from StrikerX3/enum_bitmask.hpp
Type-safe enum bitmasks
/*
Type-safe enum class bitmasks.
Based on work by Andre Haupt from his blog at
http://blog.bitwigglers.org/using-enum-classes-as-type-safe-bitmasks/
To enable enum classes to be used as bitmasks, use the ENABLE_BITMASK_OPERATORS
macro:
enum class MyBitmask {
None = 0b0000,
One = 0b0001,
Two = 0b0010,
@blockspacer
blockspacer / glfw_ship.cpp
Created April 29, 2019 09:33 — forked from PatWie/glfw_ship.cpp
instructions to use skia and glfw together. (download, installation, first program). works on Linux and Windows.
/* Note: this Google copyright notice only applies to the original file, which has large sections copy-pasted here. my changes are under CC0 (public domain).
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/*
this is intended as a second-resort, after trying to build using the official instructions inevitably fails because of poor documentation and strange build systems.
@blockspacer
blockspacer / .htaccess
Created May 8, 2019 13:37 — forked from jgranick/.htaccess
SimpleGL
SetOutputFilter DEFLATE
@blockspacer
blockspacer / libpng_fix.md
Created May 22, 2019 08:54 — forked from bluenex/libpng_fix.md
fixing 'libpng warning: iCCP: known incorrect sRGB profile' appears in Pygame.

Libpng warning: iCCP: known incorrect sRGB profile.

Some .png images used in pygame may get the warning read as "libpng warning: iCCP: known incorrect sRGB profile". To solve this I have searched and found the solution by using ImageMagick. After installing, single file can be fixed by calling convert <in_img> -strip <out_img>, but to make it fixes every wanted images in path we'll need to modify just a little bit.

Create .bat file contains the following code and place this .bat in the folder that want to be fixed and run to finish it out.

@echo off
ping -n 2 127.0.0.1 > nul

echo this batch will convert ".png" using -strip option from ImageMagick.
@blockspacer
blockspacer / builder.cpp
Created July 18, 2019 08:03 — forked from pazdera/builder.cpp
Example of `builder' design pattern in C++
/*
* Example of `builder' design pattern.
* Copyright (C) 2011 Radek Pazdera
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,