Skip to content

Instantly share code, notes, and snippets.

View texus's full-sized avatar

Bruno Van de Velde texus

View GitHub Profile
@texus
texus / physicalMonitorSizeFromHMONITOR.cpp
Created November 29, 2019 18:59
Finding physical screen size from HMONITOR using EDID
#include <Windows.h>
#include <SetupApi.h>
#include <cfgmgr32.h> // MAX_DEVICE_ID_LEN
#include <iostream>
#include <vector>
#include <string>
#include <map>
#pragma comment(lib, "setupapi.lib")
@texus
texus / toLower.cpp
Last active April 16, 2024 15:00
String to lowercase at compile time with with c++14
// This file contains code on how to convert a string to lowercase at compile time.
// A large part of the imlementation was taken from http://stackoverflow.com/a/15912824/3161376 which solved the problems that I had in the old implementation.
// The string struct will hold our data
// The declaration of our string struct that will contain the character array
template<char... str>
struct string
{
// The characters are immediately converted to lowercase when they are put in the array
@texus
texus / Transparent.cpp
Last active September 27, 2023 14:23
Translucent per-pixel alpha window on Windows
#include <SFML/Graphics.hpp>
#if _WIN32_WINNT < 0x0501
#define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
// Set part of the window that can be clicked by removing fully transparent pixels from the region
void setShape(HWND hWnd, const sf::Image& image)
{
@texus
texus / BindingAnyVariable.cpp
Last active August 29, 2015 14:12
Bind a function parameter without even knowing which variable you are going to bind (type has to be known in advance). A pointer to any variable is bound and dereferenced on the fly when calling the function.
#include <functional>
#include <iostream>
// The function that we are going to call, it just prints out the variable here.
// This function can even receive a reference to the variable and change it!
template <typename T>
void print(T& obj)
{
std::cout << obj << std::endl;
}