Category: Blog
-
Does calling sqrtf always result in a single asm instruction?
I was recently running some performance benchmarks across different platforms to understand the cost of some simple mathematic functions such as sqrtf and quickly noticed, under certain circumstances compilers such as MSVC, Clang and GCC by default will not generate a single x86-64 sqrtss instruction, there is a little more to it… I think discovering…
-
Visualising SRGB & Gamma Correction
Introduction There are plenty of fantastic websites out there which explain the technicalities of Gamma Correction and SRGB colour correction so won’t try to do the same here. Instead this post is to show visually the effects of SRGB/Gamma Correction in image composition and how blending colours in SRGB space rather than linear space is…
-
Redirect all stdout/stderr to console
If your Windows executable is using /SUBSYSTEM:WINDOWS rather than /SUBSYSTEM:CONSOLE, something you will have noticed your output messages to stdout (printf, std::cout etc) will be missing. You can easily solve this however by spawning your own Windows console window and redirecting stdout to your new console. The code below will redirect all stdout & stderr…
-
Increase Windows Console Line Limit
If you’re in a situation where your console output text is being truncated because so many lines have been output, you may want to increase the limit. Increase Windows Console Text Limit With a console window already spawned, right click the top and go to properties: Increase the Screen Buffer Size Height. You will be…
-
Faster Compiling: Visual Studio Unity (Jumbo) Builds
Unity/Jumbo builds are a way of speeding up C/C++ compilation by compiling multiple c/cpp files as a single object file. Speed improvements can come from not having to re-parse and compile shared headers. Even in projects that use pre-compiled headers, there is an overhead of processing the pre-compiled header which can be avoided with Unity/Jumbo…
-
Programming a Digital Potentiometer (MCP4131) With Raspberry Pi & WiringPi
Github Link: https://github.com/comeradealexi/MCP4131 Datasheet One of the most important parts of programming an MCP is studying the datasheet provided with it. For the MCP4131, you can download it here: https://www.microchip.com/en-us/product/MCP4131 It will provide everything you need to know about the chip. One of the most basic pieces of information we’ll need to start with is…
-
Connecting to Raspberry Pi direct to PC via Ethernet
This article will show you how to connect directly to a Raspberry Pi by connecting an ethernet cable directly to your PC without needing to do any setup on the Raspberry Pi itself. This means you don’t need to plug a keyboard and monitor into your Pi to connect to it. Requirements: PC with ethernet…
-
C++ unique/shared ptr custom deleters
I’ve recently found the need for a custom deleter function attached to smart pointers in C++ and I found there are a number of different ways to implement this. I’ll touch on the advantages/disadvantages of the different ways to use custom deleters and the difference between unique and shared ptr. std::unique_ptr: The type of the…
-
Raspberry Pi/C++ Log Class
With having written many Raspberry Pi programs now, it made sense for me to create a little Log class which I’ve used in all my projects now which I feel is really quite nice to use and intuitive. In this post I’ll run through a few of its features. Source Code: https://github.com/comeradealexi/RaspberryPiShared One of the features…
-
Raspberry Pi – Home Monitoring System
Using multiple Raspberry Pis, I’ve put together a small system to monitor my home when away. In order to maintain my own privacy, I’ve set up a system which detects when myself or my partner is home by periodically pinging our phones IP addresses on the local WiFi network and disables recording/monitoring when either of…
-
Raspberry Pi – Web Controlled Media Player
Having a spare TV and a hard drive full of videos, I wanted to make it so I could easily watch videos from a hard drive on the TV and control playback and video choice entirely from my phone, this is what I set out to achieve with this project. The entire project can be…
-
lighttpd – Changing default user (Raspberry Pi)
After following the great tutorial here (http://www.penguintutor.com/linux/light-webserver) for getting lighttpd setup and running on my Raspberry Pi, I wanted to change the default user the service ran as so I could run commands from php scripts requiring more permissions. The part I got stuck on was that on a reboot, the folder in /var/run/lighttpd would…
-
std::mutex crash on initial lock (Interesting thread releated bug with fix included!)
Have been writing some code to test out creating worker threads in C++ and came across an interesting bug where my program would crash on the first lock of the mutex. Thought it was an interesting little problem to solve. Hint: Crash isn’t necessarily 100%… #include <stdio.h> #include <thread> #include <vector> #include <mutex> #include <atomic>…
-
Using Raspberry Pi to test Power Supply Reliability
I recently came across a problem with a friend whose computer was having strange issues of switching off entirely at random. We contacted the power supply support channels who suggested it sounded as if the surge protection on the motherboard was faulty, which I agreed with since in all my experience so far, I’ve never…
-
Problems with VisualGDB and Raspberry Pi 2
I followed the tutorial for setting up VisualGDB for a Raspberry Pi from this link: VisualGDB and below are some issues that I ran into and how I fixed them. Hope it helps! Compile Error: “bits/c++config.h: No such file or directory”: With this error, all you need to do is add the following include path to…
-
Steam Live gets a huge update.
Steam Live has received yet another huge update, this time adding some great new features and fixing some of those other little niggles! It’s an application that has been around for a while now and after a long stream of constant updates and improvements, it is bar far the best Steam Client for Windows Phone…
-
C#: Class Member variable called ‘type’ causes weird compile issues caused by AVAST Antivirus.
Problem: Try and use this class in any C# project and it won’t work, it will give errors after compiling that it can’t copy the exe/dll with the following errors codes (warning MSB3026: and error MSB3027: and error MSB3021:) Renaming the ‘type’ member variable to anything else causes it to compile and run perfectly. I tested this…
-
Windows Phone C#: “Layout cycle detected. Layout could not complete.” on LongListSelector Fix
Came across a very weird problem today that has occurred on my application Steam Live which I’ve never come across before… On a certain Steam Profile I’d get a crash with the following message: “Layout cycle detected. Layout could not complete.” After a lot of searching, confusion and everything else I’ve managed to find a…
-
Windows Phone 8.1 DirectX Sample Landscape mode broken / rotation doesn’t work.
The Problem: When the phone is in landscape mode, the rendered area isn’t rotated on screen! As you can see, the image on the right is when it is in portrait mode, the one below is when in landscape. The problem is caused by the following code in DeviceResources.cpp: Since the window size being created is…