[{"content":"Should you always throw more threads at a problem to try and make it faster? As with so many problems in computing the answers is often “It Depends”. In this post, I will explore the effect of increasing thread usage in a program who’s workload is heavily bottlenecked by memory performance. I will explore how the data corresponds with hardware cache sizes on the CPU as well as some methods to improve the problem (or make them worse). We will also explore how adjusting thread affinity can impact the results.\nTest Setup ⚙️ The workload I’ll be measuring performance on is a simple loop iterating over a linked list of varying sizes until it reaches the end on a contiguous block of allocated memory. This means our loop will be accessing the memory linearly which is optimal and we’ll be running the test many times and averaging the results. We are expecting smaller sized workloads to run faster because our block of memory will remain in the CPU caches and then performance to deteriorate for larger workloads as we exceed the cache sizes.\nThe test results here are from benchmarks on a Raspberry Pi 3 running an ARM Cortex-A53 clocked at 1.2 GHz.\nBelow is a report of the cache layout of our hardware from hwloc/lstopo. It highlights that we have 4 cores each with a 32KiB L1 data cache and all 4 cores share a 512KiB L2 cache. There is no L3 cache.\nMachine (906MB total) Package L#0 NUMANode L#0 (P#0 906MB) L2 L#0 (512KB) L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0 + PU L#0 (P#0) L1d L#1 (32KB) + L1i L#1 (32KB) + Core L#1 + PU L#1 (P#1) L1d L#2 (32KB) + L1i L#2 (32KB) + Core L#2 + PU L#2 (P#2) L1d L#3 (32KB) + L1i L#3 (32KB) + Core L#3 + PU L#3 (P#3) Single Thread Performance Results Lets start with a set of single threaded results to get an idea of baseline performance. The results here align with our expectations and we can see how performance drops once we exceed L1 and L2 cache sizes. The results here align with graphs you’ll find in the excellent paper “What Every Programmer Should Know About Memory”.\nPeak single threaded speed is around 6000 MiB/s iterating over a 16KiB buffer and performance starts to tail off once we’re exactly matching the L1 cache size of 32 KiB. We see this same pattern for the L2 cache, maximum speed of about 5250 MiB/s around 256 KiB and falling off as we meet our L2 cache size exactly at 512 KiB. After this, performance plummets and subsequent data sizes are constant at around 2000 MiB/s as the data sizes far exceed the caches and we are spending majority of our time waiting for main memory.\nIntroducing More Threads 🧵 Now for the interesting part, lets see what happens when we introduce more threads, each working on their own unique workload. For example, in our 16KiB test, each thread will have its own, unique 16KiB piece of memory allocated which it is going to be processing. What I’m interested to explore here is whether, in a situation which is heavily bound by memory bandwidth, whether introducing more threads can improve performance.\nWe’ll start by focussing on our most optimal single threaded test which processed 16KiB at over 6000 MiB/s.\nThe chart here is showing the sum of the speed of data processed by each thread. The results here area really positive, our performance has scaled just about perfectly across all cores. The ~6000MiB/s single threaded performance scales with each additional thread we have introduced and each thread is independently processing data at ~6000MiB/s This is what we were hoping for with a test processing just 16KiB because we know from our hardware specs that this amount of data should comfortable fit and remain in the L1d cache of each thread.\nI also ensure here that each thread has its affinity locked to a single core to prevent the chance of the OS scheduling them across different cores while running and accessing a different L1d cache.\nIncreasing Data Sizes So lets see if this pattern we’ve seen here will continue as we increase the amount of data we process. The chart below shows increasing memory test size and how overall performance changes between 1 and 4 threads. Remember, the MiB/s we’re looking at in these results is the total amount of data we are processing across all threads.\nIt’s clear right away that the doubling of performance with each thread we see with 16KiB data size quickly starts to diminish. Lets start by analysing what we see with the 64 KiB test. With the 64KiB test, we initially see a doubling of performance up until 3 threads and then see a much smaller increase at 4 threads. This isn’t necessarily what we would have expected though because our hardware has a 512KiB L2 cache and we’re only processing 64KiB per thread (64KiB x 4 = 256KiB) so this should comfortable fit within the L2 cache.\n64KiB Analysis\nLet’s dig in to the 64KiB performance falloff a little deeper. We’ll do this by using perf, a Linux tool that allows us to easily collect hardware event statistics which will give us a better insight to what’s actually happening at the hardware level.\nWe’ll focus on hardware events that will tell us the following:\nNumber of instructions executed per-cycle Percentage of L1 cache misses Percentage of L2 cache misses Percentage of cycles waiting on memory read operations (ld_dep_stall) Metric 1 Thread 2 Threads 3 Threads 4 Threads Instructions Per Cycle 0.90 0.89 0.83 0.71 L1 Cache Refill Percent 1.6% 1.5% 1.9% 1.9% L2 Cache Refill Percent 0.0014% 0.0017% 0.0022% 0.0046% Percent Cycles ld_dep_stall 10% 11% 17% 29% Lets focus on the L1 and L2 cache refill/miss percentages to start with. It’s clear immediately that the percentages are incredibly low and the kind of increase we see between 1 and 4 threads is unlikely to explain the large drop off in performance we have observed. We already know that our entire test should comfortable fit entirely within the L2 cache.\nThe number of cycles stalled on ld_dep_stall is where things really get interesting and we see a significant increase from 10% and 11% with one and two threads, then an increase to 17% with 3 threads and a sharp increase to 28% with 4. The pattern we’ve observed here feels like it matches the drop off in performance that we see in the test results. 3 threads isn’t quite 3x the performance of 1 thread, and then 4 threads is even further off.\nSo what does ld_dep_stall actually mean? perf defines this metric as the following:\nCycles there is a stall in the Wr stage because of a load miss. Unit: armv8_cortex_a53\nOur test is almost exclusively making load requests, so it’s not surprising this is the pipeline that is stalling. But why are our tests performing worse, when we’ve mentioned before that our tests fit comfortably within L2 cache… Unfortunately I cannot find any hard evidence to tell me explicitly what is going on through more detailed hardware events but what I believe is happening is we’re pushing and processing so much memory at this point we’re stressing the bandwidth between the L1 and L2 caches. We observed in the 16KiB test, which fits entirely within L1 cache that we saw a perfect multiplying of performance as we increased more threads. The unique situation with our 64KiB test is we’re now exceeding the L1 cache, so our tests are now constantly fetching memory from L2 in to L1.\nThe great writeup on Chips and Cheese suggests with the A53, all cores \u0026amp; L1 communicate with L2 via a shared data path so could become congested. As I don’t have any hard evidence to support this, I cannot guarantee this is the cause. I explored other hardware metrics such as TLB and cache snooping events but I couldn’t find anything that matched up with the kind of performance increase we observed. I feel if this is the cause, it may be showing due to my tests here perhaps being a worst-case scenario, where every thread is doing nothing but making read requests and very little else. We’re really maxing out the L1 and L2 memory systems on the chips and perhaps what I’ve observed here is a bottleneck between L1 and L2 in this situation. If anyone could shed more light on the situation here, I’d love to talk further about it.\n128KiB to 2048KiB Analysis\nTaking a look beyond the 64KiB tests, the results start to show different patterns. The one that really stands out to me right away is the 512KiB test. This test aligns exactly with the size of the L2 cache and as we introduce more threads, our overall performance starts to deteriorate. What we’re seeing here is all 4 threads competing for L2 cache space and completely thrashing it, to the point where introducing more threads has overall made our tests slower. With this test, we’d be better off having 1 thread run the 512KiB test 4 times sequentially than distributing the work across 4 separate cores! It’s a really important lesson to be taken here when optimising workloads: throwing more threads at a problem is not always the answers and in some cases, could actually make performance even worse.\nThen if we move to the 2048KiB test scenario, performance is roughly equivalent whether we use 1 thread or 4. While in this situation, we haven’t made performance worse by introducing more threads, all we’ve really done is decrease the effect work each thread is doing and possibly increased power consumption! If we had workloads which were not memory intensive, then these would be better candidates to run in parallel with a memory intensive workload.\nAdjusting Thread Affinity In all of the test scenarios above, each thread has been locked to a unique core. I also ran tests which allowed our threads to use any core (each thread has an affinity mask of 0b1111/0xf) and the results were almost identical to the situation when I ran with a locked core. I believe that due to my artificial workload, the thread scheduler was doing a good job of keeping the each thread running on a unique core and didn’t allow them to context switch between cores while the tests were running. I would expect this to potentially be a different situation in a real world scenario, if there are competing threads and regular context switches.\nRaspberry Pi power throttling ⚡ An important problem to watch out for with the Raspberry Pi (and one which I initially fell for) is the the impact of having an insufficient power supply. The Raspberry Pi 3 I’ve used for these benchmark requires at least a 2.5A power supply, but the one I was using was a 2.0A. Initially my results seemed consistent but as I introduced more threads and larger data sizes and the system was under more load, I started to find performance quickly drop off. We can run the command vcgencmd get_throttled to query whether the system is currently throttled or has ever been throttled. The chart below compares the 2.0A and 2.5A power supplies.\nClosing Thoughts I think one of the main takeaways from these tests is that throwing more threads at a problem isn’t always the option. We’ve shown in fact that in certain scenarios, more threads can actually degrade overall performance so the most important thing to do is measure!\n","permalink":"https://alexanderhoughton.co.uk/uncategorized/%F0%9F%93%8A-evaluating-threading-performance-relationship-with-memory-bandwidth-cpu-caches-arm-cortex-a53/","summary":"Should you always throw more threads at a problem to try and make it faster? As with so many problems in computing the answers is often “It Depends”. In this post, I will explore the effect of increasing thread usage in a program who’s workload is heavily bottlenecked by memory performance. I will explore how […]","title":"📊 Evaluating Threading Performance Relationship With Memory Bandwidth \u0026 CPU Caches (ARM Cortex-A53)"},{"content":"As my first foray into CUDA programming I set myself a challenge to experiment with different methods of finding the total sum of a large array of numbers, trying different strategies exposed via CUDA to see how different approaches compare and what comes out fastest. A lot of my GPU experience previously on PC has been through DirectX 12 or Vulkan so this felt like a good opportunity to see how programming CUDA compares for a non-graphics or games related workload.\nSource Code: https://github.com/comeradealexi/CUDAParallelAddBenchmarks/blob/main/kernel.cu\nTest Setup Each test reads from a large array of integers, adding every entry together and returning the sum. Given the parallel nature of GPUs, we use the atomicAdd function to allow separate threads and blocks to increment the final output value.\nFor the various test scenarios which are detailed below, we will run with a suite of different block sizes as well as the number of values each thread processes from the input array in an attempt to find the most optimal setup. Block sizes will differ from 32 up to 1024 which has an effect on occupancy as well as the tests involving shared memory.\nMy expectation is that we’ll get faster results as we reduce the number of times we call atomicAdd, however this isn’t quite what my results find.\nWith the specific test scenarios below, we will run with the following setups:\n512MiB Buffer \u0026amp; 1 Kernel Run 4 MiB Buffer \u0026amp; 64/128 Kernel Runs I wanted to test the difference in the results between a very large buffer as well as a small kernel accessed multiple times to ensure I observe the difference in the memory speed overhead. I’m expecting that the 4MiB buffer tests, ran multiple times will remain in the GPU caches and better tests how the code is performing, while I expect the very large buffers to have memory access overheads, potentially resulting in differing results.\nNote: In order to ensure stable GPU frequencies, these tests have been run with the following enabled: nvidia-smi -lgc 2800\nTest Scenarios Scenario 1: Atomic Add Per Value Per Thread\nHere to demonstrate a suboptimal setup, here we call atomicAdd on every value we loop over per thread.\ntemplate\u0026lt;unsigned int VALUES_PER_THREAD\u0026gt; __global__ void Add_AtomicPerValuePerThread(int* output, const int* input) { const unsigned int workIndex = (threadIdx.x + (blockDim.x * blockIdx.x)) * VALUES_PER_THREAD; for (unsigned int i = 0; i \u0026lt; VALUES_PER_THREAD; i++) { int value = input[workIndex + i]; atomicAdd(\u0026amp;output[0], value); } } Scenario 2: Atomic Add Per Thread\nHere we calculate our thread total and call atomicAdd only once per thread.\ntemplate\u0026lt;unsigned int VALUES_PER_THREAD\u0026gt; __global__ void Add_AtomicPerThread(int* output, const int* input) { const unsigned int workIndex = (threadIdx.x + (blockDim.x * blockIdx.x)) * VALUES_PER_THREAD; int total = 0; for (unsigned int i = 0; i \u0026lt; VALUES_PER_THREAD; i++) { total += input[workIndex + i]; } atomicAdd(\u0026amp;output[0], total); } Scenario 3: Reduce Add Sync – Atomic Add Per Warp (32 Threads)\nHere we introduce the __reduce_add_sync function which sums the ‘total’ value from all threads in a warp (32 threads) and returns the same value to all threads. Then we only call atomicAdd once per warp. This means we call atomicAdd 32x less overall.\nIn order to use the wave intrinsic function __reduce_add_sync I had to ensure Code Generation was set to: compute_80,sm_80\ntemplate\u0026lt;unsigned int VALUES_PER_THREAD\u0026gt; __global__ void Add_ReduceAddSyncPerWarp(int* output, const int* input) { const unsigned int workIndex = (threadIdx.x + (blockDim.x * blockIdx.x)) * VALUES_PER_THREAD; int total = 0; for (unsigned int i = 0; i \u0026lt; VALUES_PER_THREAD; i++) { total += input[workIndex + i]; } // Sum of all 32 threads in a given warp int blockTotal = __reduce_add_sync(0xFFFFFFFF, total); // First of every 32 threads atomically increments final output if ((threadIdx.x \u0026amp; 31) == 0) { atomicAdd(\u0026amp;output[0], blockTotal); } } Scenario 4: Atomic Add To Shared Memory – Atomic Add Per Block\nHere every thread in the block atomically increments shared memory, then 1 thread from the block does a final atomic increment. This means we only have 1 atomicAdd per block.\ntemplate\u0026lt;unsigned int VALUES_PER_THREAD\u0026gt; __global__ void Add_AtomicSharedPerThread(int* output, const int* input) { __shared__ int sharedData; if (threadIdx.x == 0) { sharedData = 0; } __syncthreads(); const unsigned int workIndex = (threadIdx.x + (blockDim.x * blockIdx.x)) * VALUES_PER_THREAD; int total = 0; for (unsigned int i = 0; i \u0026lt; VALUES_PER_THREAD; i++) { total += input[workIndex + i]; } atomicAdd(\u0026amp;sharedData, total); __syncthreads(); if (threadIdx.x == 0) { atomicAdd(\u0026amp;output[0], sharedData); } } Scenario 5: Add To Shared Memory Array – Atomic Add Per Block\nHere instead of atomically incrementing a single shared data between threads, each increments its own shared value. Then the final thread loops over this and sums them. We expect this to potentially be inefficient because we rely on a single thread from the entire block to do a lot of processing while other threads are idle.\ntemplate\u0026lt;unsigned int VALUES_PER_THREAD\u0026gt; __global__ void Add_SharedUniqueEntryPerThread(int* output, const int* input) // Global atomic increments = Total Threads / Block Size { constexpr int SHARED_DATA_LENGTH = 1024; __shared__ int sharedData[SHARED_DATA_LENGTH]; const unsigned int workIndex = (threadIdx.x + (blockDim.x * blockIdx.x)) * VALUES_PER_THREAD; int total = 0; for (unsigned int i = 0; i \u0026lt; VALUES_PER_THREAD; i++) { total += input[workIndex + i]; } sharedData[threadIdx.x] = total; __syncthreads(); if (threadIdx.x == 0) // First thread in the block loops over all shared data. { int blockTotal = 0; for (int i = 0; i \u0026lt; blockDim.x; i++) { blockTotal += sharedData[i]; } atomicAdd(\u0026amp;output[0], blockTotal); } } Scenario 6: Shared Memory Array + Reduce Add Sync + Atomic Add Per Block\nHere we combine the features of all the other tests by using shared memory and __reduce_add_sync\ntemplate\u0026lt;unsigned int VALUES_PER_THREAD, unsigned int BLOCK_SIZE\u0026gt; __global__ void Add_SharedWithReduceAddSyncPerWarp(int* output, const int* input) // Global atomic increments = Total Threads / Block Size { constexpr int SHARED_DATA_LENGTH = (BLOCK_SIZE / 32) \u0026gt; 0 ? (BLOCK_SIZE / 32) : 1; __shared__ int sharedData[SHARED_DATA_LENGTH]; const unsigned int workIndex = (threadIdx.x + (blockDim.x * blockIdx.x)) * VALUES_PER_THREAD; int total = 0; for (unsigned int i = 0; i \u0026lt; VALUES_PER_THREAD; i++) { total += input[workIndex + i]; } int warpTotal = __reduce_add_sync(0xFFFFFFFF, total); if ((threadIdx.x \u0026amp; 31) == 0) // Each warp sums all threads in that warp. { // Divide by warp count sharedData[threadIdx.x / 32] = warpTotal; } __syncthreads(); if (threadIdx.x == 0) { int blockTotal = 0; for (unsigned int i = 0; i \u0026lt; SHARED_DATA_LENGTH; i++) { blockTotal += sharedData[i]; } atomicAdd(\u0026amp;output[0], blockTotal); } } Results As you would expect, given the number of test scenarios, the differing combinations of block/grid sizes as well as our differing memory sizes, I’ve ended up with a lot of data. I’ll try to share it and analyse it in parts where the results really stood out to me.\nResults have been collected on an Nvidia RTX 5060 running on Windows 11 with CUDA 13.2.1. Below are the device capabilities for the Nvidia RTX 5060:\nDevice 0: Name: NVIDIA GeForce RTX 5060 WarpSize: 32 MaxThreadsPerBlock: 1024 MaxGridSize(X): 2147483647 MaxGridSize(Y): 65535 MaxGridSize(Z): 65535 MaxThreadsDim(X): 1024 MaxThreadsDim(Y): 1024 MaxThreadsDim(Z): 64 SharedMemPerBlock: 49152 SharedMemPerMultiprocessor: 102400 MaxThreadsPerMultiProcessor: 1536 MaxBlocksPerMultiProcessor: 24 MultiProcessorCount: 30 SMCount: 30 MinSMPartitionSize: 8 SMCoscheduledAlignment: 8 WQConcurrencyLimit: 8 512MiB x 1 Results: Comparing tests with same block sizes:\nHere we are comparing all 6 of our test scenarios with the same block and grid sizes, so each test issues exactly the same number of threads. All of these test scenarios achieve a potential occupancy of 100%.\nThe part that surprised me here is just how close majority of these results are in terms of performance, especially the first three results. Add_AtomicPerThread does 512 global atomic increments per block and it’s performing better than several tests which do fewer global atomic increments.Add_AtomicPerValuePerThread is the outlier here, with such a large number of atomic increments per thread, showing an 80% increase in performance compared to our fastest scenario.\nTest \u0026lt; ValuesSummedPerThread, BlockSize \u0026gt; Average Time (ms) Global Memory Atomic Increments Per Block Add_AtomicSharedPerThread \u0026lt; 16, 512 \u0026gt; 5.1212 1 (Shared Memory Atomic Increments Per Block = 512) Add_AtomicPerThread \u0026lt; 16, 512 \u0026gt; 5.1213 512 Add_SharedUniqueEntryPerThread \u0026lt; 16, 512 \u0026gt; 5.2586 1 Add_SharedWithReduceAddSyncPerWarp \u0026lt; 16, 512 \u0026gt; 5.3104 1 Add_ReduceAddSyncPerWarp \u0026lt; 16, 512 \u0026gt; 5.6654 16 (Increment per warp which is 32 threads) Add_AtomicPerValuePerThread \u0026lt; 16, 512 \u0026gt; 9.1421 8,192 How occupancy affects results:\nFocusing in on the Add_AtomicPerThread scenario, it’s quite clear here how not achieving full occupancy is having a detrimental effect on the test results, to the point where the time is more than doubled when comparing 100% to 50% occupancy. This suggests that each SM is spending time idle, likely waiting for memory operations to complete and cannot spend that time processing more warps due to the tests not achieving full occupancy.\nTest \u0026lt; ValuesSummedPerThread, BlockSize \u0026gt; Average Time (ms) Occupancy Add_AtomicPerThread \u0026lt; 1, 32 \u0026gt; 20.0118 50% Add_AtomicPerThread \u0026lt; 1, 128 \u0026gt; 8.4007 100% Add_AtomicPerThread \u0026lt; 1, 512 \u0026gt; 8.4272 100% Add_AtomicPerThread \u0026lt; 1, 1024 \u0026gt; 10.7840 66.7% 4MiB x 64 Results: With the 4MiB tests, where each scenario is run 64 times back to back, we are expecting very different results to the single 512MiB tests because we expect the input memory to always remain within the GPU caches, so less time is spent waiting on memory operations. We’ll start by comparing the fastest results for each test scenario:\nTest \u0026lt; ValuesSummedPerThread, BlockSize \u0026gt; Average Time (ms) Global Memory Atomic Increments Per Block Add_AtomicSharedPerThread \u0026lt; 4, 128 \u0026gt; 0.8802 1 (Shared Memory Atomic Increments Per Block = 128) Add_SharedWithReduceAddSyncPerWarp \u0026lt; 4, 128 \u0026gt; 0.9538 1 Add_ReduceAddSyncPerWarp \u0026lt; 8, 64 \u0026gt; 1.0817 2 (Increment per warp which is 32 threads) Add_SharedUniqueEntryPerThread \u0026lt; 4, 128 \u0026gt; 1.1001 1 Add_AtomicPerThread \u0026lt; 8, 512 \u0026gt; 1.1047 512 Add_AtomicPerValuePerThread \u0026lt; 1, 512 \u0026gt; 4.1136 512 The results here align more with our initial expectations where the performance scales with the number of atomic increments per thread. But the difference is only small, comparing the fastest Add_AtomicSharedPerThread to to Add_AtomicPerThread, there are 512x more global atomic increments per thread, but performance is only 1.25x slower.\nImportance of keeping the GPU saturated\nThe results below show the how increasing the amount of work done per-thread decreases performance. Each SM on the GPU is designed to have many blocks assigned to it, ready to execute when other threads become blocked in order to keep the GPU constantly working. If there aren’t enough threads available to the SMs, we just end up wasting performance.\nTest \u0026lt; ValuesSummedPerThread, BlockSize \u0026gt; Average Time (ms) Total Threads Add_AtomicSharedPerThread\u0026lt; 4, 512\u0026gt; 2.2088 131,072 Add_AtomicSharedPerThread\u0026lt; 8, 512\u0026gt; 2.2291 65,536 Add_AtomicSharedPerThread\u0026lt; 16, 512\u0026gt; 4.1010 32,768 Add_AtomicSharedPerThread\u0026lt; 32, 512\u0026gt; 7.9956 16,384 Add_AtomicSharedPerThread\u0026lt; 64, 512\u0026gt; 8.7155 8,192 Add_AtomicSharedPerThread\u0026lt; 128, 512\u0026gt; 10.8872 4,096 Add_AtomicSharedPerThread\u0026lt; 256, 512\u0026gt; 14.6373 2,048 Add_AtomicSharedPerThread\u0026lt; 512, 512\u0026gt; 13.9761 1,024 Add_AtomicSharedPerThread\u0026lt; 1024, 512\u0026gt; 26.4963 512 Add_AtomicSharedPerThread\u0026lt; 2048, 512\u0026gt; 51.9823 256 Add_AtomicSharedPerThread\u0026lt; 4096, 512\u0026gt; 102.4490 128 Add_AtomicSharedPerThread\u0026lt; 8192, 512\u0026gt; 199.3275 64 Add_AtomicSharedPerThread\u0026lt; 32768, 128\u0026gt; 198.4756 16 Many of the other tests show similar patterns to the above as we increase the amount of work per-thread but often there is a sweet spot. Take a look at the results below, the fastest test is when we are processing 8 values per thread, anything above or below this is slower. Like with many things, it really is a delicate balancing act when you are trying to find the most optimal performance setup. We need to spawn enough threads to keep the GPU saturated, but the sweet spot here is where we can keep the GPU fully saturated but allow each thread to do as much work as possible.\nTest \u0026lt; ValuesSummedPerThread, BlockSize \u0026gt; Average Time (ms) Total Threads Add_ReduceAddSyncPerWarp\u0026lt; 1, 64\u0026gt; 8.4175 4,194,304 Add_ReduceAddSyncPerWarp\u0026lt; 2, 64\u0026gt; 4.8579 2,097,152 Add_ReduceAddSyncPerWarp\u0026lt; 4, 64\u0026gt; 2.9825 1,048,576 Add_ReduceAddSyncPerWarp\u0026lt; 8, 64\u0026gt; 2.2488 524,288 Add_ReduceAddSyncPerWarp\u0026lt; 16, 64\u0026gt; 3.8810 262,144 Add_ReduceAddSyncPerWarp\u0026lt; 32, 64\u0026gt; 7.5115 131,072 Trace Metrics 512MiB vs 4MiB:\nI hypothesised earlier that the performance difference I observed between the 512MiB and 4MiB tests were due to memory bandwidth, lets see if we can prove that using hardware metrics provided by Nvidia Nsight Systems.\nWe’ll compare the simple Add_AtomicPerThread\u0026lt;8,512\u0026gt; test with 512MiB x 1 run and 4MiB x 128 runs:\n512MiB x 1\n4MiB x 128\nThe results show as huge difference in the throughput between the two tests, with the 512MiB test at nearly 95% throughput on VRAM while the 4MiB test is closer to 1%. L1TEX and VidL2 throughput are both also much higher compared to the 512MiB, a good indication that the data we are processing is remaining in the caches and achieving better throughput as a result.\nAdd_SharedWithReduceAddSyncPerWarp vs Add_AtomicPerThread:\nNext, lets compare two very different functions running the 4MiB x 128 test setup and see how the trace metrics look. On average, Add_SharedWithReduceAddSyncPerWarp is faster than Add_AtomicPerThread so it’s interesting to observe that Add_AtomicPerThread has better throughput for L1TEX as well as much better overall warp occupancy. I think it’s important to think about what the throughput stats actually mean, really it’s pointing to us the units which are under the most pressure. We saw above in the 512MiB vs 4MiB test that the VRAM throughput was 95% vs 1%, and this explains the huge difference in performance there, but just because we were achieving 95% throughput in that unit, does not mean it’s faster.\nAdd_SharedWithReduceAddSyncPerWarp\u0026lt; 4, 128 \u0026gt; (~1.7086ms)\nAdd_AtomicPerThread\u0026lt; 8, 512 \u0026gt; (~2.1138ms)\nConclusions The main objective here was a personal objective of mine to introduce myself to CUDA programming, understand how it’s written, how to profile it and performance characteristics.\nI think one thing that’s shown here is how in order to improve performance of your application, you must target what the primary bottleneck is. Simply reducing global atomic operations overall may not be the biggest improvement you can make, if it isn’t your primary bottleneck. Often, one of the most important things you can do is always try to keep the SM units fully saturated with as much work as possible and spread your workload evenly across as many threads as possible.\nSomething else that has stood out here is that using shared memory is very fast. Often the test scenarios which are more complex, involving more code and doing atomic writes to shared memory are amongst the fastest.\nFurther Investigations:\nWhy is the occupancy so far off 100% for the traces above? What could be done to improve this further? Are there other CUDA features that could improve our parallel add further? Such as using CUDA Tiles or Clusters? Or Tensor features? How would these results differ on different GPUs? Are there more trace statistics we can gather to better understand our results, or better understand our existing trace data? Source Code is accessible here: https://github.com/comeradealexi/CUDAParallelAddBenchmarks/blob/main/kernel.cu\n","permalink":"https://alexanderhoughton.co.uk/blog/cuda-parallel-sum-benchmarks/","summary":"As my first foray into CUDA programming I set myself a challenge to experiment with different methods of finding the total sum of a large array of numbers, trying different strategies exposed via CUDA to see how different approaches compare and what comes out fastest. A lot of my GPU experience previously on PC has […]","title":"📈 CUDA Parallel Sum Benchmarks"},{"content":"I wanted to get a feel for how fast my AMD Radeon RX 6600 could transfer memory around and how much this changed depending on how much memory was being transferred as well as what type of memory was being copied to and from (E.g. UPLOAD or READBACK). I will also compare the results to a much more powerful NVIDIA RTX 5080.\nMy test setup is fairly simple, and with very little overhead. It’s a simple DirectX 12 application which simply issues ID3D12GraphicsCommandList::CopyResource commands from one allocated resource to another. The advantage of using CopyResource is that it allows the driver to decide how best to optimise the copy for the hardware. An alternate approach would be to write and issue compute shaders myself to transfer the data. We observed on AMD hardware with the Radeon GPU Profiler that the driver is issuing dispatch calls when we make calls to CopyResource and I’d expect the Nvidia card to be doing the same.\nSee the results of the tests below. Both GPUs show a similar pattern of increasing transfer rates until a point, then dropping and stabalising. I believe what we’re seeing here is the impact of the cache sizes on both GPUs, which is 32MiB for the RX 6600 and 64MiB for the RTX 5080. We observe peak transfer speeds on both cards at roughly 50% of the cache size before dropping off and stabilising.\nPCIe Transfer Speeds Next up, how does transfer speed from UPLOAD memory to on-chip GPU memory compare? In these tests we know that transfer speeds will be occuring over the PCIe bus and naturally we’re expecting slower transfer speeds when compared to on-chip GPU to GPU copies. The AMD card is using PCIe x8 4.0 which has a maximum listed speed of 15.754GiB/s while the NVIDIA at PCIe x16 5.0 with 63.015 GiB/s. (https://en.wikipedia.org/wiki/PCI_Express)\nIn my test results the AMD card peaks at around 13.2 GiB/s while the Nvidia card around 47 GiB/s, close but not quite reaching the maximum listed speeds. What I find interesting here is how we can get a feel for the optimal amount of memory to be transferring to achieve maximum speed, around 1-2MiB for the AMD card and 16-20MiB for the Nvidia.\nA Peek Under The Hood I mentioned previously that we’re using the CopyResource D3D12 function to copy resources from one location to another and this allows the driver to handle this however it wants. To take a peek under the hood, I’ve used AMD’s Radeon GPU Profiler tool while running tests of various speeds. I will focus on 4 different transfer sizes and dig in to them a little deeper. AMD’s tool confirms that under the hood, it’s using compute dispatch calls to transfer the data, while it doesn’t give us access to the ISA code being run, we can still observe that the hardware limits 16MiB being transferred in a single dispatch before splitting over multiple dispatch calls and we can also see that the transfer size per thread invocation is 16 bytes.\n768KiB\nCompute Dispatches: 1\nTotal Threads: 49,152\n4MiB\nCompute Dispatches: 1\nTotal Threads: 262,144\n16MiB\nCompute Dispatches: 1\nTotal Threads: 1,048,576\n32MiB\nCompute Dispatches: 2\nTotal Threads: 1,048,576 + 1,048,576\nRadeon GPU Profiler\nOn the left is a screenshot from AMD’s Radeon GPU Profiler from a section where I’m doing 32MiB copies. This has internally been split in to two separate dispatch calls by the driver. Events 1\u0026amp;2 are the CopyResource for UPLOAD-\u0026gt;GPU, Events 5\u0026amp;6 for GPU-\u0026gt;GPU then 9\u0026amp;10 for GPU-\u0026gt;READBACK. The other events here are D3D12 barrier calls.\nAn interesting difference I observed between UPLOAD-\u0026gt;GPU and GPU-\u0026gt;GPU is the amount of data processed in the compute shader. The UPLOAD-\u0026gt;GPU splits the 32MiB in to two dispatch calls, the same as all others but the thread count is 4,194,304 meaning it’s copying just 4 bytes per thread while the GPU-GPU dispatch call is spawing 1,048,576 threads to copy 16MiB meaning it’s copying 16 bytes per thread. I don’t know the specifics of why this might be, I can only assume it’s more optimal for the given memory types.\nOne of the limitations of DirectX 12 is that the maximum value you can pass to a dispatch ThreadGroupCount parameter is D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION which is 65536.\nCan we do better than the driver? By issuing our own compute dispatch calls can we find a faster setup within DirectX 12 to copy buffers around on the GPU? For these tests we’ll be focusing on GPU to GPU copies and to start with, we’ll write a compute shader that should match what CopyResource is doing as we can tell from Radeon GPU Profiler that CopyResource has a Thread Group Dimension of {64,1,1} and copies 16 bytes of data per shader. This is a good start, you can see in the chart below that the Copy Resource and our Compute Dispatch is roughly equal in their transfer speeds, which is what we expected.\nOur Compute Shader which copies 16 bytes per thead and has a Group Dimension of 64 looks like this:\nByteAddressBuffer Source : register(t0); RWByteAddressBuffer Destination : register(u0); [numthreads(64, 1, 1)] void main(uint3 DTid : SV_DispatchThreadID) { uint4 Value = Source.Load4(DTid.x); Destination.Store4(DTid.x, Value); } The AMD ISA Code for this shader translates to the following when compiled with optimsiatons enabled.\nFirst, lets try increasing the number of bytes copied per thread to see what effect this has while keeping the thread group size as 64. The results below are pretty clear, as we increase the amount of work per thread, we’re losing a lot of performance. Overall, in these tests we are increasing the total amount of work per thread group because we’re maintaining 64 threads per group.\nSo lets try altering the thread group size to keep each thread group processing a total of 1 KiB of data and see what the results show… They are almost identical to the test above, which clearly suggests it’s nothing to do with the thread group size in these tests and purely the extra work per-thread which is decreasing our performance.\nThe smallest and most optimal amount of data we can process per thread is 16-bytes, we can see how in the ISA above, the data is read and stored in single instructions. So how does the thread group size affect performance while maintaining 16-bytes per-thread? The chart below shows that testing thread group sizes ranging from 16 to 1024 give roughly equal performance, there are no performance gains here to be had. I believe this is because the GPU is ultiamtely going to be issuing the same number of individual threads to do the copy.\nI’d consider all of these results pretty conclusive that the driver is doing a good job under the hood when doing simple buffer copies and we were unable to create a compute dispatch setup which was any better. The data above is from the AMD card but I observed the same behaviour on the Nvidia card too. I also made additional tests comparing CopyBufferRegion and under the hood this appears identical to CopyResource.\nI’ve stuck to copying raw data buffers in these tests because I expect more complex render targets or depth buffers will have more driver optimisations applied inherently such as DCC (Delta Colour Compression) as well as Colour Mask and Fast Clear Optimisations in place.\nAchieving Consistent Results I spent a lot of time during these tests ensuring the data I was collecting was accurate. Initially I had my tests sequentially do the UPLOAD-\u0026gt;GPU, GPU-\u0026gt;GPU GPU-READBACK in the same command buffer with barriers in place but observing Radeon GPU Profiler, the driver was being optimal here and appeared to allow small parts of this work to overlap, meaning I wasn’t accurately timing the cost of each copy operation I was interested in. So I then split each test in to its own command buffer, submitted it to the queue separately and waited for it to finish before timing the next test.\nIn my initial tests, each command buffer recorded as follows to collect timing data:\nCollect Timestamp Query Resource Barriers Dispatch or Copy Resource call Resource Barriers Collect Timestamp Query Resolve Query Data This process initially appear to be accurate for the Copy Resource calls, but when I started issuing my own dispatch calls my timing data on the AMD RX 6600 started to get very inaccurate. The same tests would sometimes come back as taking 2us while other times 45us. Initially I thought perhaps this was related to SetStablePowerState but I ran tests with and without this and I still observed the inconsistency. I felt as if the timing data was being collected before the full operations had start/finished accurately. I observed in the Radeon GPU Profiler that the call to the Resolve Query Data inserted a hard barrier, flusing all caches each time it was invoked. I therefore changed the setup to have two sets of query data each test and resolve them after each collection like so:\nCollect Timestamp Query A Resolve Query Data A Resource Barriers Dispatch or Copy Resource call Resource Barriers Collect Timestamp Query B Resolve Query Data B My results after this on AMD were much more stable and consistent. I found this behaviour very odd, as it is not expected that you should have to do this, when collecting timing data and I didn’t observe these problems while running on the Nvidia hardware.\nClosing Thoughts It’s been an interesting test to get a glimpse under the hood what’s happening when calling CopyResource writing a testing framework that tries to accurately measure this. You would expect that the driver provided CopyResource would always be the fastest option available, so it’s good to see that we were able to match it with our own compute shader.\nSource code for the project can be found here: https://github.com/comeradealexi/GPUWorkSubmissionTiming\n","permalink":"https://alexanderhoughton.co.uk/blog/exploring-gpu-memory-transfer-speeds-radeon-rx-6600-rtx-5080/","summary":"I wanted to get a feel for how fast my AMD Radeon RX 6600 could transfer memory around and how much this changed depending on how much memory was being transferred as well as what type of memory was being copied to and from (E.g. UPLOAD or READBACK). I will also compare the results to […]","title":"🚌 Exploring GPU Memory Transfer Speeds (Radeon RX 6600 \u0026 RTX 5080)"},{"content":"Slim Graphics is my toy graphics engine I’ve been using to experiment with different graphical techniques and learn more about DirectX 12 as well as other graphical features such as Mesh Shaders as well as optimisation techniques.\nI have not designed the API to be perfectly optimal, nor have I set out to create the perfect graphics abstraction. Instead I have focussed on trying to make an API that is simple for me to expand upon and add new features easily, without getting bogged down in having to handle resource transitions at the perfect moments etc.\nOver time, I will be writing individual posts about the various features I’ve implemented or things that I have found interesting.\nSource code can be found here: https://github.com/comeradealexi/SlimGraphics – See the ReadMe on github for up to date information on features and setup process.\nAs of writing this post, here are some of the main features:\n3D Model and texture loading via Assimp Mesh shader support Amplification shader support GPU meshlet culling (cone and frustum) CPU frustum culling Basic post-processing and visualisations Built-in magnification tool JSON driven shader compiling via C# tool Model visualisations vertex \u0026amp; prim order wave intrinsics pixel order meshlet \u0026amp; amplification Model cache optimisation (meshoptimizer and DirectXMesh) Model simplification (via meshoptimizer) Pipeline feedback (Via API and UAV Readback) Latest Slim Graphics Posts 🐇 Slim Graphics: Introduction ","permalink":"https://alexanderhoughton.co.uk/blog/slim-graphics-introduction/","summary":"Slim Graphics is my toy graphics engine I’ve been using to experiment with different graphical techniques and learn more about DirectX 12 as well as other graphical features such as Mesh Shaders as well as optimisation techniques. I have not designed the API to be perfectly optimal, nor have I set out to create the […]","title":"🐇 Slim Graphics: Introduction"},{"content":"Mutexs, Semaphores, Condition Variables, Critical Sections… There are so many different synchronisation types to choose from but how do they compare in terms of performance and what other synchronisation types are there we can explore?\nMy tests here have been written with a job-system in mind, where worker threads are waiting for work which is triggered by another thread. So I aim to understand the performance overhead involved in triggering the synchronisation types but also the time on the worker threads to be woken up as a result. I will also explore how this scales with multiple threads and some alternatives to synchrionsation types such as spins and sleeps. I’m keen to understand what synchronisation types scale best and what will allow us to wake our threads as fast as possible.\nSynchronisation Methods In my tests I’ll be exploring the following methods for synchronising, most of which are Win32 types unless otherwise specified. All of the types below ultimately end up invoking as syscall when triggering and waiting which allows the kernel to stop the thread from running.\nSemaphore Event (Single Event) Event (Separate Event object per-thread) Critical Section (With volatile bool to trigger) Critical Section And Spin Count (With volatile bool to trigger) Condition Variable (With Critical Section) Condition Variable (With Critical Section And Spin Count) Synchronization Barrier Condition Variable (With SRW Lock – Slim Read/Write Lock) WaitOnAddress (Single address) WaitOnAddress (Separate address per-thread) std::mutex (Internally this uses a SRW Lock) std::condition_variable \u0026amp; std::mutex (Internally this uses a SRW Lock) Mutex (With volatile bool to trigger) std::atomic_flag Wait We will also explore synchronising threads using a while loop to spin and checking for a specified value. In the body of the loop we test with different operations such as yielding and sleeping.\nSpining Methods Spin: volatile bool + __noop() Spin: std::atomic_bool + __noop() Spin: std::atomic_bool + _mm_pause() Spin: std::atomic_bool + std::this_thread::yield() Spin: std::atomic_bool + SwitchToThread() Spin: std::atomic_bool + Sleep(0) Test Setup The tests work by spawning x number of threads and causing all threads to wait with a specific sync type. Majority of the results I’ll be sharing here are using the total number of threads returned by std::thread::hardware_concurrency minus one (for the main thread which will be triggering).\nOnce each thread is waiting, the main thread will then trigger all threads at once. We measure how long the main thread takes to trigger and then how long it takes from the trigger for the threads to start executing. For these tests on Windows I’m using QueryPerformanceCounter because it is accurate and allows good comparison of timings between different threads.\nFor the initial test, we are running with the default thread priority (THREAD_PRIORITY_NORMAL) and the default thread affinity (The thread can run on any logical processor).\nResults The results below are from a AMD Ryzen 5 5600X (6 cores, 12 logical processors) running Windows 11 version 25H2 with 11 worker threads and 1 main trigger thread. Results have been averaged over 32,000 runs per sync type.\nWe record the time the main thread takes to invoke the trigger and then how long from the trigger occurring, each thread takes to wake.\nThe immediate standout is the spinning methods being the fastest, this doesn’t come as a surprise though because the threads have never been put in a waiting state, they are just spinning and wasting CPU time and power.\nSo if we now turn our attention to the full synchronisation types, we can see two distinct groups of results focusing on the thread wake time, with the latter being the Mutex \u0026amp; Critical Sections being used without a condition variable.\nChanging Thread Count So how does the performance change in our setup when we change the number of threads which are woken? We will again compare the time the thread takes to wake and also the trigger time. As before, thread counts below include the main triggering thread.\nThe pattern we see across all sync types is that as the thread count increases, so does the average wake time for each thread and for the slower sync setups we’ve got, this increase is much larger.\nIt’s also interesting to observe that when we’re waking just a single thread however, performance is very similar across all sync types.\nVariations Thread Priority:\nIn order to give all of our threads the best chance of being executed, we call SetThreadPriority with THREAD_PRIORITY_HIGHEST.\nThe results are perhaps not as you would expect, by setting all threads to be the highest priority, we a consistent drop in performance as every type tested takes longer to wake compared to the default thread priority!\nThread Affinity:\nFor these tests, we lock each thread to a unique logical processor with SetThreadAffinityMask. This means threads wont context switch around different threads. For video game development on consoles, it’s quite common for us to lock threads to specific logical processors/cores because we know the exact hardware our code will be running on. Naturally, this is much more difficult on PC because hardware can differ so much, as can the number of cores and logical processors so despite the results below, I would always exercise caution before shipping code with thread affinities locked.\nThe results below are mixed. In many cases performance is very similar and worst case, we’re negatively affecting performance. I think on a PC system where you’re running many different processes and your application won’t have exclusive access to specific cores, it’s probably best to let the OS handle thread scheduling…\nComparing Each Thread I found it important, given some of the tests above include a synchronisation object per-thread, to also record the time each thread took to wake to see if we can spot any patterns. Below the chart shows that the Event (Per Thread) and Wait On Address (Per Thread) wake the first thread they trigger before the last thread they trigger, which makes complete sense, but I think it’s important to look at it this way instead of just the average because while we’re waking early threads faster, later ones are slower than the average. We’re seeing this pattern because we’re in control of the thread waking order, there will be an order of each waked thread for the other sync types, but it’s just not consistent each time.\nIn order to visualise the difference in waking order between the first and last threads, I collect and sort the wake time for each thread and keep the average wake time for the order each thread was woken. Doing this, we get charts showing the average wake time in order for our sync types:\nThere is a lot of overlapping data in the charts above, so it can be difficult to see in an image. The standout here though is that the Event and Semaphore types have the most consistent wake time across all threads, while other sync times vary a lot more between the first and last thread woken. The outlier is the Condition Variable + SRW Lock, this varies from 6us all the way to 30us. What’s also interesting is that all sync types other than Event and Semaphore are faster at waking the first 3 threads, but then the cost increases significantly.\nSo the results above got me thinking… Instead of having an Event per thread or a single Event for all threads, could a hybrid approach give some benefits? E.g, having an Event object for x number of threads. We’ve already got two variants of the Event type, a single one which triggers all threads and another setup where we have 11 Event types for each thread which we trigger in order. This may not even have to just extend to the Event primitive, could any of the sync types benefit from a hybrid approach?\nThe data above shows that we can increase the average thread waking performance from having a single event trigger all threads with a small increase in trigger time. The sweet spot here, where we had 11 worker threads in total to have 3 event types with the first two triggering 5 threads each, and the last triggering just a single thread.\nNext Steps To some extent, I feel like I’ve only scratched the surface here and there is still a lot more to explore surrounding this such as the following:\nExploring how timeBeginPeriod/timeEndPeriod affects performance. What is actually happening under the hood of each sync time and how that impacts the performance overhead. Almost all waiting threads appear to end up waiting in a syscall to NtWaitForAlertByThreadId but there is a clear difference in trigger and waking performance occuring despite this. We explored how splitting the Event type resulted in better performance, could this be done for other sync types for better performance? How do these tests change on different hardware setups? I’m particularly interested in how the thread waking performance would work on say a 192 logical processor Thread Ripper, the overhead of unlocking such a huge number of threads must be particularly slow, but perhaps you wouldn’t write a job system which could equally spread over such a huge number of threads. How would these tests compare under Linux and using some of the Linux native synchronisation types? I plan to clean up and share the source code I have written for these tests in the future. ","permalink":"https://alexanderhoughton.co.uk/blog/comparing-synchronisation-methods-on-windows/","summary":"Mutexs, Semaphores, Condition Variables, Critical Sections… There are so many different synchronisation types to choose from but how do they compare in terms of performance and what other synchronisation types are there we can explore? My tests here have been written with a job-system in mind, where worker threads are waiting for work which is […]","title":"Comparing Synchronisation Methods on Windows"},{"content":"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…\nI think discovering the following is a good example of why it’s always a good idea to inspect the generated assembly code when optimising performance to fully understand what is happening under the hood.\nSource code:\n#include \u0026lt;math.h\u0026gt; float square(float num) { return sqrtf(num); } MSVC v19.latest + /O2:\nfloat square(float) PROC xorps xmm1, xmm1 ucomiss xmm1, xmm0 ja SHORT $LN3@square sqrtss xmm0, xmm0 ret 0 $LN3@square: jmp sqrtf float square(float) ENDP So what’s going on here? Isn’t the sqrtss instruction exactly what we need? We can see it generated in the assembly but there is some additional logic in there plus an actual function call to the sqrtf function on line 8. So lets get a better understanding of what’s happening:\nxorps xmm1, xmm1 – Here we are putting a value of zero in to the xmm1 register. xorps is: “Bitwise Logical XOR of Packed Single Precision Floating-Point Values”. It’s common for compilers to generate a value of zero through a simple, fast XOR operation because if you XOR the same value, the result is always zero.\nucomiss xmm1, xmm0 – Next we have a comparison operation. ucomiss: “Unordered Compare Scalar Single Precision Floating-Point Values and Set EFLAGS”. So now we are comparing our input value to the function (xmm0) to zero (xmm1). This operation will set the EFLAGS based on the comparison of the values which will then be used in the following ja operation.\nja SHORT $LN3@square – This is a jump instruction. ja will jump to the specified label if the comparison is above. So in our case, it will jump if the value in xmm0 is above xmm1. So it’s checking if zero is above the value passed to the function. Or to flip this on its head, it’s checking if the value we passed to our function is less than zero.\nSo if we pass a value less than zero, we’re going to jump to the label $LN3@square: which ends up calling the full sqrtf function. Otherwise we end up calling the sqrtss function and returning.\nSo why is the logic branching here based on whether a negative value is passed? Let’s start by taking a look at the documentation for the sqrtf function (https://linux.die.net/man/3/sqrtf):\nDomain error: x less than -0\nerrno is set to EDOM. An invalid floating-point exception (FE_INVALID) is raised.\nHmm… Let’s understand the error handling with these functions a little but further…\nMath Error math_error is used for detecting errors from mathematical functions. It’s a feature I’ve not come across before in game development code, most times we call math functions we will sanitise the input before calling the function and we likely won’t be writing code which can gracefully handle the results of a bad value passed to a math function (except perhaps in non-shipping builds).\nYou can use math error library like below to check the results of a call such as sqrtf:\nfloat safe_sqrtf(float f) { // Always clear errno by calling _set_errno(0) immediately // before a call that may set it, // and check it immediately after the call. errno = 0; float result = sqrtf(f); int error_value = errno; if (error_value != 0) { printf(\u0026#34;sqrtf error %i for value: %f\\n\u0026#34;, error_value, f); return 0.0f; } return result; } So if we passed a negative value to our safe_sqrtf function, we can expect errno to be set to EDOM and we can handle this however we like. The return value from sqrtf will be -nan(ind) so here we instead return 0.0f.\nCan we omit math errors? Yes we can! With MSVC we are given different compiler options for floating point operations these are /fp:strict, /fp:precise and /fp:fast. The default option is /fp:precise. It’s important to know that these floating point controls are global and affect more than just how error handing is performed so it’s not always recommended to enable this without careful scrutiny. You can read more about what these options do here: https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior\nBelow is the assembly code generated for each of the three options:\n/fp:strict float square(float) PROC rex_jmp QWORD PTR __imp_sqrtf float square(float) ENDP Here we never use the sqrtss instruction, it always ends up calling the sqrtf implementation.\n/fp:precise float square(float) PROC rex_jmp QWORD PTR __imp_sqrtf float square(float) ENDPfloat square(float) PROC xorps xmm1, xmm1 ucomiss xmm1, xmm0 ja SHORT $LN3@square sqrtss xmm0, xmm0 ret 0 $LN3@square: jmp sqrtf float square(float) ENDP /fp:fast float square(float) PROC sqrtss xmm0, xmm0 ret 0 float square(float) ENDP What about other compilers? With Clang or GCC we can get the same results by passing -ffast-math but this enables a lot of other optimisations and assumptions which in my experience within game development can have a negative impact on gameplay features relying on very precise floating point accuracy. The good news though is that -ffast-math is a big collection of other compiler options and we can just disable math error handling specifically with the following: -fno-math-errno.\nCan we do it without compiler options? Yes! We can use the intrinsic _mm_sqrt_ss which will translate to the exact sqrtss assembly instruction we’ve been aiming for. Lets see how that could look:\nSource code:\n#include \u0026lt;xmmintrin.h\u0026gt; __m128 square_mm(__m128 num) { return _mm_sqrt_ss(num); } MSVC v19.latest + /O2:\nfloat square(float) ENDP__m128 square_mm(__m128) PROC movups xmm0, XMMWORD PTR [rcx] sqrtss xmm0, xmm0 ret 0 __m128 square_mm(__m128) ENDP Hmm, that’s not as optimal as previous results with the assembly generated! What’s going on here? Under MSVC if we’re expecting to use SIMD registers directly, it’s best to add the __vectorcall to the function. Here is an extract from: https://learn.microsoft.com/en-us/cpp/cpp/vectorcall\nThe __vectorcall calling convention specifies that arguments to functions are to be passed in registers, when possible. __vectorcall uses more registers for arguments than __fastcall or the default x64 calling convention use. The __vectorcall calling convention is only supported in native code on x86 and x64 processors that include Streaming SIMD Extensions 2 (SSE2) and above.\nSo lets try it again with __vectorcall added:\nSource code:\n#include \u0026lt;xmmintrin.h\u0026gt; __m128 __vectorcall square_mm(__m128 num) { return _mm_sqrt_ss(num); } MSVC v19.latest + /O2:\n__m128 square_mm(__m128) PROC sqrtss xmm0, xmm0 ret 0 __m128 square_mm(__m128) ENDP So you can see how the explicit __vectorcall now has produced the same instructions as the /fp:fast variant but we’ve done it without global compiler options. I expect there are other options you could explore with pragma’s or function attributes in order to dictate math error functionality for specific sections of code but I have not extensively explored this.\nFurther SIMD behaviour If we run some more tests using SIMD, how will the compiler handle it?\n4 Float Loop:\nHere we have 4 floats passed to a function and a loop where we explicitly call sqrtf() on each of them. The interesting part here is that even with the default /fp:precise behaviour, the compiler automatically omits the negative check and call to the sqrtf C function which is different to the behaviour on a single float.\n__m128 __vectorcall m128_sqrtf(__m128 m) { __m128 out; for (size_t i = 0; i \u0026lt; 4; i++) { out.m128_f32[i] = sqrtf(m.m128_f32[i]); } return out; } The assembly produced for the code above with standard /O2 on MSVC is our most optimal outcome:\n__m128 m128_sqrtf(__m128) PROC sqrtps xmm0, xmm0 ret 0 The fp:strict variant here naturally procudes a far more complext result with the loop unrolled to make 4 individual calls to the sqrtf. While the fp:fast variant produces the same code.\n3 Float Loop:\nThis is the same as the test on the left but with a loop of only 3 floats instead with the rest of the setup identical. The differences in the code produced are stark:\n__m128 __vectorcall m128_sqrtf(__m128 m) { __m128 out; for (size_t i = 0; i \u0026lt; 3; i++) { out.m128_f32[i] = sqrtf(m.m128_f32[i]); } return out; } __m128 m128_sqrtf(__m128) PROC $LN22: sub rsp, 72 movaps XMMWORD PTR [rsp+48], xmm6 xorps xmm1, xmm1 movaps xmm6, xmm0 ucomiss xmm1, xmm6 ja SHORT $LN15@m128_sqrtf xorps xmm0, xmm0 sqrtss xmm0, xmm6 jmp SHORT $LN16@m128_sqrtf $LN15@m128_sqrtf: call sqrtf $LN16@m128_sqrtf: movaps xmm1, xmm6 movss DWORD PTR out$[rsp], xmm0 shufps xmm1, xmm6, 85 xorps xmm0, xmm0 ucomiss xmm0, xmm1 ja SHORT $LN13@m128_sqrtf xorps xmm0, xmm0 sqrtss xmm0, xmm1 jmp SHORT $LN14@m128_sqrtf $LN13@m128_sqrtf: movaps xmm0, xmm1 call sqrtf $LN14@m128_sqrtf: movss DWORD PTR out$[rsp+4], xmm0 xorps xmm0, xmm0 shufps xmm6, xmm6, 170 ucomiss xmm0, xmm6 ja SHORT $LN11@m128_sqrtf xorps xmm1, xmm1 sqrtss xmm1, xmm6 jmp SHORT $LN20@m128_sqrtf $LN11@m128_sqrtf: movaps xmm0, xmm6 call sqrtf movaps xmm1, xmm0 $LN20@m128_sqrtf: movaps xmm0, XMMWORD PTR out$[rsp] movaps xmm6, XMMWORD PTR [rsp+48] shufps xmm0, xmm0, 210 movss xmm0, xmm1 shufps xmm0, xmm0, 201 add rsp, 72 ret 0 __m128 m128_sqrtf(__m128) ENDP I also ran the tests above using a custom struct containing 4 sequential floats rather than the __m128 type to see if this was being handled as a special case but I observed identical behaviour with my custom structure.\nCompiler Explorer Examples View the comparisons of all compilers and their variations on godbolt.org here: https://godbolt.org/z/v3na8z91P\nPerformance So lets take a look at the performance difference of our variants… For these tests I have used Google Benchmark: https://github.com/google/benchmark – A great open source tool for benchmarking small sections of code in isolation.\nWhen using a tool like Google Benchmark and testing a very small section of code like I am here with a single function, it’s incredibly important to validate that the actual test you’ve written is being executed as expected. I’m always surprised how clever compilers these days can actually be in how they can completely eliminate and optimise code away.\nThe key part in the code below is to ensure the variable passed to sqrtf is a volatile, so the compiler is forced to read the value from memory again and cannot make assumptions about its values. Without this, the compiler is clever enough to realise the work done in the loop never changes for each iteration and only invoke sqrtf once in certain situations. We also shouldn’t take the figures here as “the cost of calling”, what we’re interested in here is how much faster each variation is compared to the default.\nvoid BM_sqrtf(benchmark::State\u0026amp; state) { float A = 0.0f; volatile float B = 1.0f; do_not_optimise(A); do_not_optimise(B); for (auto _ : state) { A += sqrtf(B); } do_not_optimise(A); do_not_optimise(B); } Test Setup /fp:strict /fp:precise (default) /fp:fast AMD Ryzen 5 5600X 2.76 ns 2.63 ns 2.63 ns Intel i5-8265U 3.90 ns 2.44 ns 2.44 ns So what’s really interesting here is no observable difference between /fp:precise and /fp:fast despite us knowing /fp:fast is a simple sqrtss instruction while /fp:fast has additional logic to check if the value is negative first and then branch based on that. I can’t fully explain the reasons for this but I expect perhaps branch prediction is always taking the correct path with my running the same test over and over with the same values but it’s very interesting how the additional instructions we know are present here do not affect the test results.\nComparing to the /fp:strict variant, we see a performance difference, especially so on my laptop Intel chip, over a 50% performance hit and a far smaller hit on the AMD chip.\nRaspberry Pi (ARM64) I also took the opportunity to run the test on a Raspberry Pi 3 Model B V.2. GCC here does not have the equivalent of the /fp:strict which always generated a jmp instruction so instead the test here is with the default -O3 versus -O3 -fno-math-errno. The tests here were compiled using GCC version 14.2.0.\n-O3:\nsquare_root(float): fcmp s0, #0.0 bpl .L5 b sqrtf .L5: fsqrt s31, s0 fmov s0, s31 ret -O3 -fno-math-errno:\nsquare_root(float): fsqrt s0, s0 ret Test Setup -O3 -O3 -fno-math-errno Raspberry Pi 3 Model B V.2 20.1 ns 15.9 ns The comparison on the ARM chip of -O3 vs -O3 -fno-math-errno is the equivalent of /fp:precise and /fp:fast on the MSVC compiler so it’s very interesting that we see a large performance difference here on the ARM and GCC compiler while on the MSVC and x86-64 chips we saw no difference at all. On the Raspberry Pi we observe over a 25% speed improvement by using the -fno-math-errno.\n3 Float Loop Performance I also elected to run some further tests on the setup where we have a loop calling sqrtf three times because this resulted in some large differences with the code produced. The function for this test looks like this:\nstruct Float3 { float f[3]; }; __declspec(noinline) Float3 __vectorcall sqrt_float3_no_inline(Float3 m) { Float3 o; for (size_t i = 0; i \u0026lt; 3; i++) { o.f[i] = sqrtf(m.f[i]); } return o; } Below is the assembly produced for each of the results on MSVC and the performance results on AMD Ryzen 5 5600X. In this test case, we do observe a very small performance improvement between /fp:precise and /fp:fast.\n/fp:strict (5.54 ns)\nFloat3 sqrt_float3_no_inline(Float3) PROC $LN12: push rbx sub rsp, 80 movaps XMMWORD PTR [rsp+64], xmm6 movaps xmm6, xmm0 unpcklps xmm6, xmm1 movaps xmm0, xmm6 movaps XMMWORD PTR [rsp+48], xmm7 movd ebx, xmm2 call QWORD PTR __imp_sqrtf movaps xmm7, xmm0 movaps xmm0, xmm6 shufps xmm0, xmm0, 85 call QWORD PTR __imp_sqrtf movaps xmm6, xmm0 movd xmm0, ebx call QWORD PTR __imp_sqrtf movaps xmm2, xmm0 movaps xmm1, xmm6 movaps xmm6, XMMWORD PTR [rsp+64] movaps xmm0, xmm7 movaps xmm7, XMMWORD PTR [rsp+48] add rsp, 80 pop rbx ret 0 Float3 sqrt_float3_no_inline(Float3) ENDP /fp:precise (3.55 ns)\nFloat3 sqrt_float3_no_inline(Float3) PROC $LN21: sub rsp, 88 movaps XMMWORD PTR [rsp+64], xmm6 xorps xmm3, xmm3 ucomiss xmm3, xmm0 movaps XMMWORD PTR [rsp+48], xmm7 movaps xmm6, xmm1 movaps XMMWORD PTR [rsp+32], xmm8 movaps xmm7, xmm2 ja SHORT $LN15@sqrt_float xorps xmm8, xmm8 sqrtss xmm8, xmm0 jmp SHORT $LN16@sqrt_float $LN15@sqrt_float: call sqrtf movaps xmm8, xmm0 $LN16@sqrt_float: xorps xmm0, xmm0 ucomiss xmm0, xmm6 ja SHORT $LN13@sqrt_float sqrtss xmm6, xmm6 jmp SHORT $LN14@sqrt_float $LN13@sqrt_float: movaps xmm0, xmm6 call sqrtf movaps xmm6, xmm0 $LN14@sqrt_float: xorps xmm0, xmm0 ucomiss xmm0, xmm7 ja SHORT $LN11@sqrt_float xorps xmm0, xmm0 sqrtss xmm0, xmm7 jmp SHORT $LN12@sqrt_float $LN11@sqrt_float: movaps xmm0, xmm7 call sqrtf $LN12@sqrt_float: movaps xmm7, XMMWORD PTR [rsp+48] movaps xmm2, xmm0 movaps xmm0, xmm8 movaps xmm1, xmm6 movaps xmm8, XMMWORD PTR [rsp+32] movaps xmm6, XMMWORD PTR [rsp+64] add rsp, 88 ret 0 Float3 sqrt_float3_no_inline(Float3) ENDP /fp:fast (3.36 ns)\nFloat3 sqrt_float3_no_inline(Float3) PROC sqrtss xmm0, xmm0 sqrtss xmm1, xmm1 sqrtss xmm2, xmm2 ret 0 Float3 sqrt_float3_no_inline(Float3) ENDP Closing thoughts I started writing this post because I noticed additional complexity when calling sqrtf and it’s led me down a bit of a rabbit hole! But it’s been an interesting journey. The things I’ve taken away from this are:\nMath.h functions can internally set errno to help diagnose when bad values are passed to them. Disabling this functionality can produce faster and simpler code. Compiler options such as -ffast-math are not all or nothing and contain many individual compiler options so we can select safe ones without unwanted side effects. This little experiment reinforces that you’ve always got to measure performance and you can’t make assumptions about how things will perform on different hardware or platforms. Additionally it’s shown me that using tools such as Google Benchmark, you need to be so careful in the code to write that your compiler will not optimise away your intentions. Don’t underestimate the compiler! ","permalink":"https://alexanderhoughton.co.uk/blog/does-calling-sqrtf-always-result-in-a-single-asm-instruction/","summary":"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 […]","title":"📐 Does calling sqrtf always result in a single asm instruction?"},{"content":" Overview This page contains the majority of projects I have worked on in my career. I specialise in low-level, engine, optimisation and graphics. I love understanding why computer code behaves the way it does and using that information to write to code that runs faster which ultimately results in a better user experience.\nI won’t try to list every API or programming area I have worked in below (there are far too many!) so I’ll try to summarise the ones I feel are most relevant to my skills and interests:\nPrimary Programming Languages: C/C++ Important Soft Skills: Leading team to a common goal, inspiring + motivating + rewarding team, line management duties, conducting regular one-to-ones with team, mentoring duties to unlock team members full potential Relevant Programming Skills: Multithreading, SIMD (NEON+SSE), Optimisation, Profiling, Complex code merging, Bespoke Engines + Unreal Engine, x86-64, ARM, Clang \u0026amp; MSVC Relevant Platform Experience: PC, Xbox (XDK+GDK), PlayStation 4 \u0026amp; 5, Nintendo Switch, iOS, Android Graphics API Experience: DirectX 11 + 12, OpenGL, GNM + AGC, NVN, Vulkan Software / Libraries: Mono/Mono, Sharpmake, ANGLE, Perforce, Github, DirectXMath, SuperLuminal, RenderDoc, Nvidia Nsight Other Relevant Skills: Project due diligence + task breakdown + time estimates Blog: https://alexanderhoughton.co.uk/category/blog/ Unannounced AAA Port – Xbox Series X|S \u0026amp; PlayStation 5 2023-2024 – Xbox Series X|S \u0026amp; PlayStation 5\nLed a team of 7 programmers with an external partner bringing a AAA engine to Xbox Series X|S and PlayStation 5.\nWe implemented every platform specific engine requirement and added brand new graphics API to bring both platforms to parity with PC as well as integrating the new platforms to the entire build and package pipelines. A lot of work on this project involved bringing C# support to PS5 and Xbox through the use of Mono which was an incredibly complex and challenging undertaking to get working fully.\nRed Dead Redemption – Nintendo Switch \u0026amp; PlayStation 4 2023 – Nintendo Switch \u0026amp; PlayStation 4\nWe worked closely with our good friends at DoubleEleven on this project. Our primarily responsibility was to bring the Nintendo Switch to rendering parity with the original release and then optimise the game to get it running at a solid 30fps.\nI made further contributions to the PlayStation 4 version by adding FSR2.0 support to allow for high quality anti-aliasing, upscaling \u0026amp; sharpening.\nThe Great War: Western Front – PC 2023 – PC Steam\nFor this project we added DirectX 12 support to Petroglyphs PC engine, upgrading it from DirectX 11. I was not involved day-to-day with this project but provided crucial support and guidance to the team working on the project.\nhttps://store.steampowered.com/app/2109370/The_Great_War_Western_Front/\nBassmaster Fishing 2022 – Nintendo Switch 2022 – Unreal Engine 4 / Nintendo Switch\nBringing the popular fishing game to Switch for the first time. This was a good project for many of us because we had the opportunity to dig deep in to Unreal Engine. We made modifications at the engine level to automate the process of stripping LODs and automatically changing LOD levels on the fly.\nZombie Army 4: Dead War – Nintendo Switch 2021-2022 – Nintendo Switch\nMany told us it was impossible to bring Zombie Army 4 (ZA4) to the Nintendo Switch but we found new and exciting ways to not only optimise the game but also improve the visuals beyond what we ever thought was possible.\nI led the coding efforts on this project and worked very closely with the art team to make sure no stone went unturned in the hunt for optimisations.\nDigital Foundry were so impressed with our work that myself, Arden Aspinall (Studio Head) and Reece Parrinder (Senior Artist) were interviewed by Thomas Morgan of Eurogamer: https://www.eurogamer.net/digitalfoundry-2022-zombie-army-4-the-making-of-an-incredible-switch-port\nNVIDIA GTC Presentation: Lessons in Porting AAA Action Games to the Nintendo Switch 2021\nIn 2021 myself and our head of studio Arden Aspinall were invited by Nvidia to give a talk at the GTC conference detailing our experience of bringing games to the Nintendo Switch.\nhttps://www.nvidia.com/en-us/on-demand/session/gtcspring21-e32649/\nEvil Genius 2 2021 – PC / Xbox / PlayStation\nWe joined the project later in to development to aid in optimising the game for release. Evil Genius 2 is a very different game to what Rebellion and the Asura Engine has produced before so this produced some unique and interesting challenges to overcome.\nStrange Brigade – Nintendo Switch 2021 – Nintendo Switch\nI mentored our new graduates to get the Switch port up and running using Sniper Elite 4 as a template. The rest of the studio and myself got more involved as the project progressed to add new optimisations and bug fixes.\nZombie Army 4, Strange Brigade \u0026amp; Sniper Elite 4 – Google Stadia 2020 – Google Stadia\nMyself and the team spent a large period of time bringing the Rebellion back cataloge to Google’s Stadia platform. The Asura engine already had Vulkan rendering support, however it required some modification to optimise it and work around driver issues.\nA large portion of the work I was involved in was adding audio playback support via Pulse Audio API and then optimising to ensure playback was uninterripted.\nSniper Elite 4 – Nintendo Switch 2020 – Nintendo Switch\nSniper Elite 4 was our most challenging port to date for very different reasons to other projects. After initially getting the Stadia version of Sniper Elite 4 working with Vulkan, we got the Switch version working with Vulkan too and very quickly realised that the CPU performance was going to be the biggest uphill battle in hitting our 30fps target.\nSo when Sniper Elite 4 was at visual parity with Vulkan, which happened very early on in the development process, our GPU time was hitting nearly 90ms at its worst but more frightening was the CPU time, peaking at over 70ms.\nDetailed analysis of our Sniper Elite 4 port can be found in our GTC talk, featuring myself her\nZombie Army Trilogy – Nintendo Switch 2019 – Nintendo Switch\nThis project got up and running in record time as almost all of the tech we did for Sniper Elite 3 on Switch was easily ported into Zombie Army Trilogy but the main bulk of this project was optimising the assets and the code to get it running smoothly on the Switch. You can have so many zombies on screen at any one time with ZAT so there was a massive push on the CPU optimisation side to get it working.\nI completely multithreaded almost all of the CPU rendering side of this project, making full use of NVN to have separate render systems simultaneously record to separate command buffers on different threads and stitch them all together at the end to parallelise as much work as possible.\nThe Dynamic Resolution Scaling system was modified to take shot lived explosions and other effects to always aim for the highest resolution. ZAT is the first project in docked mode that we allow the 3D to render at full 1080p.\nFootball Manager 2019 – Google Stadia 2018-2019 – Google Stadia\nGetting Football Manager and the engine running and working on Google’s Stadia platform. This mainly involved writing a Vulkan implementation for the engines graphics layer BGFX.\nIt was a really interesting project for me, adding Vulkan support. It taught me loads about Vulkan as well as subtle differences between hardware.\nSniper Elite 3 – Nintendo Switch 2018-2019 – Nintendo Switch\nA port of Rebellion’s Sniper Elite 3, originally released in 2014. All of the rendering code I wrote for BattleZone and Sniper Elite V2 was used to get this port finished in record time. Due to the increased visual fidelity of SE3 as well as the more complex AI and other gameplay features, squeezing every ounce of performance out of the Nintendo Switch was one of my main tasks for this project. I rewrote huge chunks of code and pushed as utilised the 3 available CPU cores on the Switch to get this project running buttery smooth.\nGPU Optimisations CPU Optimisations Lots of work went into multithreading the rendering systems to make better use of the Nintendo Switch’s 3 available cores. Tools Increased level export time dramatically by adding a shader caching system BattleZone – Nintendo Switch 2018 – Nintendo Switch\nA port of Rebellion’s BattleZone VR to the Nintendo Switch. Most of the renderer was based off my code from Sniper Elite V2.\nRendering (NVN) Optimisations (GPU \u0026amp; CPU) Improved loading times Achieved 30fps target frame rate Audio (Base audio renderer and streaming sound system) Audio Optimisations BattleZone played up to 70 simultaneous sounds sometimes which often put a big strain on the Switch but I was able to optimise the audio code and behaviour. Sniper Elite V2 Remastered 2017-2019 – PC / Xbox One / PlayStation 4 / Nintendo Switch\nA visual upgrade for PC and port to PS4, XB1 and Nintendo Switch. Played a big roll across all platforms.\nAbstracted the existing D3D11 Renderer to make porting to different platforms easier. Rendering Implemented the PS4(Gnm) and Nintendo Switch (NVN) rendering systems from scratch to parity of DX11 XB1 X and PS4 Pro 4K Support XB1 \u0026amp; PS4 HDR Support XB1 ESRAM Implementation and resource hot swapping XB1, Switch \u0026amp; PS4 Specific Optimisations Anamorphic lens flare Water caustics effect Photomode effects and filters Dynamic Resolution Scaling Tools XB1, PS4 \u0026amp; Nintendo Switch texture converters Many upgrades and bug fixes to HLSL to GLSL converter for Switch Audio Nintendo Switch base audio implementation Rebellion were so pleased with the Anamorphic Lens Flare and Water Caustics effects I wrote that they had me implement them into their main branch for use in Strange Brigade. You’ll also find heavy use of the system in NZA4.\nRogue Trooper Redux 2016-2017 – PC / Xbox One / PlayStation 4 / Nintendo Switch\nRemastering an old classic, Rogue Trooper onto PS4, XB1, PC \u0026amp; Nintendo Switch. Played a big role across all platforms.\nMultiplayer \u0026amp; Matchmaking Support (Steam, GOG, PS4 \u0026amp; XB1) Including Socket and Network Communication code. Audio (PS4 \u0026amp; Nintendo Switch) Including threaded Stream from disk audio files Video Playback (Steam/GOG) WebM format Rendering Tasks Ported many legacy D3D9 classes to D3D11 Ported D3D9 HLSL ASM to HLSL Assisted with PS4 \u0026amp; Nintendo Switch rendering implementation Soft Particles Jointly implemented Parallax Mapping Jointly implemented SSAO Tessellation Support (Didn’t ship) Implemented certain XB1 XRs and PS4 TRCs Tools Texture Conversion for PS4 \u0026amp; XB1 Other Responsibilities Adding Bitangent and Tangent information to existing model format via export process Bug fixing (Gameplay, Networking, Audio, Visual) Unreleased Unity Project 2016 2016-2017 – Android / iOS\nSpent 6 months working on porting a Unity project from console \u0026amp; PC platforms onto mobile. The main focus of the project was making it fit into memory.\nSpent a lot of time in the C++ Hans Boehm Garbage Collector which Unity uses. Gained a good understand of Unity from a very low level. Heavenstrike Rivals 2016\nWorked to bring Heavenstrike Rivals to Steam for the first time. My work involved upating the UI to work with keyboard and mouse controls.\nCricket Captain 2015, 2016, 2017, 2018 2015-2018 – PC / Android / iOS\nUsing our in-house engine I generated quads for the crowd system and added billboarded animations for the crowd texture sheets.\nWorms World Party Remastered 2015 – PC\nActed as lead programmer at TickTock Games on the project. We finished off the project for Team 17, adding achievements, controller support and upgrading the MFC front end.\nSteam Achievements Steam Leaderboards Controller Support Increasing the resolution of the MFC front end Optimising the Software Renderer International Snooker Pro 2015 – Windows Phone 8\nSolo project, porting from Android to Windows Phone 8 using Project ANGLE, which translates OpenGL ES to DirectX.\nImplemented ANGLE renderer. Windows Phone 8 Audio, file saving and everything else to get the project running. Z Steel Soldiers 2015 – PC\nJoined the project after initial release and worked on adding new features into the game, fixing bugs and improving performance.\nUpgraded path-finding algorithm to A* and visualised calculated path Gameplay \u0026amp; engine bug fixes ","permalink":"https://alexanderhoughton.co.uk/experience/","summary":"\u003cdetails open\u003e\n\u003csummary\u003e\u003cstrong\u003eOverview\u003c/strong\u003e\u003c/summary\u003e\n\u003cp\u003eThis page contains the majority of projects I have worked on in my career. I specialise in low-level, engine, optimisation and graphics. I love understanding why computer code behaves the way it does and using that information to write to code that runs faster which ultimately results in a better user experience.\u003c/p\u003e\n\u003cp\u003eI won’t try to list every API or programming area I have worked in below (there are far too many!) so I’ll try to summarise the ones I feel are most relevant to my skills and interests:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cstrong\u003ePrimary Programming Languages:\u003c/strong\u003e C/C++\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eImportant Soft Skills:\u003c/strong\u003e Leading team to a common goal, inspiring + motivating + rewarding team, line management duties, conducting regular one-to-ones with team, mentoring duties to unlock team members full potential\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eRelevant Programming Skills:\u003c/strong\u003e Multithreading, SIMD (NEON+SSE), Optimisation, Profiling, Complex code merging, Bespoke Engines + Unreal Engine, x86-64, ARM, Clang \u0026amp; MSVC\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eRelevant Platform Experience:\u003c/strong\u003e PC, Xbox (XDK+GDK), PlayStation 4 \u0026amp; 5, Nintendo Switch, iOS, Android\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eGraphics API Experience:\u003c/strong\u003e DirectX 11 + 12, OpenGL, GNM + AGC, NVN, Vulkan\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSoftware / Libraries:\u003c/strong\u003e \u003ca href=\"https://github.com/mono/mono\"\u003eMono/Mono\u003c/a\u003e, \u003ca href=\"https://github.com/ubisoft/Sharpmake\"\u003eSharpmake\u003c/a\u003e, \u003ca href=\"https://github.com/google/angle\"\u003eANGLE\u003c/a\u003e, Perforce, Github, \u003ca href=\"https://github.com/microsoft/DirectXMath\"\u003eDirectXMath\u003c/a\u003e, SuperLuminal, RenderDoc, Nvidia Nsight\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eOther Relevant Skills:\u003c/strong\u003e Project due diligence + task breakdown + time estimates\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eBlog:\u003c/strong\u003e \u003ca href=\"/category/blog/\"\u003ehttps://alexanderhoughton.co.uk/category/blog/\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e","title":"Career Projects"},{"content":" 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 wrong and can result in images that don’t look as good.\nI will start by saying that one of the tips that really helped me in understanding SRGB colour space is that almost every colour image we view on our montitors is in SRGB colour space. We also know that when we are writing techniques or shaders to blend, manipulate or apply lighting to a 3D scene, we want to do this with textures that have first been converted in to linear colour space.\nIn DirectX or OpenGL for example, this means using SRGB format specifiers for diffuse/abledo textures or any colour data which has been authored visually. When sampling textures in shaders using SRGB formats, the hardware will ensure we are given the values in linear space.\nNote: In order to run the interactive examples on this page you need to run in a browser that supports WebGL2.\nHTML Colour Gradients Here we have a few very simple examples showing how even a simple colour gradient block in HTML are not blending in linear colour space and then we have a WebGL version which is correctly converting the images to SRGB colour space.\nNotice in the default two images that without gamma correction, we don’t seem to get a nice smooth transition between the red and green and also get a splodge of brownish/dark orange colour after the red. In contrast, the SRGB corrected blend shows a more natural blend of colours.\nDiv linear-gradient colour blending WebGL Rendered with sRGB Gamma Correction Colour Pickers Red ()\nGreen ()\nBlue () Red ()\nGreen ()\nBlue () Presets Red to Green Black to White Blue to Green Green to Yellow Image Sampling: Below is a 2×2 pixel image with 2 fully red and 2 fully green pixels. We then tell our web browser to stretch the image to be 500×500 pixels in size. Our web browsers will blend the colours together in srgb colour space. On the right hand side we have a WebGL canvas doing the same image render but here we make sure the blending happens in linear space.\nDefault Web Blending SRGB Blending (Blend: ) Below we have another 2×2 image but this time with a single red, green, blue and white pixel:\nDefault Web Blending SRGB Blending (Blend: ) And here we have an image showing more blending between more colours:\nDefault Web Blending SRGB Blending (Blend: ) Image Blending In the examples below we show the result of blending two images together. Use the slider to adjust the blend amount of each image. In the SRGB Blend image, we do not make any conversions and we blend in SRGB colour space which is incorrect. In the Linear Blend image, we first convert the image from SRGB to Linear, blend the two images together and then convert back to SRGB. Mixing colours in linear colour space is correct.\nBlend slider: %\nSRGB Blend Linear Blend Blend slider: %\nSRGB Blend Linear Blend Blend slider: %\nSRGB Blend Linear Blend SRGB Conversion Gone Wrong Below are some examples of how an image can look when SRGB/Linear conversions are applied incorrectly. Extra Linear Conversion SRGB Reference Extra SRGB Conversion LearnOpenGL has some great visual examples too which showcase how wrong a 3D scene with lighting can look without proper SRGB consideration (Source: https://learnopengl.com/Advanced-Lighting/Gamma-Correction): Sources Gamma Correction: https://learnopengl.com/Advanced-Lighting/Gamma-Correction Adobe Stock Images: https://stock.adobe.com/uk/search DirectX Data Conversation Rules: https://learn.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-data-conversion \u0026amp; https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/converting-data-color-space ","permalink":"https://alexanderhoughton.co.uk/blog/visualising-srgb-gamma-correction/","summary":"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 […]","title":"Visualising SRGB \u0026 Gamma Correction"},{"content":"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.\nYou can easily solve this however by spawning your own Windows console window and redirecting stdout to your new console.\nThe code below will redirect all stdout \u0026amp; stderr messages to a new console window:\nif (AllocConsole()) { AttachConsole(GetCurrentProcessId()); HANDLE hConOut = CreateFileA(\u0026#34;CONOUT$\u0026#34;, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); SetStdHandle(STD_OUTPUT_HANDLE, hConOut); SetStdHandle(STD_ERROR_HANDLE, hConOut); //Ensures FILE* object remapped to new console window freopen(\u0026#34;CONOUT$\u0026#34;, \u0026#34;w\u0026#34;, stdout); freopen(\u0026#34;CONOUT$\u0026#34;, \u0026#34;w\u0026#34;, stderr); //Allows use of _write(1,...) \u0026amp; _write(2,...) to be redirected freopen(\u0026#34;CONOUT$\u0026#34;, \u0026#34;w\u0026#34;, _fdopen(1, \u0026#34;w\u0026#34;)); freopen(\u0026#34;CONOUT$\u0026#34;, \u0026#34;w\u0026#34;, _fdopen(2, \u0026#34;w\u0026#34;)); } ","permalink":"https://alexanderhoughton.co.uk/blog/redirect-all-stdout-stderr-to-console/","summary":"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 \u0026amp; stderr […]","title":"Redirect all stdout/stderr to console"},{"content":"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.\nIncrease 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 limited to 9999 lines maximum. See the section below for modifying this value programmatically to go beyond this limit. Increase Windows Console Text Limit Programmatically via C/C++ You can achieve the equivalent of the above programmatically by calling SetConsoleScreenBufferSize. While it accepts a SHRT_MAX value of 32767, in reality I found the limit on my PC to be 16384 before the console started to truncate text\n#include \u0026lt;windows.h\u0026gt; COORD c = { 120, SHRT_MAX };\tSetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), c); Alternatives: Redirect IO to a file When executing programs from the command line, you can redirect the output into a file by appending “\u0026gt; FileName” to the end of the command. To give an example, to redirect the output from ipconfig to a text file called MyFile.txt you can do as follows:\nipconfig \u0026gt; MyFile.Txt ","permalink":"https://alexanderhoughton.co.uk/blog/increase-windows-console-line-limit/","summary":"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 […]","title":"Increase Windows Console Line Limit"},{"content":"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 builds which we will observe below.\nEnabling Unity/Jumbo Builds in Visual Studio 2019 \u0026amp; 2022: In Visual Studio, open the Project Configuration Manager. Then under Configuration Properties \u0026gt; Advanced \u0026gt; Enable Unity (JUMBO) Build set it to Yes.\nThis will add the following entry to your .vcxproj:\n\u0026lt;EnableUnitySupport\u0026gt;true\u0026lt;/EnableUnitySupport\u0026gt; The generated Unity files will be in your projects $(IntDir) by default. They’ll be something along the lines of ‘unity_XA9SRNK1NRU62EJK.cpp’ so you can inspect them and see exactly what’s going on and what files are being compiled.\nAdditional useful options: Once Unity/Jumbo support has been enabled, it will show additional options under Configuration Properties \u0026gt; C/C++ \u0026gt; Unity Build. These can be changed per file. For example under the ‘Code Snippet To Add Before Include’ you can add the following to show in the output what files each generated Unity file contains:\npragma message(\u0026#34;$$unity_id$$-$$file_number$$-$$file_name$$\u0026#34;) Simple Demonstration: To show the benefits of Unity/Jumbo builds I’ve created a simple test project which contains 50 .cpp files, each including the same large header and a simple function returning an constant integer.\nThe header file included in each file is as follows, which contains a fair bit of code to parse and compile.\n#pragma once #include \u0026lt;Windows.h\u0026gt; #include \u0026lt;iostream\u0026gt; #include \u0026lt;vector\u0026gt; #include \u0026lt;map\u0026gt; #include \u0026lt;unordered_map\u0026gt; #include \u0026lt;stdio.h\u0026gt; #include \u0026lt;stdint.h\u0026gt; #include \u0026lt;assert.h\u0026gt; Performance stats:\nDefault: 16.5 seconds Unity/Jumbo: 2.2 seconds pch: 2.1 seconds Unity/Jumbo \u0026amp; pch: 1.5 seconds Results above are from an Intel i5-8265U, 8GB DDR4 @ 2400MHZ. Visual Studio 2022, MSVC 14.33.31629, x64 bit, multithreaded compilation enabled.\nSo the results above show that comparing normal multithreaded compilation of each individual cpp file vs a combining them into a few Unity/Jumbo .cpp files we see a significant improvement. However the results compared to just using pre-compiled headers are fairly similar, as you’d expect considering each .cpp file is almost empty and is just including the same headers. What’s interesting is when we combine both unity \u0026amp; pre-compiled headers, we see a nearly 25% improvement in compile speed. We can attribute that to the overhead of processing the PCH for each .cpp file, even though it already contains ‘pre-compiled’ code.\nLets take a look at the use of Unity/Jumbo builds in a real world project next.\nUnity/Jumbo build support in assimp: assimp is a library to import and export various 3d-model-formats including scene-post-processing to generate missing render data. https://github.com/assimp/assimp\nassimp does not work out of the box when you just enable Unity/Jumbo build support so it required some fixes in a few places to compile and for certain .cpp files, it was simpler to exclude them from being used in the Unity builds. I’ll go through some of the common errors you’ll encounter as a result in the next section.\nPerformance stats:\nDefault Build: ~75 seconds Unity/Jumbo Build: ~35 seconds It took some effort to get it fully working and even then, some files were not part of the unity build process but the improvements in compile time are significant. If you scale this to a much larger project, you could easily shave a significant amount of time off your builds.\nCommon Unity/Jumbo build errors: Due to the nature of including multiple .cpp files into a single object/compilation unit majority of the problems will come from code in one CPP file bleeding into others. Common errors will come from ‘using namespace MyNamespace;’, static/global variables sharing the same name and #defines.\nIf any errors prove too difficult to fix, a fallback can always be to exclude the specific file from Unity/Jumbo build support. This is done by setting Configuration Properties \u0026gt; C/C++ \u0026gt; Unity Build \u0026gt; Included In Unity File to False.\nerror C2872: ‘Type’: ambiguous symbol This error could be due to a Type existing in multiple namespaces and both namespaces being used. Workarounds for these kind of errors can be to fully quality the namespace in the cpp files\nerror C2011: ‘MyClass’: ‘class’ type redefinition This error could be from certain header files not containing header guards or a #pragma once so end up being included multiple times.\nerror C2084: function ‘int FunctionA(void)’ already has a body (function redefiniton) Sometimes you’ll come across little helper functions written as a global/static in a cpp file and can exist in multiple cpp files. The proper way to fix this would be to forward declare the function in a header and only include the implementation once.\nerror C2374: ‘MyInt’: redefinition; (variable redefiniton) Similar to the function problem above, often static variables can have the same name. If they need to be different, rename them or alternately expose them via headers.\nCommon Windows.h issues: While running some tests, I ran into issues as a result of Windows.h being exposed to lots more .cpp files. This brought out some common issues such as ‘min’ and ‘max’ being defined in Windows.h which can break use of std::min / std::max. This error was fixed for me by defining ‘NOMINMAX’.\nOther issues arose as a result of some other #defines in Windows.h. Assimp for example has some functions called ‘CreateDirectory’ which Windows.h can #define as CreateDirectoryW.\nSo often it can be a good idea to try and keep platform specific code files together as part of the build process.\nFurther reading: Support for Unity (Jumbo) Files in Visual Studio: https://devblogs.microsoft.com/cppblog/support-for-unity-jumbo-files-in-visual-studio-2017-15-8-experimental/\nWorking with Unity/Jumbo builds: https://austinmorlan.com/posts/unity_jumbo_build/\nFastBUILD: https://www.fastbuild.org/docs/functions/unity.html\n","permalink":"https://alexanderhoughton.co.uk/blog/faster-compiling-visual-studio-unity-jumbo-builds/","summary":"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 […]","title":"Faster Compiling: Visual Studio Unity (Jumbo) Builds"},{"content":"ℹ️ Update August 2026 Hello! A small update from a long time after I published this original blog post. My original methodology here was incredibly manual, it involved manually writing and sleeping between every single clock cycle in order to program the MCP 4131 chip. Below is an updated and much simplified method of interacting with Raspberry Pi devices using the SPI interface. The advantage of this method is that by sending our commands via the SPI interface, we guarantee each CLK duration is exactly the same and there is no chance of interruptions. With my original setup, manually sending one bit at a time with a sleep between in user-space code, I could not guarantee my program wouldn’t have been context switched out and a higher priority program given precedence to run.\nThe code below has a similar wiring setup to my original diagrams except the following differ (MCP4131 ➡️ Raspberry Pi)\nCS ➡️ CE0 SCK ➡️ SCLK SDI/SDO ➡️ MOSI #include \u0026lt;fcntl.h\u0026gt; #include \u0026lt;sys/ioctl.h\u0026gt; #include \u0026lt;linux/spi/spidev.h\u0026gt; #include \u0026lt;stdint.h\u0026gt; #include \u0026lt;stdio.h\u0026gt; #include \u0026lt;unistd.h\u0026gt; // Useful source https://zbotic.in/digital-potentiometer-mcp4131-software-controlled-resistance/ void write_wiper(int fd, uint8_t value) { uint8_t tx[2] = {0, value}; // write command, address 0 uint8_t rx[2] = {0}; struct spi_ioc_transfer tr = { .tx_buf = (unsigned long)tx, .rx_buf = (unsigned long)rx, .len = 2, .speed_hz = 1000000, .bits_per_word = 8, }; ioctl(fd, SPI_IOC_MESSAGE(1), \u0026amp;tr); } int main() { int fd = open(\u0026#34;/dev/spidev0.0\u0026#34;, O_RDWR); uint8_t mode = SPI_MODE_0; uint8_t bits = 8; uint32_t speed = 1000000; ioctl(fd, SPI_IOC_WR_MODE, \u0026amp;mode); ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, \u0026amp;bits); ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, \u0026amp;speed); int duration_ms = 5000; // total ramp time int steps = 128; // 0 to 127 int delay_us = (duration_ms * 1000) / steps; // Cycle up from 0 to 127 for (int v = 0; v \u0026lt; steps; v++) { write_wiper(fd, v); usleep(delay_us); } // Cycle down from 127 to 0 for (int v = steps - 1; v \u0026gt;= 0; v--) { write_wiper(fd, v); usleep(delay_us); } close(fd); return 0; } Original Article (October 2021) Github Link:https://github.com/comeradealexi/MCP4131\nDatasheet 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\nIt 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 what each pin on the chip does:\nMCP4131 Data Sheet Pins CS = Chip Select SCK = Serial Clock SDI/SDO = Serial Data In / Serial Data Out VSS = Ground VDD = Positive Power Supply Input P0B = Potentiometer Terminal B P0W = Potentiometer Wiper (W) Terminal P0A = Potentiometer Terminal A Pin Input/Output Protocol Below is a diagram from the datasheet showing you the protocol for each pin in order to program the MCP4131.\nMCP4131 Protocol Initial state of all pins:\nCS = HIGH SCK = HIGH SDI/SDO = LOW (HIGH = 3.3 Volts, GPIO ON)\n(LOW = 0 Volts, GPIO OFF)\nSDI Bit Layout The MCP4131 expects 16 bits of data to be passed each time we program it. The layout of these 16 bits are as follows:\nIn our case the MCP4131 is a 7-bit device which means our Data Byte supports just 7 bits… Which means we can program it with values between 0 and 127. Where 0 would be full resistance and 127 being no resistance.\nIn this case, our memory bits should all be 0, our commands bits should be 0 0 as we’re writing data and the first 3 data bits also 0 because it’s a 7 bit potentiometer. So the first 9 bits we write should all be zeros.\nPCB Setup GPIO 17 = CS\nGPIO 27 = CLK\nGPIO 22 = SDI/SDO\nThe LED is connected to the Potentiometer Wiper.\nMCP4131 Wiring Diagram with Raspberry Pi Source Code https://github.com/comeradealexi/MCP4131 – The code here will cycle from max to min then back to max again.\nThe initial setup code here initialises WiringPi and sets the pins as outputs and also puts all of our output pins into their default states.\nMCP4131(int inGPIO_CS, int inGPIO_SCK, int inGPIO_SDI) : GPIO_CS(inGPIO_CS), GPIO_SCK(inGPIO_SCK), GPIO_SDI(inGPIO_SDI) { wiringPiSetupSys(); pinMode(GPIO_CS, OUTPUT); pinMode(GPIO_SCK, OUTPUT); pinMode(GPIO_SDI, OUTPUT); digitalWrite(GPIO_CS, LOW); digitalWrite(GPIO_SCK, LOW); digitalWrite(GPIO_SDI, LOW); digitalWrite(GPIO_CS, HIGH); digitalWrite(GPIO_SCK, LOW); digitalWrite(GPIO_SDI, LOW); } Once the setup is complete, the chip is programmed via the WriteData function.\n//7 bit values 0-127 void WriteData(unsigned char Value) { const int DelayTime = 10; if (Value \u0026gt; 127) Value = 127; //Clamp to 7 bit max value digitalWrite(GPIO_CS, LOW); delayMicroseconds(DelayTime); for (int i = 0; i \u0026lt; 16; i++) { bool bHigh = false; //First 9 bits are all 0 //Write out the last 7 data bits (MSB fist) if (i \u0026gt; 8) { unsigned char idx = (i - 9); //6 to 0 unsigned char bit = 1 \u0026lt;\u0026lt; (6 - idx); bHigh = Value \u0026amp; bit; } digitalWrite(GPIO_SDI, bHigh ? HIGH : LOW); digitalWrite(GPIO_SCK, HIGH); delayMicroseconds(DelayTime); digitalWrite(GPIO_SCK, LOW); delayMicroseconds(DelayTime); } digitalWrite(GPIO_CS, HIGH); } The code matches the protocol image we saw earlier. We start by setting the Chip Select (CS) to low, this tells the chip we are going to start writing to it.\nWe then start writing our 16 bits of data. Setting out desired bit and then setting the SCK to HIGH and back to low again to complete the writing of a single bit. This is done 16 times in total.\nAfter the last bit is written, we set the CS back to HIGH and that completes the data writing!\n","permalink":"https://alexanderhoughton.co.uk/blog/programming-a-digital-potentiometer-mcp4131-with-raspberry-pi-wiringpi/","summary":"ℹ️ Update August 2026 Hello! A small update from a long time after I published this original blog post. My original methodology here was incredibly manual, it involved manually writing and sleeping between every single clock cycle in order to program the MCP 4131 chip. Below is an updated and much simplified method of interacting […]","title":"💡 Programming a Digital Potentiometer (MCP4131) With Raspberry Pi \u0026 WiringPi"},{"content":"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.\nRequirements:\nPC with ethernet port (or USB ethernet adapter) Ethernet cable Raspberry Pi tftpd64 (DHCP Software https://pjo2.github.io/tftpd64/) It’s quite simple to get your PC and Pi talking to each other over ethernet, the main requirement is a DHCP server. (A DHCP Server is a network server that automatically provides and assigns IP addresses, default gateways and other network parameters to client devices). Without a DHCP server, the Pi won’t know what IP Address to use.\nStep 1: Physical Connections Plug your Raspberry Pi into your PC with the Ethernet cable. Connect either directly to your built in Ethernet port or via your USB Ethernet adapter.\nStep 2: PC Network Setup So we’ll need to configure our static settings on the PC side to begin with.\nStart by opening up the Network Connections window:\nYou should see all your network devices available. In my case I’ve got a few. Since I’m using a USB Ethernet adapter, I will be using that one (Ethernet 5).\nRight click on the network device you’ve got connection to your Pi and go to Properties.\nClick on the “Internet Protocol Version 4 (TCP/IPv4)” and then hit “Properties”\nWe’ll want to fill in our IP and Subnet Mask manually so that it’s static and never changes.\nThe IP Address chosen should not conflict with any other connections on the PC.\nIn my case I’ve chosen for the IP Address: 192.168.111.1 and the Subnet Mask: 255.255.255.0\nOnce entered, hit OK.\nStep 3: DHCP Server Setup Our local PC is now setup. You can prove it’s working by pinging itself via command line “ping 192.168.111.1” and you should get a response from yourself.\nThe next step is to run the DHCP Server so that we can assign the Raspberry Pi a valid IP address and then connect to it.\nDownload TFTPD64: https://pjo2.github.io/tftpd64/ (Tftpd64 is a free, lightweight, opensource IPv6 ready application which includes DHCP, TFTP, DNS, SNTP and Syslog servers as well as a TFTP client)\nI went for the .zip file without any installer so we can just directly run the exe:\nOnce downloaded, unzip and run tftpd64.exe.\nHit settings at the bottom\nUnder the GLOBAL tab, disable everything except DHCP Server.\nFill out the DHCP settings similar to below.\nI’ve got it setup so the IP pool starts at 192.168.111.10 and there are 10 addresses available.\nFor the “Def. router (Opt 3)” enter the PC IP address you chose earlier.\nHit OK when complete.\nAfter I hit OK, I waited a few moments until the Pi was automatically assigned an IP address:\nThe IP address you see here is now the IP of the Pi! So you can connect to it via SSH or however you want just as you would normally!\n","permalink":"https://alexanderhoughton.co.uk/blog/connecting-to-raspberry-pi-direct-to-pc-via-ethernet/","summary":"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 […]","title":"Connecting to Raspberry Pi direct to PC via Ethernet"},{"content":"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.\nI’ll touch on the advantages/disadvantages of the different ways to use custom deleters and the difference between unique and shared ptr.\nstd::unique_ptr: The type of the deleter is defined as part of the unique_ptr and you define it as the second template parameter, then when constructing the type, you must pass through the type specified as a parameter.\nInstead of std::unique_ptr calling ‘delete’ and invoking the destructor on the internally stored pointer, it will instead pass the pointer to the function provided.\nThe deleter must by a type which implements a operator() which takes a T* as a parameter.\nSo in the example below, we specify that the deleter is std::function\u0026lt;void(MyClass*)\u0026gt;. Then on construction, we pass through the function we want to call.\nclass MyClass { public: ~MyClass() { } }; using DefaultPtr = std::unique_ptr\u0026lt;MyClass\u0026gt;; DefaultPtr pDefault; //Will call MyClass::~MyClass() using CustomDeletePtr = std::unique_ptr\u0026lt;MyClass, std::function\u0026lt;void(MyClass*)\u0026gt;\u0026gt;; CustomDeletePtr pCustom; //Will call function passed through on construction static void CustomDeleter(MyClass* pMyClass) { //This will be called instead of delete and invoking the constructor. } void InitPointers() { pDefault = DefaultPtr(new MyClass()); pCustom = CustomDeletePtr(new MyClass(), \u0026amp;CustomDeleter); } std::unique_ptr – cheapest implementations: The custom deleter type you specify will affect the size of your std::unique_ptr. The sizes below are from C++ VS2019 64bit.\nDefault: std::unique_ptr\u0026lt;MyClass\u0026gt; (no custom deleter) – 8 bytes. 1: std::unique_ptr\u0026lt;MyClass, CustomDeleteClass\u0026gt; – 8 bytes. 2 std::unique_ptr\u0026lt;MyClass, decltype(lambda)\u0026gt; – 8 bytes. 2: std::unique_ptr\u0026lt;MyClass, void(*)(MyClass*)\u0026gt; – 16 bytes. 3: std::unique_ptr\u0026lt;MyClass, std::function\u0026lt;void(MyClass*)\u0026gt; – 72 bytes. Lets talk about the sizes above. std::unique_ptr by default is a really simple wrapper for a pointer and it only has to store the 8 byte pointer.\nAdding custom deleters can increase the size of std::unique_ptr because it has to store the type specified. std::function really bloats out the size of the std::unique_ptr because of the flexibility and features it provides.\nProviding a C Style function as the deleter void(*)(MyClass*) increases the size to 16 bytes. This is because it needs to store a pointer to the function specified. Its increase the size of the function but offers good flexibility because you can provide any function you want when constructing.\nUsing a custom deleter class with an operator() or a lambda incurs no additional storage overhead because the custom deleter function is always the same for all objects created and the DeleterClass contains no member variables.\nclass DeleterClass { public: void operator()(MyClass* pMyClass) { } }; using CustomDeleteOperatorPtr = std::unique_ptr\u0026lt;MyClass, DeleterClass\u0026gt;; CustomDeleteOperatorPtr MyCustomPtr(new MyClass()); auto lambda = [](MyClass* p) { delete p; }; std::unique_ptr\u0026lt;MyClass, decltype(lambda)\u0026gt; PointerWithLambda(new MyClass(), lambda); One bonus when using the operator() over a lambda is that you don’t even have to specify it when constructing new instances of the object as you can see above, assuming the class can be default constructed.\nstd::shared_ptr std::shared_ptr requires some different syntax compared to std::unique_ptr. Behind the scenes, std::shared_ptr allocates a ‘control block’ containing the atomic reference counter and other data such as the custom deleter. The image below from Oreilly.com shows it nicely:\nWhen using a custom deleter with shared_ptr we don’t pass any additional template arguments, our custom deleter is passed when creating the object and it exists within the control block.\nclass MyClass { public: ~MyClass() { } }; static void CustomDeleter(MyClass* pMyClass) { delete pMyClass; } int main() { //1 - Function std::shared_ptr\u0026lt;MyClass\u0026gt; s1(new MyClass(), CustomDeleter); //2 - Lambda std::shared_ptr\u0026lt;MyClass\u0026gt; s2(new MyClass(), [](MyClass* pMyClass) { delete pMyClass; }); //3 - Custom Class class DeleterClass { public: DeleterClass() { } void operator()(MyClass* pMyClass) { delete pMyClass; } }; DeleterClass d; //Must be CopyConstructible. std::shared_ptr\u0026lt;MyClass\u0026gt; s3(new MyClass(), d); } The size of the shared_ptr remains 16 bytes on a 64 bit compiler. One pointer to the object and another pointer to the control block. Depending on the implementation, the size of the control block could change if a custom deleter is or isn’t allocated.\nOn MSVC 2019, using std::shared_ptr by default, the control block size is 24 bytes. The size of the control block can increase depending on the type of deleter used. Using a lambda or class with an operator() incurs no additonal storage overhead. Using a function pointer will increment the size by the cost of a pointer and using more complex types such as std::function will increase storage further, as it does with std::unique_ptr.\nNote: Unfortunately you cannot use a custom deleter with std::make_shared (nor with std::make_unique). Something else interesting to know about std::shared_ptr is that it’s more optimal to use std::make_shared() rather than std::shared_ptr\u0026lt;T\u0026gt;(new T()) because internally the implementation needs to allocate a control block so if you provide your own pointer, it has to call ‘new’ to allocate its own control block. If you called make_shared(), it will allocate the memory for your data and the control block in the same allocation!\nClosing thoughts When wanting to use a custom deleter with a std::unique_ptr and you want it to be the same function for all objects, use a custom class with operator() as this incurs the least overhead, can be inlined at runtime and doesn’t increase the size of unique_ptr.\nIf you’re wanting to call a different function for each of your unique_ptrs, opt for a straight up function pointer/ lambda. The only additional overhead is the cost of storing the function pointer.\nFor std::shared_ptr, the storage overhead of the deleter is stored in the control block only once instead of for every object like with std::unique_ptr, so it’s cheaper to use a complex delete type with larger storage requirements.\n","permalink":"https://alexanderhoughton.co.uk/blog/c-unique-shared-ptr-custom-deleters/","summary":"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 […]","title":"C++ unique/shared ptr custom deleters"},{"content":"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.\nSource Code: https://github.com/comeradealexi/RaspberryPiShared\nOne of the features I wanted from my logging class was the ability for it to automatically add new line characters, it takes that extra thing to remember away from the programmer and removes the chance of printing problems in the log.\nInitially with my logging class I had it so that whenever the operator\u0026lt;\u0026lt; was invoked, it would automatically print a new line character. This meant that lines of code such as the following would result in 2 lines in the log, which is undesired. Also, every time the operator\u0026lt;\u0026lt; is invoked, it’s locking and unlocking the mutex each time which is inefficient.\nLog::Get() \u0026lt;\u0026lt; \u0026quot;Received a new door status update of: \u0026quot; \u0026lt;\u0026lt; DoorStatusToString(ds);\nSo I came up with a system whereby the operator\u0026lt;\u0026lt; for the Log class, instead of returning the same Log class, returns a Log::LogReturn class type. This little class also overloads the operator\u0026lt;\u0026lt; and writes data to the log but keeps track if it has written anything to the log. When the destructor for the Log::LogReturn class is invoked, it will only print a new line character if nothing has been written to it. This results in the desired behaviour where the final call to the operator\u0026lt;\u0026lt;, where nothing is written, a new line character is added and the mutex is unlocked.\nWith the above code working well, this also allowed me to make the initial call to the Log class to add extra information to the output such as the current date and time as well as the thread id.\nBelow is a snapshot of the entire log class at the time of publishing this post, see GitHub for the latest version.\n#pragma once #include \u0026lt;iostream\u0026gt; #include \u0026lt;ostream\u0026gt; #include \u0026lt;istream\u0026gt; #include \u0026lt;mutex\u0026gt; #include \u0026lt;stdarg.h\u0026gt; #include \u0026lt;fstream\u0026gt; #include \u0026lt;iomanip\u0026gt; // put_time #include \u0026lt;chrono\u0026gt; // chrono::system_clock #include \u0026lt;ctime\u0026gt; // localtime #include \u0026lt;sstream\u0026gt; // stringstream #include \u0026lt;ctime\u0026gt; #include \u0026lt;string\u0026gt; // string #include \u0026lt;thread\u0026gt; class Log { private: std::ofstream m_LogFile; std::mutex m_LogMutex; public: //The LogReturn is used to ensure when the LogReturn destructor is called, it writes the newline to the end of the current line. //Since there is never an actual LogReturn struct LogReturn { LogReturn(Log\u0026amp; log) : m_Log(log) { } ~LogReturn() { if (m_bWrittenTo == false) { m_Log.m_LogFile \u0026lt;\u0026lt; \u0026#34;\\n\u0026#34;; m_Log.m_LogFile.flush(); std::cout \u0026lt;\u0026lt; \u0026#34;\\n\u0026#34;; m_Log.m_LogMutex.unlock(); } } template \u0026lt;typename T\u0026gt; LogReturn operator\u0026lt;\u0026lt;(const T\u0026amp; TData) { m_bWrittenTo = true; m_Log.m_LogFile \u0026lt;\u0026lt; TData; std::cout \u0026lt;\u0026lt; TData; return LogReturn(m_Log); } Log\u0026amp; m_Log; bool m_bWrittenTo = false; }; Log() { OpenLog(); } ~Log() { CloseLog(); } static inline Log\u0026amp; Get() { static Log log; return log; } static std::string Return_current_time_and_date() { auto now = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(now); std::stringstream ss; ss \u0026lt;\u0026lt; \u0026#34;(\u0026#34; \u0026lt;\u0026lt; std::this_thread::get_id() \u0026lt;\u0026lt; \u0026#34;) \u0026#34;; ss \u0026lt;\u0026lt; std::put_time(std::localtime(\u0026amp;in_time_t), \u0026#34;%Y-%m-%d %X: \u0026#34;); return ss.str(); } static std::string ToString(const std::chrono::system_clock::time_point\u0026amp; timePoint) { auto in_time_t = std::chrono::system_clock::to_time_t(timePoint); std::stringstream ss; ss \u0026lt;\u0026lt; std::put_time(std::localtime(\u0026amp;in_time_t), \u0026#34;%Y-%m-%d %X\u0026#34;); return ss.str(); } //Allows writing to ofstream as well as cout! template \u0026lt;typename T\u0026gt; LogReturn operator\u0026lt;\u0026lt;(const T\u0026amp; TData) { m_LogMutex.lock(); m_LogFile \u0026lt;\u0026lt; Return_current_time_and_date(); m_LogFile \u0026lt;\u0026lt; TData; std::cout \u0026lt;\u0026lt; TData; return LogReturn(*this); } void Printf(const char* __fmt, ...) { std::unique_lock\u0026lt;std::mutex\u0026gt; lk(m_LogMutex); const int k_bufferSize = 1024 * 1024; static char cLogBuffer[k_bufferSize]; if (m_LogFile.good()) { va_list argptr; va_start(argptr, __fmt); vsprintf(cLogBuffer, __fmt, argptr); va_end(argptr); m_LogFile \u0026lt;\u0026lt; Return_current_time_and_date(); m_LogFile \u0026lt;\u0026lt; cLogBuffer; m_LogFile.flush(); std::cout \u0026lt;\u0026lt; cLogBuffer; } } void OpenLog() { #ifdef DEBUG #define BUILD \u0026#34;DEBUG\u0026#34; #else #define BUILD \u0026#34;RELEASE\u0026#34; #endif //Use epoc time as a file log stamp std::chrono::milliseconds ms = std::chrono::duration_cast\u0026lt;std::chrono::milliseconds\u0026gt;(std::chrono::system_clock::now().time_since_epoch()); std::string strName = \u0026#34;Log_\u0026#34; BUILD \u0026#34;_\u0026#34;; strName += std::to_string(ms.count()); strName += \u0026#34;.txt\u0026#34;; std::unique_lock\u0026lt;std::mutex\u0026gt; lk(m_LogMutex); m_LogFile.open(strName.c_str(), std::ofstream::out); } void CloseLog() { *this \u0026lt;\u0026lt; \u0026#34;Exiting Program With Normal Termination\u0026#34;; std::unique_lock\u0026lt;std::mutex\u0026gt; lk(m_LogMutex); if (m_LogFile.good()) { m_LogFile \u0026lt;\u0026lt; \u0026#34;Log Closed.\u0026#34;; m_LogFile.close(); } } }; Potential Bugs:\nThe main bug I can foresee with this system is if, for some reason the user were to hold onto the Log::LogReturn class type and not have its destructor invoked at the end of a line of code. I believe I should be able to get around this however by disabling the copy/assignment operator.\n","permalink":"https://alexanderhoughton.co.uk/programming/raspberry-pic-log-class/","summary":"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: \u003ca href=\"https://github.com/comeradealexi/RaspberryPiShared\"\u003ehttps://github.com/comeradealexi/RaspberryPiShared\u003c/a\u003e One of the features […]","title":"Raspberry Pi/C++ Log Class"},{"content":"Using multiple Raspberry Pis, I’ve put together a small system to monitor my home when away.\nIn 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 us has been home withing a defined time period.\nThere are two main programs involved, the listener and the sender.\nSource Code:\nShared Files: https://github.com/comeradealexi/RaspberryPiShared\nSender: https://github.com/comeradealexi/RaspberryPiNetworkRecordSend\nListener: https://github.com/comeradealexi/RaspberryPiNetworkRecordListen\nSender:\nThe sender is a really simple little program, all it does it listen for a change on a specified GPIO port and then sends the status of the door to all clients listed in a text file.\nIn my case, the sender is hooked up to a little magnetic switch to the front door of my flat. When the status of the switch changes, it sends this change to all listeners on the network.\nIn theory the device running the sender could also run a listener program if a camera to record was also hooked up to it.\nListener:\nThis is where the bulk of the project is contained. The listener has a number of components working together:\nLANNetworkCheck: This class periodically pings multiple ip addresses on the LAN to detect if anyone is home. Currently this is just hard coded for my purposes, but would work nicely if lifted into being loaded from a file. That way multiple listeners could in theory have different rules about who it should record. Say for instance you didn’t want anyone coming into your office, you could set it only detect your phones ip address.\nSo in the event of a signal being received by a sender that a door has been opened, the program will then check if a valid ip was detected within the last 10 minutes. If so, the status change is ignored. I set it to 10 minutes to give adequate time for phones to conenct to the wifi network when entering the home.\nIf however a valid ip has not been detected in the last 10 minutes, the recording process beings. It starts off by taking a still picture with the camera and emailing the image to the specified email address. It will then start recording video indefinitely until a valid ip is connected.\nAdditionally, to handle situations where the door may have been opened but the phone not conencted to the wifi and recording has started, if a valid ip is connected within the first 10 minutes of recording, it’ll delete the recording.\nAnother feature for peace of mind is a simple status update where if a valid ip has not been detected for more than x hours, it’ll take and email a picture to a specified email address. This feature isn’t really necessary for day to day use but is nice if you are away on holiday for example.\nMy Setup:\nI’ve got a Pi Zero hooked up to the front door running the sender program.\nThen a Pi 3 and another Pi Zero both with cameras running the Listener program.\nExternal Programs Used:\nTo take/record from the camera raspivid and raspistill were used.\nTo send emails with attachments, mutt was used.\nImprovements TODO:\nThis was a fairly small project but the following features would make it much better if implemented, but it would require a lot of extra work which I don’t currently have the time to implement:\nAbility to remotely trigger picture/video taking and sending to email address. Ideally I was trying to come up with a system which would work 100% of the time, since I don’t have a static IP address on my home network, I would have to devise some sort of system where each Pi communicates with my remote server and only receive commands from it. A remote and secure website to stream video footage from cameras. I started working on something to this effect but it proved quite difficult to get it to stream reliably so this feature was parked. When a door open event is detected and video recording occurs, it would be good to have this sent to an email address or accessible via some sort of server remotely. Alex\n","permalink":"https://alexanderhoughton.co.uk/programming/raspberry-pi-home-monitoring-system/","summary":"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 […]","title":"Raspberry Pi – Home Monitoring System"},{"content":"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.\nThe entire project can be found on github here: https://github.com/comeradealexi/RPIMediaController\nPhysical Prerequisites:\nRaspberry Pi 2 (or newer, I’m unsure of previous Pi’s media playback) LAN connection for Pi (I’m using the official Raspberry Pi WiFi Dongle) Hard Drive/USB containing videos (preferably organised into folders) Any web browser to control playback. Software Prerequisites:\nWeb Server with PHP Running on Raspberry Pi (I used lighttpd see my other blog post here if you want to set this up). OMXPlayer (Comes with Raspberry Pi NOOBS by default). Optional: I used a Visual Studio 2015 Linux Project for this project, it works really well. A general overview of how all components fit together:\nJavaScript:\nHaving never written a line of JavaScript in my life, I kicked off the project by creating a checkbox system. Where it behaves as you’d expect, parents of the selected checkboxes are marked as ‘indeterminate’. I found some interesting examples which shows me how to specifically check \u0026amp; uncheck but I rewrote it to fit my needs. I could probably be more efficient as it loops over all checkboxes multiple times each time one is checked/unchecked but it works.\nfunction UpdateMarkings(event) { console.log(event); var ChangeType = event.checked; var listOfChildren = event.parentElement.parentElement.getElementsByClassName(\u0026#34;checkboxClass\u0026#34;); for (var i = 0; i \u0026lt; listOfChildren.length; i++) { listOfChildren[i].checked = ChangeType; } //Update Indeterminates var allCheckboxClasses = document.getElementsByClassName(\u0026#34;checkboxClass\u0026#34;); for (var i = allCheckboxClasses.length - 1; i \u0026gt;= 0; i--) { var allChildrenTypes = allCheckboxClasses[i].parentElement.parentElement.getElementsByClassName(\u0026#34;checkboxClass\u0026#34;); var checkCount = 0; for (var j = 1; j \u0026lt; allChildrenTypes.length; j++) { if (allChildrenTypes[j].checked) checkCount++; } if (allChildrenTypes.length \u0026gt; 1 \u0026amp;\u0026amp; (checkCount + 1) == allChildrenTypes.length) { allCheckboxClasses[i].checked = true; allCheckboxClasses[i].indeterminate = false; } else if (checkCount \u0026gt; 0) { allCheckboxClasses[i].checked = false; allCheckboxClasses[i].indeterminate = true; } else allCheckboxClasses[i].indeterminate = false; } } All the checkbox html is generated by the C++ program which recursively searches a specified folder for videos with certain file extensions (avi, mp4, m4a and mkv). It then builds up the list, assigning an ID to every checkbox which doesn’t have any children (i.e is a video file).\nWhen ‘Play Selected’ is called. A JavsScript function is called to gather a list of ID’s of all the ticked non-childen checkboxes:\nfunction GatherAllTicked() { var checkedList = []; var rejectList = []; var allCheckboxClasses = document.getElementsByClassName(\u0026#34;checkboxClass\u0026#34;); for(var i = 0; i \u0026lt; allCheckboxClasses.length; i++) { if (allCheckboxClasses[i].checked == true \u0026amp;\u0026amp; include(rejectList, allCheckboxClasses[i].id) == false) { var allChildrenTypes = allCheckboxClasses[i].parentElement.parentElement.getElementsByClassName(\u0026#34;checkboxClass\u0026#34;); var AllChildrenChecked = true; for(var j = 1; j \u0026lt; allChildrenTypes.length; j++) { if (allChildrenTypes[j].checked == false) AllChildrenChecked = false; } if (AllChildrenChecked == true) { //checkedList.push(allCheckboxClasses[i].id); for(var j = 1; j \u0026lt; allChildrenTypes.length; j++) { if (allChildrenTypes[j].name == \u0026#34;file\u0026#34;) checkedList.push(allChildrenTypes[j].id); else rejectList.push(allChildrenTypes[j].id); } } } } return checkedList; } JQuery \u0026amp; Ajax is used to call a php script and POST the list.\nThe other bit of JavaScript in the project is to call a PHP script periodically which opens a file, containing the name of the current playing video. This is then shown on the web page.\nPHP:\nThe PHP in this project is fairly simple, all the scripts simple open a file and either read/write to them. In some cases it’s just a normal file and others it’s a FIFO file so it can directly communicate with the running C++ program.\nThe PHP script below receives a ‘cmd’ url parameter containing a single character which is sent to the C++ program to Pause/Play/Change Volume/Stop etc.\nCurrently the PHP scripts just have hard coded paths, a more elegant, dynamic solution would be nice.\n\u0026lt;?php $paramAdded = $_GET[\u0026#39;cmd\u0026#39;]; $stdInFilePath = \u0026#39;/home/pi/projects/RaspberryPiPlayer/bin/ARM/Debug/thefifofile\u0026#39;; //\u0026#39;/proc/\u0026#39; . $pidTxt . \u0026#39;/fd/1\u0026#39;; file_put_contents(\u0026#39;cmd.txt\u0026#39;, $paramAdded); $pStdInFile = fopen($stdInFilePath, \u0026#39;w\u0026#39;); if ($pStdInFile \u0026amp;\u0026amp; $paramAdded) { fwrite($pStdInFile, $paramAdded); fwrite($outputFile, \u0026#34;Writing to the std in\\n\u0026#34;); fclose($pStdInFile); } ?\u0026gt; C++ Program:\nThe majority of coding for this project was in the C++ program. Which fills key roles:\nListens for input via FIFO file from PHP scripts. Makes system calls to omxplayer, via a pipe to write keyboard input directly to it. Generate the html list of checkboxes. It’s all contained in a single .cpp file, you can see it on the github repository linked at the top of this post.\nBelow is the recursive function to generate the checkbox html. The LookupList is a std::map\u0026lt;int,std::string\u0026gt;. So when we get commands through from the PHP with a list of video ID’s they can quickly be looked up in the map and the full file path of the video obtained.\nvoid RecursivelyBuildListHtml(char* pszPath, FILE* pOutputFile, const char* pPrevName, int iDepth, int\u0026amp; ID, LookupList\u0026amp; lookupList) { char tmpPath[1024]; DIR* dp = opendir(pszPath); dirent* dirp; if (dp == nullptr) return; while ((dirp = readdir(dp)) != NULL) { if (dirp-\u0026gt;d_type == DT_DIR || dirp-\u0026gt;d_type == DT_REG) { if (dirp-\u0026gt;d_type == DT_DIR \u0026amp;\u0026amp; ShouldIgnoreDir(dirp-\u0026gt;d_name)) continue; if (dirp-\u0026gt;d_type == DT_REG \u0026amp;\u0026amp; ShouldIgnoreReg(dirp-\u0026gt;d_name)) continue; snprintf(tmpPath, sizeof(tmpPath), \u0026#34;%s/%s\u0026#34;, pszPath, dirp-\u0026gt;d_name); const char* displayType = iDepth \u0026gt;= 0 ? \u0026#34;display: none;\u0026#34; : \u0026#34;display: ;\u0026#34;; const char* szName = dirp-\u0026gt;d_type == DT_REG ? \u0026#34;name=\\\u0026#34;file\\\u0026#34;\u0026#34; : \u0026#34;\u0026#34;; if (dirp-\u0026gt;d_type == DT_REG) lookupList[ID] = tmpPath; fprintf(pOutputFile, \u0026#34;\u0026lt;li\u0026gt;\u0026#34; \u0026#34;\u0026lt;img style=\\\u0026#34;width:15px; height:15px; background - color: lightblue;\\\u0026#34; src=\\\u0026#34;down.png\\\u0026#34; onclick=\\\u0026#34;dropdownfunction(this)\\\u0026#34;\u0026gt;\u0026lt;/img\u0026gt;\u0026#34; \u0026#34;\u0026lt;label\u0026gt;\u0026lt;input %s onclick=\\\u0026#34;UpdateMarkings(this)\\\u0026#34; type=\\\u0026#34;checkbox\\\u0026#34; id=\\\u0026#34;%s\\\u0026#34; class=\\\u0026#34;checkboxClass\\\u0026#34;\u0026gt;%s\u0026lt;/label\u0026gt;\\n\u0026#34;, szName, std::to_string(ID++).c_str(), dirp-\u0026gt;d_name); if (dirp-\u0026gt;d_type == DT_DIR) { fprintf(pOutputFile, \u0026#34;\u0026lt;ul style=\\\u0026#34;%s\\\u0026#34;\u0026gt;\\n\u0026#34;, displayType); RecursivelyBuildListHtml(tmpPath, pOutputFile, dirp-\u0026gt;d_name, iDepth + 1, ID, lookupList); fprintf(pOutputFile, \u0026#34;\u0026lt;/ul\u0026gt;\\n\u0026#34;); } fprintf(pOutputFile, \u0026#34;\u0026lt;/li\u0026gt;\\n\u0026#34;); } } } Thoughts about this project:\nThis is a little project I’ve really enjoyed working on because it has taught me a lot of new things about Linux, the Raspberry Pi and especially JavaScript. Having not written any JavaScript before, I felt this was a really good way to get a good overview of how it works and how it can be used to communicate with a running C++ project. I’ve no doubt what I’ve learnt from this project will be useful again in the future.\nThe great thing about this project is that I’m genuinely going to use what I’ve created and it will be super handy.\nImprovements To Be Made:\nI’m no graphic designer and the web page I’ve created doesn’t look that appealing. The web page isn’t super mobile friendly. The C++ program contains the header and footer of the html web page, ideally this would be in its own Index.html page, then there would be a php script to fetch the cached checkbox lists from a file. Currently the program will play the selection at random, it would be good to have a choice to play the selection in alphabetical order. If you’ve got someone evil on your WiFi they’ll be able to fully control it as much as anyone else, so beware! ","permalink":"https://alexanderhoughton.co.uk/programming/raspberry-pi-web-controlled-media-player/","summary":"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 […]","title":"Raspberry Pi – Web Controlled Media Player"},{"content":"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.\nThe part I got stuck on was that on a reboot, the folder in /var/run/lighttpd would be re-created with permissions for only the www-data user and not ‘pi’ which I had changed the service to run as. So below are the full steps I had to go through to change the default user and everything is now working nicely, even after a reboot. (Skip to step 5 for this fix).\n1) Ensure the service is stopped:\nsudo service lighttpd stop 2) Modify /etc/lighttpd/lighttpd.conf to change the default user. Change ‘www-data’ to ‘pi’ or whatever user you want to change it to. For the rest of this guide, I’ll be using pi.\nsudo nano /etc/lighttpd/lighttpd.conf Ctrl+X then Y and hit enter with nano to save the changes.\n3) Modify /etc/init.d/lighttpd. Change ‘www-data’ to ‘pi’.\nsudo nano /etc/init.d/lighttpd from: install -d -o www-data -g www-data -m 0750 \u0026#34;/var/run/lighttpd\u0026#34; to: install -d -o pi -g pi -m 0750 \u0026#34;/var/run/lighttpd\u0026#34; 4) Then we can modify the owner and permissions of existing folders, run each of these commands:\nsudo chown -R pi:pi /var/log/lighttpd sudo chown -R pi:pi /var/run/lighttpd sudo chown -R pi:pi /var/cache/lighttpd 5) Modify /usr/lib/tmpfiles.d/lighttpd.tmpfile.conf and change www-data to pi. This is the part which was stopping it from working for me after a reboot.\nsudo nano /usr/lib/tmpfiles.d/lighttpd.tmpfile.conf from: d /var/run/lighttpd 0750 www-data www-data - to: d /var/run/lighttpd 0750 pi pi - 6) Save the file then reboot.\nsudo reboot If you’re still having issues, look into the following log files to see why it’s failing to startup lighttpd:\n(to go to the bottom of a file open in ‘nano’ hit CTRL + _ (that’s ctrl + underscore) and then CTRL + V):\nsudo nano /var/log/syslog sudo nano /var/log/lighttpd/error.log I also had run the following commands prior to me getting it working so I’m unsure if these will help:\nsudo usermod -a -G www-data pi sudo usermod -a -G pi www-data Hope this helps someone else out there, took my ages to get it working properly after a reboot.\n","permalink":"https://alexanderhoughton.co.uk/blog/lighttpd-changing-default-user-raspberry-pi/","summary":"After following the great tutorial here (\u003ca href=\"http://www.penguintutor.com/linux/light-webserver\"\u003ehttp://www.penguintutor.com/linux/light-webserver\u003c/a\u003e) 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 […]","title":"lighttpd – Changing default user (Raspberry Pi)"},{"content":"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%…\n#include \u0026lt;stdio.h\u0026gt; #include \u0026lt;thread\u0026gt; #include \u0026lt;vector\u0026gt; #include \u0026lt;mutex\u0026gt; #include \u0026lt;atomic\u0026gt; class WorkerThread { public: WorkerThread(const char* szName) : m_threadName(szName) , m_thread(\u0026amp;WorkerThread::WorkerLoop, this) { } ~WorkerThread() { m_bFinished = true; m_thread.join(); } private: void WorkerLoop() { m_mutex.lock(); printf(\u0026#34;run once\u0026#34;); m_mutex.unlock(); } std::thread\tm_thread; std::atomic_bool\tm_bFinished = false; std::string\tm_threadName; std::mutex\tm_mutex; }; int main() { WorkerThread workThread(\u0026#34;first worker thread\u0026#34;); return 0; } Fix: Basically what’s happening is that because I was creating the thread during the class constructor, it would start running that thread while the class was still being constructed. So it is possible and extremely likely that when the newly spawned thread attempts to lock the mutex for the first time, the mutex hasn’t even been initalised during the class constructor yet! An interesting little thread related bug and a dangerous one too! Could easily go unnoticed if by luck it didn’t crash on your machine.\n","permalink":"https://alexanderhoughton.co.uk/blog/stdmutex-crash-on-initial-lock-interesting-thread-releated-bug-with-fix-included/","summary":"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 \u0026lt;stdio.h\u0026gt; #include \u003cthread\u003e #include \u003cvector\u003e #include \u003cmutex\u003e #include \u003catomic\u003e […]","title":"std::mutex crash on initial lock (Interesting thread releated bug with fix included!)"},{"content":"For this guide I’ll be showing how I got my Huawei E303 Mobile Dongle to with with Gammu on the Raspberry Pi to send and receive SMS messages. This is the specific Huawei E303 I used.\nWhen I first started out, I was hoping it would just a be a case of plugging in the modem, running Gammu and all would be well but things are never that easy! The main hurdle is that the Mobile Dongle, as with many others has different modes which it can function in. The Huawei E303 has 3 different modes of function, these are in the table listed below. The problem is that by default the device is in the USB Mass Storage Mode, not very useful if we wan’t to used it for 3G Internet or in Modem mode to send SMS Messages!\nLuckily there is a tool out there called USB_ModeSwitch to help us greatly. It is described as: “A mode switching tool for controlling ‘multi-mode’ USB devices.”\nWith the following details: ‘More and more USB devices (especially high-speed WAN stuff, based on cell phone chipsets which are able to change their USB connection mode) have their MS Windows drivers onboard; when plugged in for the first time they act like a flash storage and start installing the driver from there. After installation (and on every consecutive plugging) the driver switches the mode internally, the storage device vanishes (in most cases), and a new device (like an USB modem) shows up. Modem maker “Option” calls that feature “ZeroCD (TM)” since it eliminates the need for shipping a separate driver carrier.’\nBy running the following command to view USB devices we can see what mode our device is in:\nlsusb It should yield something like the following for a Raspberry Pi\nBus 001 Device 005: ID 12d1:1f01 Huawei Technologies Co., Ltd. Bus 001 Device 004: ID 148f:5372 Ralink Technology, Corp. RT5372 Wireless Adapter Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Make a note of the ID of your Modem, in my case the ID is: 12d1:1f01.\nWe can now install USB_ModeSwitch with the following command (note it is a ‘-‘ rather than a ‘_’):\nsudo apt-get install usb-modeswitch After installing, reboot your device.\nsudo reboot If you now run the lsusb command again, your device mode should have switched. usb_modeswitch will, by default put your device into the 3G Mobile Internet mode. For me, the result is below. Notice how the ID has changed from 12d1:1f01 to 12d1:14dc.\nBus 001 Device 006: ID 12d1:14dc Huawei Technologies Co., Ltd. If you just intend to use your modem for Internet, then you are done! Running ifconfig while in this mode for me reveals a new ethernet adapter.\nUSB modes Huawei E303 / E353 (3.se) ID lsusb name mode 12d1:1f01 Huawei Technologies Co., Ltd. USB Mass Storage 12d1:14dc Huawei Technologies Co., Ltd. 3G Internet 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem Modem SMS/Modem Mode:\nContinue with the rest of this guide if you want to put the device into Modem mode so you can use it to send SMS messages. This is where things get a little trickier because we have to do a lot more manually.\nThere is a configuration file for each adapter that usb_modeswitch creates which is placed inside a compressed folder. We need to extract the configuration file for our modem so we can edit it, to put it in a different mode.\nUsing the original ID we made a note of at the very start, run the following command, putting your ID at the end so that we can extract the file.\nsudo tar -xzvf /usr/share/usb_modeswitch/configPack.tar.gz 12d1:1f01 Some other tutorial recommend formatting the file name as 12d1:1f01 if you are having issues.\nOpening the extracted file gave me the following:\nsudo nano /usr/share/usb_modeswitch/12d1:1f01 # Huawei E353 (3.se) and others TargetVendor=0x12d1 TargetProductList=\u0026#34;14db,14dc\u0026#34; HuaweiNewMode=1 NoDriverLoading=1 With the file open in the editor of your choice (or by running the nano command above) we now want to edit the file.\nNow this is the part that will be pretty different for different types of modems, by searching around I was able to find from this post here http://askubuntu.com/questions/489936/huawei-e3531-view-signal-strength of what to change the contents of the file to. From what I’ve seen, if you search around your specific model or similar ones, you should be able to find what you need to paste into the file.\nI completely replaced the contents of the file with the following:\n# Huawei E3531s-2 - switch to modem mode instead of HiLink CDC-Ether mode TargetVendor=0x12d1 TargetProduct=0x1f01 # switch to 12d1:1001 (modem mode, 3 virtual serial ports) MessageContent=\u0026#34;55534243123456780000000000000011062000000100000000000000000000\u0026#34; After changing the contents of the file, reboot your device.\nsudo reboot After rebooting your device and running the lsusb command, your device should now be in Modem mode:\nBus 001 Device 006: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem Gammu:\nOnce you’ve got to this stage, getting Gammu running is pretty easy. There are tons of great tutorials for getting Gammu working, here is the one I used: http://www.mattiasnorell.com/send-sms-from-a-raspberry-pi/\n","permalink":"https://alexanderhoughton.co.uk/blog/guide-sending-an-sms-with-raspberry-pilinux-huawei-e303-mobile-dongle/","summary":"For this guide I’ll be showing how I got my Huawei E303 Mobile Dongle to with with Gammu on the Raspberry Pi to send and receive SMS messages. This is the specific Huawei E303 I used. When I first started out, I was hoping it would just a be a case of plugging in the […]","title":"Guide: Sending an SMS with Raspberry Pi/Linux – Huawei E303 Mobile Dongle"},{"content":"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 had a power supply behave so inconsistently. We’d have the computer stress testing for over 48 hours straight without any problems but the next day, it’ll power off in the first few minutes.\nImage Source So we came up with a little test involving a raspberry pi in order to test the reliability of the power supply. Since we didn’t have a spare power supply to use, we needed a way of proving if it was the motherboard shutting off or the power supply giving up.\nWe used the common method of making a connection between ports 16 and 17, as shown in the image to the right to force the power supply to turn out without being connected to a motherboard. We also connected a few peripherals such as fans, leds and hard drives to give the power supply a fair test so that it was under at least some sort of load.\nSo using the raspberry Pi, I wrote a simple little program to read the status of a GPIO pin which was connected to the 5V line on one of the power supplies 4-pin molex connections.\nI popped a few resistors in too to split the load so that I didn’t risk damaging the Pi.\nI won’t post the source code since it was quickly hacked together and a mess but here is the basic flow:\nWHILE TRUE { IF ( GPIO INPUT IS FALSE) //Stopped Receiving Power... { RECORD TIMESTAMP WHILE GPIO INPUT IS FALSE {} RECORD TIMESTAMP PRINT HOW LONG POWER CUT FOR } } Leaving it running, we’d get a lot of messages saying the power had been cut for about 3 microseconds, which I’ve put down just to noise/normal operation but there were times where it reported that there was no power for around 36000 microseconds. I’m not an expert by any means but I’m pretty sure a good, solid power supply should not be cutting out power for that period of time!\nThe end result is we bought a new power supply and the computer runs perfectly now 🙂 It was an interesting small Pi project none the less to help confirm a problem with the power supply which we are now returning.\nAlex\n","permalink":"https://alexanderhoughton.co.uk/blog/using-raspberry-pi-to-test-power-supply-reliability/","summary":"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 […]","title":"Using Raspberry Pi to test Power Supply Reliability"},{"content":"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!\nCompile 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 the project. You may have installed your SysGCC elsewhere but mine is the following path:\n*C:\\SysGCC\\raspberry\\arm-linux-gnueabihf\\sysroot\\usr\\include\\arm-linux-gnueabihf\\c++\\4.9*\nYou’ll be adding the include file via VisualGDB’s project settings rather than the normal Visual Studio ones.\nRight click on the project and hit VisualGDB Project Properties, go to the Makefile settings tab and add the path to the include directories.\nCompiling VisualGDB with root/sudo access: If you need to run your application with increased privileges as a super user, you’ll want to go to your VisualGDB project properties, go onto the Debug settings tab and then tick the box ‘Run debugger as root with sudo’ as seen in the screenshot below. For some reason, I had real issues attempting to log into my Pi as root, it kept telling me my password was invalid even after changing it so this was the alternative solution. You’ll need to do this if you want to make use of the GPIO ports on your Pi.\n","permalink":"https://alexanderhoughton.co.uk/blog/problems-with-visualgdb-and-raspberry-pi-2/","summary":"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 […]","title":"Problems with VisualGDB and Raspberry Pi 2"},{"content":"Had a similar problem to Jeroen Swart to do with Cookies in Windows Phone as he mentioned in his blog post here.\nBasically identical C# code to make a HttpWebRequest with a few cookies would work in a simple desktop app but no cookies would be sent at all in Windows Phone.\nMy code to add cookies to a CookieContainer:\ncookies.Add(new Uri(\u0026#34;https://alexanderhoughton.co.uk/\u0026#34;), new Cookie(\u0026#34;TestCookie\u0026#34;, \u0026#34;TestCookieValue\u0026#34;, \u0026#34;/\u0026#34;, \u0026#34;alexanderhoughton.co.uk\u0026#34;)); The fix was to remove the path and domain strings from the Cookie constructor! As Jeroen mentioned in his blog, it’s something to do with the ‘.’ prefix etc.\nWorking Code:\ncookies.Add(new Uri(\u0026#34;https://alexanderhoughton.co.uk/\u0026#34;), new Cookie(\u0026#34;TestCookie\u0026#34;, \u0026#34;TestCookieValue\u0026#34;)); Cookies now are sent successfully.\n","permalink":"https://alexanderhoughton.co.uk/blog/c-httpwebrequest-not-sending-cookies-on-windows-phone/","summary":"Had a similar problem to Jeroen Swart to do with Cookies in Windows Phone as he mentioned in his blog post here. Basically identical C# code to make a HttpWebRequest with a few cookies would work in a simple desktop app but no cookies would be sent at all in Windows Phone. My code to […]","title":"[C#] HttpWebRequest not sending Cookies on Windows Phone"},{"content":"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 (At least until Valve releases their own official one!)\nSome of the key features are as follows:\nPin your profile to a live tile showcasing your latest games, playtime and other useful information. Get the latest Steam News with images directly on a Live Tile. Pin Steam Status information provided by SteamStat.us right to your homescreen on a live tile! View your friends list, games list, profile information, inventory, VAC ban status and much more in the application. Embracing the beautiful Windows Phone styling coupled with Steam colour schemes and utilising users profile background images. Store Download Link:http://windowsphone.com/s?appid=6fb43bb9-07c3-48f5-a5cf-cfefb1b539ba\nTechnical Stuff about this update:\nMemory usage has been greatly improved in the latest update and more memory improvements will be coming to the application to keep it running properly on devices with 512MB of RAM. A while back when the application was more primitive, it would have just let the phone download every single image in a list. For example, when downloading all the users games and displaying them in a long list, it would download the image for every single game.\nWhen you get folks with steam libraries 600+ games, the phones quickly run out of memory and crash! I’ve now implemented a much more efficient system where it will only downloaded the maximum number of images that can be seen on screen at any one time. For the Inventory for example, it won’t download/store more than 6 images in memory at any one time. The 6 images stored in memory are updated as you scroll down/up the list of items so it will only ever download the images in view and delete the ones that aren’t.\nSomething else which is a small change but makes a big difference is detecting which part of the panorama a user is currently on and not downloading the data for that part until the user is actually viewing it. For example, nothing to do with the inventory happens until you pan onto the Inventory panorama item, at which point it will fetch the users inventory and fill the list box.\nThe same goes with all other panorama items, the friends and owned games lists won’t be populated and images downloaded until it is in view of the user, it’s a small change but really improves performance and reduces data usage.\n","permalink":"https://alexanderhoughton.co.uk/blog/steam-live-gets-a-huge-update/","summary":"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 […]","title":"Steam Live gets a huge update."},{"content":"Problem:\nTry 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:)\npublic class cDescriptions { public string appid { get; set; } public string classid { get; set; } public string instanceid { get; set; } public string icon_url { get; set; } public string icon_url_large { get; set; } public string icon_drag_url { get; set; } public string name { get; set; } public string market_hash_name { get; set; } public string market_name { get; set; } public string name_color { get; set; } public string background_color { get; set; } public string type { get; set; } public int tradable { get; set; } public int marketable { get; set; } public int commodity { get; set; } public string market_fee_app { get; set; } public string market_tradable_restriction { get; set; } public string market_marketable_restriction { get; set; } } Renaming the ‘type’ member variable to anything else causes it to compile and run perfectly.\nI tested this on my vs 2012 and 2013 and it failed, I can declare this class on vs 2015.\nLink to StackOverflow where I raised this question.\nThe fix \u0026amp; the cause:\nUpon disabling AVAST Antivirus, it worked perfectly! Avast was interfering silently without telling me and causing me these weird issues.\n","permalink":"https://alexanderhoughton.co.uk/blog/c-class-member-variable-called-type-causes-weird-compile-issues-caused-by-avast-antivirus/","summary":"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 […]","title":"C#: Class Member variable called ‘type’ causes weird compile issues caused by AVAST Antivirus."},{"content":"Came across a very weird problem today that has occurred on my application Steam Live which I’ve never come across before…\nOn a certain Steam Profile I’d get a crash with the following message: “Layout cycle detected. Layout could not complete.”\nAfter a lot of searching, confusion and everything else I’ve managed to find a fix which I have no idea why it works.\nFix:\nChanging the font size of one of my TextBlocks from 21 to any other value.\nFinding the problem:\nI’ve had a look around at it appears a lot of other people have had problems with the LongListSelector. In future I will be avoiding it as it is clearly buggy and has weird things going on.\nMy method for finding the problem was to incrementally remove XAML controls from my LongListSelector until it started working. Once I removed the right one it was a case of seeing what was different about it from the others.\nEntire XAML:\n\u0026lt;phone:LongListSelector x:Name=\u0026#34;OwnedGameListBox\u0026#34; Tap=\u0026#34;OwnedGameListBoxTap\u0026#34; ScrollViewer.VerticalScrollBarVisibility=\u0026#34;Disabled\u0026#34; ItemRealized=\u0026#34;OwnedGameListBox_ItemRealized\u0026#34; ItemUnrealized=\u0026#34;OwnedGameListBox_ItemUnrealized\u0026#34; BorderThickness=\u0026#34;0,20,0,0\u0026#34; \u0026gt; \u0026lt;phone:LongListSelector.ItemTemplate\u0026gt; \u0026lt;DataTemplate\u0026gt; \u0026lt;StackPanel Orientation=\u0026#34;Vertical\u0026#34; Tap=\u0026#34;OwnedGameListBoxTap\u0026#34; Margin=\u0026#34;0,0,0,12\u0026#34;\u0026gt; \u0026lt;StackPanel Orientation=\u0026#34;Horizontal\u0026#34; HorizontalAlignment=\u0026#34;Left\u0026#34; VerticalAlignment=\u0026#34;Top\u0026#34; Margin=\u0026#34;10,10,0,0\u0026#34; Tap=\u0026#34;StackPanel_Tap_1\u0026#34;\u0026gt; \u0026lt;Image Width=\u0026#34;60\u0026#34; Source=\u0026#34;{Binding getSmallImageActualURL}\u0026#34; Height=\u0026#34;60\u0026#34; Margin=\u0026#34;3\u0026#34; VerticalAlignment=\u0026#34;Top\u0026#34; /\u0026gt; \u0026lt;StackPanel Margin=\u0026#34;15,0,0,0\u0026#34;\u0026gt; \u0026lt;TextBlock Width=\u0026#34;320\u0026#34; TextWrapping=\u0026#34;Wrap\u0026#34; Text=\u0026#34;{Binding name}\u0026#34; Margin=\u0026#34;0,0,0,0\u0026#34; FontSize=\u0026#34;32\u0026#34; /\u0026gt; \u0026lt;TextBlock Text=\u0026#34;{Binding getTotalPlaytimeFormatted}\u0026#34; Margin=\u0026#34;0,0,0,0\u0026#34; TextWrapping=\u0026#34;Wrap\u0026#34; FontSize=\u0026#34;21\u0026#34; \u0026gt; \u0026lt;TextBlock.Foreground\u0026gt; \u0026lt;SolidColorBrush Color=\u0026#34;{StaticResource PhoneAccentColor}\u0026#34;/\u0026gt; \u0026lt;/TextBlock.Foreground\u0026gt; \u0026lt;/TextBlock\u0026gt; \u0026lt;/StackPanel\u0026gt; \u0026lt;/StackPanel\u0026gt; \u0026lt;/StackPanel\u0026gt; \u0026lt;/DataTemplate\u0026gt; \u0026lt;/phone:LongListSelector.ItemTemplate\u0026gt; \u0026lt;/phone:LongListSelector\u0026gt; Fixed:\n\u0026lt;TextBlock Text=\u0026#34;{Binding getTotalPlaytimeFormatted}\u0026#34; Margin=\u0026#34;0,0,0,0\u0026#34; TextWrapping=\u0026#34;Wrap\u0026#34; FontSize=\u0026#34;20\u0026#34; \u0026gt; ","permalink":"https://alexanderhoughton.co.uk/blog/windows-phone-c-layout-cycle-detected-layout-could-not-complete-on-longlistselector-fix/","summary":"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 […]","title":"Windows Phone C#: “Layout cycle detected.  Layout could not complete.” on LongListSelector Fix"},{"content":"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.\nThe problem is caused by the following code in DeviceResources.cpp:\nDX::ThrowIfFailed( m_swapChain-\u0026gt;SetRotation(displayRotation) ); Since the window size being created is always the right size because in Windows Phone 8.1 the Bounds of the CoreWindow are reported correctly, we don’t actually need to rotate the swap buffer at all!\nEither remove the code above or simple change it to:\nDX::ThrowIfFailed( m_swapChain-\u0026gt;SetRotation(DXGI_MODE_ROTATION_IDENTITY) ); And it’s fixed! I hope this has helped 🙂\n","permalink":"https://alexanderhoughton.co.uk/blog/windows-phone-8-1-directx-sample-landscape-mode-broken-rotation-doesnt-work/","summary":"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 […]","title":"Windows Phone 8.1 DirectX Sample Landscape mode broken / rotation doesn’t work."},{"content":"Something I’ve always enjoyed programming is input via a controller, I’d dabbled with Microsoft’s XINPUT classes for the Xbox 360 controller before and I found it really interesting so I decided to put together a collection of classes which would allow detection of common input scenarios for video games.\nAs it currently stands, the specific detections I’ve created are:\nQTE from Heavy Rain Thumb Stick Rotation. As commonly found in Quick Time Events in games, this is used to detect if a certain thumb stick is moved from a certain position to another in a circular motion. This is achieved by imagining the thumb stick as a circle and splitting it up into slices and detecting which is the thumb stick is currently situated in. You can set how many slices you want the circle to be separated into for enhanced accuracy. The class supports rotation from any point 360 degrees back to the start or any position in between.\nButton Mash. This one is fairly simple, when a specified button is mashed fast enough for long enough. I’ve achieved this by having a value which starts at zero, then is increased x amount each time the button is pressed. Once the value reaches 1.0, then the button has been mashed sufficiently. Of course, the value is always decreasing by a small amount each update so you have to be quick to reach 1.0!\nButton Combo: Exactly the kind of thing you’d find in every fighting game.\nFunction Pointers:\nSomething I hadn’t used in C++ before that I became extremely familiar with by the end of this project was function pointers, I knew they existed in C++ and the idea behind them seemed really powerful to me so I decided to design all the classes in this project around passing function pointers.\nThe most difficult part of this came when creating the button combo class where I planned to pass in a list of function pointers to the specific buttons that must be pressed in order. This got slightly confusing when having to deal with pointers to pointers and arrays at the same time, but through using typedef’s and reading + understanding compile time errors I was able to overcome these problems.\ntypedef float (XInputHandler::*XInputFctnPtr) (); typedef float (XInputHandler::*XInputFctnPtrArray[MAX_BUTTON_COMBO_SEQUENCE]) (); Extra Stuff:\nIn order to possibly make all input types interchangeable, every method of input on the controller is evaluated by returning a float so that the A button for example can be swapped out with the right trigger easily.\nCode:\nXInputHandler:\n#include \u0026#34;XInputHandler.h\u0026#34; XInputHandler::XInputHandler(PlayerIndex playerIndex) { this-\u0026gt;playerNum = playerIndex; } XInputHandler::~XInputHandler() { } bool XInputHandler::isControllerConnected() { DWORD error = XInputGetState(playerNum, \u0026amp;xInputControllerState); if (error == ERROR_DEVICE_NOT_CONNECTED) return false; else return true; } bool XInputHandler::Update(float fDT) { //Return false if no longer connected. DWORD error = XInputGetState(playerNum, \u0026amp;xInputControllerState); if (error == ERROR_DEVICE_NOT_CONNECTED) return false; else return true; } float XInputHandler::getLeftTrigger() { return xInputControllerState.Gamepad.bLeftTrigger / MAX_BYTE_SIZE; } float XInputHandler::getRightTrigger() { return xInputControllerState.Gamepad.bRightTrigger / MAX_BYTE_SIZE; } float XInputHandler::getLeftStickX() { if (xInputControllerState.Gamepad.sThumbLX == 32767) return 1.0f; return (float)xInputControllerState.Gamepad.sThumbLX / MAX_INT_SIZE; } float XInputHandler::getLeftStickY() { if (xInputControllerState.Gamepad.sThumbLY == 32767) return 1.0f; return (float)xInputControllerState.Gamepad.sThumbLY / MAX_INT_SIZE; } float XInputHandler::getRightStickX() { if (xInputControllerState.Gamepad.sThumbRX == 32767) return 1.0f; return (float)xInputControllerState.Gamepad.sThumbRX / MAX_INT_SIZE; } float XInputHandler::getRightStickY() { if (xInputControllerState.Gamepad.sThumbRY == 32767) return 1.0f; return (float) xInputControllerState.Gamepad.sThumbRY / MAX_INT_SIZE; } Vector2 XInputHandler::getLeftStickVector() { return Vector2(getLeftStickX(), getLeftStickY()); } Vector2 XInputHandler::getRightStickVector() { return Vector2(getRightStickX(), getRightStickY()); } float XInputHandler::getButtonDownA() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_A) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownB() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_B) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownX() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_X) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownY() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_Y) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownStart() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_START) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownBack() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_BACK) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownLeftBumper() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_LEFT_SHOULDER) return 1.0f; else return 0.0f; } float XInputHandler::getButtonDownRightBumper() { if (xInputControllerState.Gamepad.wButtons \u0026amp; XINPUT_GAMEPAD_RIGHT_SHOULDER) return 1.0f; else return 0.0f; } ThumbStickRotate:\n#include \u0026#34;ThumbStickRotate.h\u0026#34; #include \u0026lt;iostream\u0026gt; ThumbStickRotate::ThumbStickRotate(XInputHandler *inputHandler, float startPos, float endPos) { this-\u0026gt;inputHandler = inputHandler; currentPosition = 0; float stepSize = (endPos - startPos) / NUMBER_OF_SEGMENTS; if (endPos \u0026lt; startPos) bRotateClockwise = false; else bRotateClockwise = true; for (int i = 0; i \u0026lt; NUMBER_OF_SEGMENTS; i++) angleSteps[i] = startPos + (stepSize * i); } bool ThumbStickRotate::Update() { Vector2 newVec = inputHandler-\u0026gt;getLeftStickVector(); if (newVec.getMag() \u0026lt; 0.5f) { currentPosition = 0; return false; } float fAngle = newVec.getAngle(); if (newVec.fX \u0026lt; 0.0f) fAngle = 360 - fAngle; std::cout \u0026lt;\u0026lt; \u0026#34;fangle: \u0026#34; \u0026lt;\u0026lt; fAngle \u0026lt;\u0026lt; \u0026#34; currentPos: \u0026#34; \u0026lt;\u0026lt; angleSteps[currentPosition] \u0026lt;\u0026lt; std::endl; } bool ThumbStickRotate::UpdateClockwise(float fAngle) { if (fAngle \u0026gt; angleSteps[currentPosition]) { if (currentPosition == (NUMBER_OF_SEGMENTS - 1)) { currentPosition = 0; return true; } else if (fAngle \u0026lt; angleSteps[currentPosition + 1]) currentPosition++; } return false; } bool ThumbStickRotate::UpdateAntiClockwise(float fAngle) { if (fAngle \u0026lt; angleSteps[currentPosition]) { if (currentPosition == (NUMBER_OF_SEGMENTS - 1)) { currentPosition = 0; return true; } else if (fAngle \u0026gt; angleSteps[currentPosition + 1]) currentPosition++; } return false; } ThumbStickRotate::~ThumbStickRotate() { this-\u0026gt;inputHandler = nullptr; } ButtonMash:\n#include \u0026#34;ButtonMash.h\u0026#34; #include \u0026lt;iostream\u0026gt; ButtonMash::ButtonMash(XInputHandler *inputHandler, XInputFctnPtr buttonPtr) { m_xinptHandler = inputHandler; ButtonFunctionPointer = buttonPtr; currentValue = 0.0f; btnDown = false; } bool ButtonMash::Update(float fDT) { currentValue -= 0.001f; if (currentValue \u0026lt; 0.0f) currentValue = 0.0f; if ((m_xinptHandler-\u0026gt;*ButtonFunctionPointer)()) { if (!btnDown) currentValue += 0.1f; btnDown = true; } else btnDown = false; if (currentValue \u0026gt;= 1.0f) return true; return false; } ButtonMash::~ButtonMash() { m_xinptHandler = nullptr; ButtonFunctionPointer = nullptr; } ","permalink":"https://alexanderhoughton.co.uk/programming/c-controller-input-class/","summary":"Something I’ve always enjoyed programming is input via a controller, I’d dabbled with Microsoft’s XINPUT classes for the Xbox 360 controller before and I found it really interesting so I decided to put together a collection of classes which would allow detection of common input scenarios for video games. As it currently stands, the specific detections […]","title":"C++ Controller Input Class"},{"content":"In order to further my C++ skills and get started with the brand new Unreal Engine 4, I decided it would be a great task to convert my previous game Side Switcher from UE3.\nI have currently replicated the entire input, movement and camera control into the game, without any level design as of yet. I’ve also just finished implementing the Switch Plate. Since programming with UE4 in C++ is MUCH MUCH easier to add new features and such compared to UnrealScript with UE3, I’ve decided to work on a lot more elements to add to the game. One of these being some basic AI chase enemies.\n","permalink":"https://alexanderhoughton.co.uk/programming/bringing-side-switcher-to-unreal-engine-4-work-in-progress-october-2014/","summary":"In order to further my C++ skills and get started with the brand new Unreal Engine 4, I decided it would be a great task to convert my previous game Side Switcher from UE3. I have currently replicated the entire input, movement and camera control into the game, without any level design as of yet. […]","title":"Bringing Side Switcher to Unreal Engine 4. (WORK IN PROGRESS OCTOBER 2014)"},{"content":"As part of my degree at Bournemouth University, part of the final year project was to exhibit at the Festival of Design \u0026amp; Innovation (FODI) where we can showcase ourselves and our final year projects. With FODI came the need for a website in which each pupil on Creative Technology could upload details about their project as well as some information about themselves, I took it upon myself to set up this site.\nHaving only done basically image drawing with PHP before, I knew the task ahead would require a lot of learning and delving deep into how PHP is used in conjunction with HTML, SQL databases and with WordPress.\nThe site started as a blank WordPress site after which I installed a theme which met a few requirements but I knew that many of the features I would need to add in myself.\nI found this task extremely interesting, until this point I haven’t really delved deep into other peoples code to analyse how it works and how I can then manipulate and build upon that. While majority of the core WordPress php scripts are documented, the theme I selected to base the site on came with no code documentation so it required some time to read and understand it which I enjoyed.\nI did most of my PHP programming in Notepad++ and other photo editing in Photoshop.\nA few of the main features added and key features of the project:\nAdded ability for users to add personal photo of themselves as well as a featured image. On work overview, re-designed how the data is displayed and show the users personal photo. Colour coordinate between the two Creative Technology courses (Music and Games) to make the two easily distinguishable. Randomizing the order of everyone’s projects. Created the CT Class list (http://ct2014.co.uk/creative-technology-class-list-2014/) a randomizing way to browse each person by their course and personal photo. Managed a small team to help me with visual media, ideas and gathering users to upload their project data. CT2014.co.uk will be live until June 2015, you can view it here.\nBelow is a code snippet a page I created from scratch which randomly displays students from Music \u0026amp; Games technology courses and displays them separately.\n\u0026lt;?php /* Template Name: Custom Alex Template */ // GET SELECTED THUMBNAIL SIZE $thumb = of_get_option(\u0026#39;md_post_featured_img_size\u0026#39;); /// CHECK CATEGORY if(isset($term)) { $checkcat = $term; } // GET PORTFOLIO POSTS $args = array( \u0026#39;posts_per_page\u0026#39; =\u0026gt; -1, \u0026#39;post_type\u0026#39; =\u0026gt; \u0026#39;works\u0026#39;, \u0026#39;post_status\u0026#39; =\u0026gt; array(\u0026#39;publish\u0026#39;), \u0026#39;orderby\u0026#39; =\u0026gt; \u0026#39;rand\u0026#39; ); //ADDED BY ALEX ORDER BY RAND if(function_exists(\u0026#39;CPTO_activated\u0026#39;)) { $args = array_merge($args, array( \u0026#39;orderby\u0026#39; =\u0026gt; \u0026#39;menu_order\u0026#39;, \u0026#39;order\u0026#39;=\u0026gt;\u0026#39;asc\u0026#39; ) ); } query_posts($args); ?\u0026gt; \u0026lt;?php get_header(); ?\u0026gt; \u0026lt;?php $courseCol = \u0026#34;c9c5c1\u0026#34;; $firstCat = \u0026#34;\u0026#34;; $secondCat = \u0026#34;\u0026#34;; $rndno = rand(1,100); $maxNo = 50; if ($rndno \u0026gt; $maxNo) { $firstCat = \u0026#34;Games Technology\u0026#34;; $secondCat = \u0026#34;Audio Technology\u0026#34;; } else { $firstCat = \u0026#34;Audio Technology\u0026#34;; $secondCat = \u0026#34;Games Technology\u0026#34;; } ?\u0026gt; \u0026lt;br class=\u0026#34;clear\u0026#34; /\u0026gt; \u0026lt;div class=\u0026#34;row fitvids\u0026#34;\u0026gt; \u0026lt;div class=\u0026#34;sixteen columns\u0026#34;\u0026gt; \u0026lt;center\u0026gt;\u0026lt;h2\u0026gt;Meet Creative Technology 2014\u0026lt;/h2\u0026gt;\u0026lt;/center\u0026gt; \u0026lt;?php if (strpos($firstCat, \u0026#34;Games Technology\u0026#34;) !== false) : ?\u0026gt; \u0026lt;img src=\u0026#34;http://ct2014.co.uk/wp-content/uploads/2014/06/GamesWideTitle.png\u0026#34; alt=\u0026#34;Creative Technology\u0026#34; width=\u0026#34;920\u0026#34; height=\u0026#34;52\u0026#34; class=\u0026#34;aligncenter size-full wp-image-192\u0026#34; /\u0026gt; \u0026lt;?php endif; ?\u0026gt; \u0026lt;?php if (strpos($firstCat, \u0026#34;Audio Technology\u0026#34;) !== false) : ?\u0026gt; \u0026lt;img src=\u0026#34;http://ct2014.co.uk/wp-content/uploads/2014/06/MusicWideTitle.png\u0026#34; alt=\u0026#34;Creative Technology\u0026#34; width=\u0026#34;920\u0026#34; height=\u0026#34;52\u0026#34; class=\u0026#34;aligncenter size-full wp-image-192\u0026#34; /\u0026gt; \u0026lt;?php endif; ?\u0026gt; \u0026lt;div style=\u0026#34;margin-left:45px; margin-top:15px;\u0026#34;\u0026gt; \u0026lt;?php if (strpos($firstCat, \u0026#34;Games Technology\u0026#34;) !== false) $courseCol = \u0026#34;f37c74\u0026#34;; else $courseCol = \u0026#34;eeba53\u0026#34;; ?\u0026gt; \u0026lt;?php while ( have_posts() ) : the_post(); ?\u0026gt; \u0026lt;?php $image = get_field(\u0026#39;Photo\u0026#39;); ?\u0026gt; \u0026lt;?php $nameField = get_field(\u0026#39;work-client\u0026#39;); if($nameField == \u0026#34;\u0026#34;) $nameField = \u0026#34;Not Set\u0026#34;; ?\u0026gt; \u0026lt;?php $linkField = get_permalink($id); ?\u0026gt; \u0026lt;?php $terms = get_the_terms( $id , \u0026#39;works-categories\u0026#39;, \u0026#39;string\u0026#39; ); if ( $terms \u0026amp;\u0026amp; ! is_wp_error( $terms ) ) { $draught_links = array(); foreach ( $terms as $term ) { $draught_links[] = \u0026#39;\u0026lt;a href=\u0026#34;\u0026#39;.esc_attr(get_term_link( $term, \u0026#39;works-categories\u0026#39; )).\u0026#39;\u0026#34;\u0026gt;\u0026#39;.$term-\u0026gt;name.\u0026#39;\u0026lt;/a\u0026gt;\u0026#39;; } $categories = join( \u0026#34;, \u0026#34;, $draught_links ); } ?\u0026gt; \u0026lt;?php if( !empty($image) \u0026amp;\u0026amp; strpos($categories, $firstCat) ): ?\u0026gt; \u0026lt;div class=\u0026#34;wp-caption alignleft\u0026#34; style=\u0026#34;width:160px; border: 3px solid #\u0026lt;?php echo $courseCol; ?\u0026gt;!important; margin-bottom:10px;\u0026#34; \u0026gt; \u0026lt;a href=\u0026#34;\u0026lt;?php echo $linkField ?\u0026gt;\u0026#34;\u0026gt; \u0026lt;img src=\u0026#34;\u0026lt;?php echo $image[\u0026#39;url\u0026#39;]; ?\u0026gt;\u0026#34; style=\u0026#34;width:150px; max-width:150px; min-width:150px; height:210px; max-height:210px; min-height:210px;\u0026#34; alt=\u0026#34;\u0026lt;?php echo $image[\u0026#39;alt\u0026#39;]; ?\u0026gt;\u0026#34; /\u0026gt; \u0026lt;/a\u0026gt; \u0026lt;p class=\u0026#34;wp-caption-text\u0026#34;\u0026gt;\u0026lt;?php echo $nameField; ?\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;?php endif; ?\u0026gt; \u0026lt;?php endwhile; ?\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;?php if (strpos($secondCat, \u0026#34;Games Technology\u0026#34;) !== false) : ?\u0026gt; \u0026lt;img src=\u0026#34;http://ct2014.co.uk/wp-content/uploads/2014/06/GamesWideTitle.png\u0026#34; alt=\u0026#34;Creative Technology\u0026#34; width=\u0026#34;920\u0026#34; height=\u0026#34;52\u0026#34; class=\u0026#34;aligncenter size-full wp-image-192\u0026#34; /\u0026gt; \u0026lt;?php endif; ?\u0026gt; \u0026lt;?php if (strpos($secondCat, \u0026#34;Audio Technology\u0026#34;) !== false) : ?\u0026gt; \u0026lt;img src=\u0026#34;http://ct2014.co.uk/wp-content/uploads/2014/06/MusicWideTitle.png\u0026#34; alt=\u0026#34;Creative Technology\u0026#34; width=\u0026#34;920\u0026#34; height=\u0026#34;52\u0026#34; class=\u0026#34;aligncenter size-full wp-image-192\u0026#34; /\u0026gt; \u0026lt;?php endif; ?\u0026gt; \u0026lt;div style=\u0026#34;margin-left:45px; margin-top:15px;\u0026#34;\u0026gt; \u0026lt;?php query_posts($args); ?\u0026gt; \u0026lt;?php if (strpos($secondCat, \u0026#34;Audio Technology\u0026#34;) !== false) $courseCol = \u0026#34;eeba53\u0026#34;; else $courseCol = \u0026#34;f37c74\u0026#34;; ?\u0026gt; \u0026lt;?php while ( have_posts() ) : the_post(); ?\u0026gt; \u0026lt;?php $image = get_field(\u0026#39;Photo\u0026#39;); ?\u0026gt; \u0026lt;?php $nameField = get_field(\u0026#39;work-client\u0026#39;); if($nameField == \u0026#34;\u0026#34;) $nameField = \u0026#34;Not Set\u0026#34;; ?\u0026gt; \u0026lt;?php $linkField = get_permalink($id); ?\u0026gt; \u0026lt;?php $terms = get_the_terms( $id , \u0026#39;works-categories\u0026#39;, \u0026#39;string\u0026#39; ); if ( $terms \u0026amp;\u0026amp; ! is_wp_error( $terms ) ) { $draught_links = array(); foreach ( $terms as $term ) { $draught_links[] = \u0026#39;\u0026lt;a href=\u0026#34;\u0026#39;.esc_attr(get_term_link( $term, \u0026#39;works-categories\u0026#39; )).\u0026#39;\u0026#34;\u0026gt;\u0026#39;.$term-\u0026gt;name.\u0026#39;\u0026lt;/a\u0026gt;\u0026#39;; } $categories = join( \u0026#34;, \u0026#34;, $draught_links ); } ?\u0026gt; \u0026lt;?php if( !empty($image) \u0026amp;\u0026amp; strpos($categories, $secondCat) ): ?\u0026gt; \u0026lt;div class=\u0026#34;wp-caption alignleft\u0026#34; style=\u0026#34;width:160px; border: 3px solid #\u0026lt;?php echo $courseCol; ?\u0026gt;!important; margin-bottom:10px;\u0026#34; \u0026gt; \u0026lt;a href=\u0026#34;\u0026lt;?php echo $linkField ?\u0026gt;\u0026#34;\u0026gt; \u0026lt;img src=\u0026#34;\u0026lt;?php echo $image[\u0026#39;url\u0026#39;]; ?\u0026gt;\u0026#34; style=\u0026#34;width:150px; max-width:150px; min-width:150px; height:210px; max-height:210px; min-height:210px;\u0026#34; alt=\u0026#34;\u0026lt;?php echo $image[\u0026#39;alt\u0026#39;]; ?\u0026gt;\u0026#34; /\u0026gt; \u0026lt;/a\u0026gt; \u0026lt;p class=\u0026#34;wp-caption-text\u0026#34;\u0026gt;\u0026lt;?php echo $nameField; ?\u0026gt;\u0026lt;/p\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;?php endif; ?\u0026gt; \u0026lt;?php endwhile; ?\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;/div\u0026gt; \u0026lt;?php get_footer(); ?\u0026gt; ","permalink":"https://alexanderhoughton.co.uk/websites/php-programming-ct2014-co-uk/","summary":"As part of my degree at Bournemouth University, part of the final year project was to exhibit at the Festival of Design \u0026amp; Innovation (FODI) where we can showcase ourselves and our final year projects. With FODI came the need for a website in which each pupil on Creative Technology could upload details about their […]","title":"PHP Programming CT2014.co.uk"},{"content":"As part of the ‘Modelling \u0026amp; Game Design’ unit at Bournemouth University, I was tasked with creating a full game using the Unreal Development Kit. Having only ever used UDK for map design and some very simple Kismet visual scripting, I was eager to get to grips with this powerful engine as a tool to create games. The game could not categorically be a first person or third person shooter (this would be too easy!) so I decided to create a side-scrolling platformer game. However I didn’t just want to create a side-scroller which was like every other one, I wanted something special…\nSide Switcher was my final idea, a side scrolling puzzle game where you can have control over the direction you are facing by stepping onto switching plates. Switching plates change your direction of travel depending on which way you enter them.\nKey Features:\nMain Menu Colourful \u0026amp; Simplistic Design Style Custom Obstacles \u0026amp; Hazards Tutorials during gameplay (background) Switching Plates Realtime HUD (Animated via Flash) Coins to collect Checkpoint saves Simple \u0026amp; Unique Puzzles Secret / Optional Areas Race Car Finish! Challenges with Matinee Animation UDK Background features Custom Textures \u0026amp; Models Music by Colin Houghton Technical Achievements:\nUnrealScript: Having never used UnrealScript before, the idea of it was fairly daunting however I jumped head first into it and really tried to get to grips with it. With UDK, they have a lot of classess already available for you to use and view which use UnrealScript. Websites such as (www.uncodex.com) which have an online database of all the base UDK classes were brilliant in helping me analyse existing code and learning how to write my own.\nOnce I understood all the specific details of UnrealScript and how exactly they were used, I felt confident enough to begin creating Side Switcher.\nKismet in UDK 3: Kismet is a visual form of scripting in UDK where you create objects and connect their inputs and outputs to other objects. While I do personally prefer coding my way forwards, Kismet is an essential part of UDK 3 and at times can make things very easy to achieve. Kismet relies heavily on logic so you really must think through what it is you are creating in Kismet, something I really did like about the feature.\nActionScript 3 \u0026amp; Flash: Something I wasn’t expecting to learn from creating a game with UDK 3, Flash \u0026amp; ActionScript 3 are the essential tools for creating realistic and powerful HUD \u0026amp; menu systems in UDK 3. I’d always wanted to get into Flash programming with ActionScript but my attention had always been focused elsewhere so this was a great chance for me to understand the basics. I mainly used ActionScript 3 to program the animation sequences for the HUD variables which move everytime they change, as well as the checkpoint save features where a small message box appears. I will definitely be using ActionScript again in the future, I found it really easy the way you can drag a shape into your scene and then manipulate it endlessly through code.\n","permalink":"https://alexanderhoughton.co.uk/programming/side-switcher-full-game-using-udk-unrealscript-actionscript/","summary":"As part of the ‘Modelling \u0026amp; Game Design’ unit at Bournemouth University, I was tasked with creating a full game using the Unreal Development Kit. Having only ever used UDK for map design and some very simple Kismet visual scripting, I was eager to get to grips with this powerful engine as a tool to […]","title":"Side Switcher – Full game using UDK, UnrealScript + ActionScript"},{"content":" ‘COMMAND THAT TANK’ is a game which puts your tank commanding skills to the test to see whether you are not only the best tank commander in your country, but the entire world.\nWith Command That Tank you tank control of either a powerful APC (Armoured Personnel Carrier) or a ferocious WW2 Tiger Tank in an effort to prove your skills at controlling a tank through different and increasingly difficult levels. The for each level is to shoot every single target as quickly as possible, the faster you shoot all targets, the more points you get! However, you also get more points based on how far away you have shot the target from, opening a world of tactical manoeuvres in order to increase your total score. Will you try and shoot all the targets as quickly as possible to increase your score through time or take extra time to fire shots as far away as possible?\nGame Features: Command That Tank has a huge number of features, content, assets and re-playability. The key features can be found below:\nThree unique, interesting and increasingly difficult levels Full \u0026amp; realistic tank controls Vehicle \u0026amp; sky animation Physics engine applied to tank shells XBOX 360 Controller \u0026amp; Mouse+Keyboard support Customisable Explosions! There are five different explosive weapons to choose from. Two different tank models to command. 5 Customisable HLSL Effects (Normal, Black \u0026amp; White, Bass, Vibrance, Alienworld) Online high scores table (compete with other tank commands from around the world) An immersive \u0026amp; realistic audio experience Addictive \u0026amp; competitive gameplay style Terrain and level assets generated from an image file Screenshots:\n","permalink":"https://alexanderhoughton.co.uk/programming/command-that-tank-3d-xna-game-c-php-hlsl/","summary":"‘COMMAND THAT TANK’ is a game which puts your tank commanding skills to the test to see whether you are not only the best tank commander in your country, but the entire world. With Command That Tank you tank control of either a powerful APC (Armoured Personnel Carrier) or a ferocious WW2 Tiger Tank in […]","title":"COMMAND THAT TANK – 3D XNA GAME (C#, PHP, HLSL)"},{"content":"After finishing my course at Bournemouth University, I wanted to invest my free time into improving my programming and game development skills.\nI decided that since majority of my course at University had focused on the Unreal Development Kit, it would be cool to try out Unity properly and see how it compares.\nI’ve done a small amount of work in Unity prior to this project, where I was following numerous online video tutorials and reading published books as I attempted to replicate some small and simple games.\nusing UnityEngine; using System.Collections; public class GameScriptGrid : MonoBehaviour { public GameObject[] totalList; public Vector3[] initialStartPositions; public GameObject correctText; public GameObject incorrectText; private Color clickColour = new Color(5,0,0); public Color defaultColour; private AudioSource audioSource; public AudioClip correctClip; public AudioClip incorrectClip; private float correctClicks = 0; private float incorrectClicks = 0; private float level = 1; private float timeBetweenNewAdded = 0; //In miliseconds private float timeSinceLastChange = 0; public TextMesh textMesh1; public TextMesh textMesh2; public TextMesh textMesh3; // Use this for initialization void Start () { defaultColour = totalList [0].renderer.material.color; audioSource = GetComponent\u0026lt;AudioSource\u0026gt; (); initialStartPositions = new Vector3[totalList.Length]; for (int i = 0; i \u0026lt; totalList.Length; i++) initialStartPositions [i] = totalList [i].transform.position; } // Update is called once per frame void Update () { ChangeMaxSimultaneousBasedOnLevel (); timeBetweenNewAdded = 2000 / level; if (timeSinceLastChange \u0026lt; (Time.realtimeSinceStartup * 1000)) { Debug.Log(\u0026#34;Add New Cube Time!\u0026#34;); int cubeNo = GetRandomCube(); if (cubeNo \u0026gt; -1) { totalList[cubeNo].GetComponent\u0026lt;CubeScript\u0026gt;().ColorToChangeTo = clickColour; totalList[cubeNo].GetComponent\u0026lt;CubeScript\u0026gt;().SetActive(); } timeSinceLastChange = (Time.realtimeSinceStartup * 1000) + timeBetweenNewAdded; } DoInput (); if (level \u0026gt; 4) MoveThemRightLeft (); if (level \u0026gt; 6) Camera.main.GetComponent\u0026lt;MainCameraScript\u0026gt; ().spin = true; SimpleSway (); } public bool goRight = true; void SimpleSway() { float x = this.transform.position.x; if (goRight)x = x + (0.1f * Time.deltaTime); else x = x - (0.1f * Time.deltaTime); if (x \u0026gt; 0.2f) goRight = false; if (x \u0026lt; -0.2f) goRight = true; this.transform.position = new Vector3 (x, this.transform.position.y, this.transform.position.z); } int GetRandomCube() { int max = totalList.Length; int val = Random.Range (0, max); if (totalList [val].renderer.material.color == clickColour) return -1; else return val; } private float timeCounter = 0f; private float shiftTime = 2.0f; private float moveLeftRightSpeed = 0.5f; void MoveThemRightLeft() { timeCounter += Time.deltaTime; if (timeCounter \u0026gt; shiftTime) { Debug.Log(\u0026#34;CHANGE NOW...\u0026#34;); timeCounter = 0f; shiftTime = 4f; moveLeftRightSpeed = -moveLeftRightSpeed; } for (int i = 0; i \u0026lt; totalList.Length; i++) { if (i \u0026lt; 3) totalList[i].transform.position = new Vector3(totalList[i].transform.position.x + moveLeftRightSpeed * Time.deltaTime, totalList[i].transform.position.y, totalList[i].transform.position.z); else if (i \u0026lt; 6) totalList[i].transform.position = new Vector3(totalList[i].transform.position.x - moveLeftRightSpeed * Time.deltaTime, totalList[i].transform.position.y, totalList[i].transform.position.z); else totalList[i].transform.position = new Vector3(totalList[i].transform.position.x + moveLeftRightSpeed * Time.deltaTime, totalList[i].transform.position.y, totalList[i].transform.position.z); } } void ChangeMaxSimultaneousBasedOnLevel() { float tmpLvl = (int)(correctClicks / 3f); //Debug.Log (\u0026#34;(int)(correctClicks / 2f): \u0026#34; + tmpLvl); if (tmpLvl \u0026gt; 100) { tmpLvl = 11 + (tmpLvl / 50); } else tmpLvl = 1 + (tmpLvl / 10); //Debug.Log (\u0026#34;LEVEL: \u0026#34; + tmpLvl); level = tmpLvl; textMesh1.text = \u0026#34;Level: \u0026#34; + ((level * 10) - 9).ToString(); } private void DoInput() { if(Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] rayCastHit; rayCastHit = Physics.RaycastAll(ray); if (rayCastHit.Length \u0026gt; 0) { CubeScript temp = rayCastHit[0].transform.gameObject.GetComponent\u0026lt;CubeScript\u0026gt;(); Debug.Log(\u0026#34;SOMETHING HIT...\u0026#34;); Debug.Log(rayCastHit[0].transform.gameObject.name); if (temp.isActivated) { correctClicks++; temp.SetDefault(); audioSource.clip = correctClip; audioSource.Play(); Instantiate(correctText, temp.transform.position,Quaternion.identity); } else { //Incorrect Hit Instantiate(incorrectText, temp.transform.position, Quaternion.identity); audioSource.clip = incorrectClip; audioSource.Play(); incorrectClicks++; textMesh2.text = \u0026#34;Misses: \u0026#34; + incorrectClicks.ToString() + \u0026#34; / 5\u0026#34;; } } } } } using UnityEngine; using System.Collections; public class CubeScript : MonoBehaviour { public bool isActivated = false; public Color ColorToChangeTo; public float LerpSpeed = 0.025f; private float speedLerp; private Color defaultCol; private float timeActivated = 0.0f; private Vector3 startingScale; public float timeToDestroy = 1500; private float startingYValue; public GameObject explosion; public ParticleSystem ps; private float yPositionDesired = 4; // Use this for initialization void Start () { startingScale = this.transform.localScale; speedLerp = LerpSpeed; ColorToChangeTo = defaultCol = this.renderer.material.color; startingYValue = this.transform.position.y; } // Update is called once per frame void Update () { //if (this.renderer.material.color != ColorToChangeTo) this.renderer.material.color = Color.Lerp (this.renderer.material.color, ColorToChangeTo, speedLerp); if (isActivated) { if ((timeActivated + timeToDestroy) \u0026lt; ((Time.realtimeSinceStartup * 1000))) { transform.localScale += new Vector3 (0.0025f, 0.0025f, 0.0025f); //speedLerp = 0.075f; //ColorToChangeTo = new Color (0, 0, 0); if ((timeActivated + timeToDestroy * 1.5f) \u0026lt; ((Time.realtimeSinceStartup * 1000))) { Debug.Log (\u0026#34;DESTORY???\u0026#34;); //GAME OVERRRRR isActivated = false; Instantiate(explosion, this.transform.position, Quaternion.identity); ps.Stop (); GetComponent\u0026lt;MeshRenderer\u0026gt; ().enabled = false; } } } else { transform.localScale = startingScale; } Debug.Log (\u0026#34;Y POS: \u0026#34; + this.transform.position.y); this.transform.position = Vector3.Lerp( this.transform.position, new Vector3 (this.transform.position.x, yPositionDesired, this.transform.position.z), speedLerp); } public void SetActive() { ps.Play (); speedLerp = LerpSpeed; timeActivated = Time.realtimeSinceStartup * 1000; isActivated = true; } public void SetDefault() { this.transform.position = new Vector3 (this.transform.position.x, 3.5f, this.transform.position.z); ps.Stop (); speedLerp = LerpSpeed; ColorToChangeTo = defaultCol; isActivated = false; } } ","permalink":"https://alexanderhoughton.co.uk/programming/getting-to-grips-with-unity-c/","summary":"After finishing my course at Bournemouth University, I wanted to invest my free time into improving my programming and game development skills. I decided that since majority of my course at University had focused on the Unreal Development Kit, it would be cool to try out Unity properly and see how it compares. I’ve done […]","title":"Getting to grips with Unity (C#)"},{"content":"When I first started doing work as a creative writer for certain websites around the web I started to learn the basics of how WordPress worked more and more and the potential to make some money from a blog / website if I set one up myself. I knew I wanted to start a blog about something but I knew it had to be something that would offer unique content and be on a topic that is popular enough to earn some money from.\nIt was around the time the game Call of Duty: Black Ops was the biggest game out there in August 2011 when I found my gap in the market. I was trying to find out about all the Call of Duty map packs that were available for Black Ops, a fairly common search term on Google, yet there was no dedicated place with information on all of them, thats when Callofdutymappacks.com was created.\nSince it was my first time ever setting up a WordPress site I had to read a few tutorials on how to set it up and investiage the best company to host my website with. I’d experimented with Apache and hosting my website myself but at the end of the day it just wasn’t a viable option.\nI asked on the Photoshop forum I was a part of to help me design the header image of the website and then tweaked and changed the rest of the website how I wanted.\nLearning HTML:\nI had previously designed website completely from scratch using Dreamweaver at GCSE but WordPress was much more complicated and in order to make certain tweaks to the design you need to go down into the HTML to edit it. Since setting up my website I have learnt a great deal more about how HTML works and how to edit it.\nAlong with learning HTML my website has taught me about visitor trends, how Google ranks web pages, advertising types, advertising techniques, advertising placement and so much more related to how the world wide web works. It’s been a brilliant learning curve.\nIn less than a year my website is ranking the number 1 spot for search terms such as “MW3 Map Pack” and Modern Warfare 3 Map Packs” which is fantastic news as it is driving my high levels of traffic which in turn is making me money.\nI update the website on a regular basis in order to maintain a good search ranking. Overall the website has been a brilliant learning experience and has taught me about all sorts of web services, programs and marketing techniques as well as social networking which I find a valuable asset.\nSticking with the times (Updating CodMapPacks to 2014):\nAs with any solution, eventually it begins to look tiresome and old fashioned, if you look at the screenshot above of the site in 2011 you can tell it just wouldn’t cut it with todays web standards. So I invested a few days in 2014 updating the look and layout of the site to make it more efficient and look much nicer. The screenshot below speaks for itself:\n","permalink":"https://alexanderhoughton.co.uk/websites/callofdutymappacks-com/","summary":"When I first started doing work as a creative writer for certain websites around the web I started to learn the basics of how WordPress worked more and more and the potential to make some money from a blog / website if I set one up myself. I knew I wanted to start a blog […]","title":"CallofDutyMapPacks.com"},{"content":"\nAbstract / Introduction: With the video games industry currently larger than it ever has been before, just creating a game and releasing it to the world is just the beginning of its lifecycle. Analytics has exploded in the games industry recently and is now regarded as one of the most important aspects of game design. The ability understand user psychology, understand how they play, think and learn your games proves to be extremely valuable information for increasing games fun, popularity and at the end of the day, monetary income.\nTo give an idea of the level of data collected in video games, Electronic Arts™ tracks game data for 2 million games worldwide every day generating a total of 150 Terabytes every day. David Smith. (2013).\nAims: The aim of this project is to create a Google Analytics for Games application which will allow developers to get real-time data overviews for all of their projects at a glance through the use of Windows 8’s Live Tile feature set. This information will be updated regularly and automatically across multiple titles without the need to manually check and login for each.\nThe Live Tiles will be customisable by the users to show specific data for each game and/or combined data for multiple games in order to give the users power beyond that provided by Google’s web Analytic client.­­\nHaving an overview to hand with real-time data will allow developers to always be on top of their metrics, react to trends as they begin appearing and get ahead of problems as soon as possible. If required then the user should be able to click the Live Tile to receive further detailed information about the metric in question.\nToast Notifications will also be integrated as a means of emergency situations if a certain metric drops drastically low or a web server is down to allow developers to react as quickly as possible.\nHaving this data available to developers as fast as possible will allow updates and changed to games to be made much faster, leading to a better end user experience.\n","permalink":"https://alexanderhoughton.co.uk/programming/final-year-project-bournemouth-university/","summary":"Abstract / Introduction: With the video games industry currently larger than it ever has been before, just creating a game and releasing it to the world is just the beginning of its lifecycle. Analytics has exploded in the games industry recently and is now regarded as one of the most important aspects of game design. […]","title":"Final Year Project Bournemouth University"},{"content":"For my final year project at University I had decided that I would be developing a Windows 8 application, something I, at the time had no experience in. Over the 2013 Christmas break I decided I would create a Windows 8 application in order to understand the basics and fundamentals of the development and just generally be prepared for future development.\nI decided to re-create an application I had made for Windows Phone (Starcraft II Profiler). This is an application I am extremely proud of, it is extremely functional and of very good quality. Coming from Windows Phone to Windows 8 was not actually as easy as I thought it first would be, there are a lot of small and subtle differences which are easily overlooked.\nCertain functions, features and specifics found in Windows Phone cannot be used in Windows Store development so a large proportion of the code I had written previously had to be completely re-written and re-designed. I look on this in a positive light though as it allowed me to discover the ins and outs of Windows 8 development. Obviously certain aspects were bound to change, the layout and UI of Windows 8, while similar to Windows Phone is actually very different which led me to truly understanding and learning how GridViews and Grid’s worked in much more detail.\nMuch of what I was accustom to also with Windows Phone with Live Tiles and background services which very different also with Windows 8 but I took the time to read and learn from many sources and examples projects to create a solution which ended up working really well.\nI also took this opportunity to upgrade the application, allowing the user to login by pasting in the URL of where their profile is located. The application now analyses the URL for the required information and validates it to allow for login!\nStarcraft II Profiler for Windows 8 can be downloaded here!\n","permalink":"https://alexanderhoughton.co.uk/programming/beginning-windows-store-8-1-development-upgrading-starcraft-ii-profiler-c-xaml-php/","summary":"For my final year project at University I had decided that I would be developing a Windows 8 application, something I, at the time had no experience in. Over the 2013 Christmas break I decided I would create a Windows 8 application in order to understand the basics and fundamentals of the development and just […]","title":"Beginning Windows Store 8.1 Development: Upgrading Starcraft II Profiler (C#, XAML, PHP)"},{"content":"\nBeing my most popular application to date, Call of Duty Quiz was one of the first applications I ever made for the Windows Phone and since creating it my programming skills have come a long way. I felt it was time to re-create the popular application with a visual overhaul and new questions alongside the newly released Call of Duty: Ghosts.\nAs the total install number is just of 100,000 I felt it was also a good time to monetize the application using skills I learnt from Steam Live Tile regarding In-App Purchases. The only problem with this is that these In-App purchases are only supported by Windows Phone 8 and 7.8 devices so my update will leave 7.1 users out of the new update unfortunately, however 7.1 market share is now fairly small in comparison and getting smaller.\nThe new application includes 500+ questions compared to the original 100 as well as updated graphics and much more efficient coding.\n","permalink":"https://alexanderhoughton.co.uk/programming/remastering-call-of-duty-quiz/","summary":"Being my most popular application to date, Call of Duty Quiz was one of the first applications I ever made for the Windows Phone and since creating it my programming skills have come a long way. I felt it was time to re-create the popular application with a visual overhaul and new questions alongside the […]","title":"Remastering Call of Duty Quiz"},{"content":"Having run multiple websites for a number of years now, Google Analytics has been an extremely important part of managing and running the sites. I’ve used the service provided by Google to analyse a vast array of different data in order to make for a better user experience and improve website SEO plus SERP.\nIn combination with Google Analytics I’ve conducted a number of experiments with Google Ad’s in order to achieve maximum income through site advertisements as well as social integration.\nMaking full use of Google Analytics, for Top Ten TV I started making use of custom variables which I used to track custom data about my visitors, extending on the huge amount of data Google already collects. Specifically I set up Google Analytics to log whether adverts on the website were being shown or not by checking whether a DIV tags size was zero. Having noticed an increase in mobile website users as well as a growing number of AdBlock users, I thought it would be interesting to see the percentage of users my Google AdSense Ad’s were being shown too. For the record, around 33% of users on Top Ten TV are not being delivered adverts, which in theory could mean to 33% less income.\n","permalink":"https://alexanderhoughton.co.uk/websites/google-analytics-experience/","summary":"Having run multiple websites for a number of years now, Google Analytics has been an extremely important part of managing and running the sites. I’ve used the service provided by Google to analyse a vast array of different data in order to make for a better user experience and improve website SEO plus SERP. In […]","title":"Google Analytics Experience"},{"content":" Latest and Greatest app. Consolidates and builds upon all previous Windows Phone knowledge, having spent months creating previous applications as I was going through large learning curves, I was able to create StarCraft II Profiler in less than one week.\nSC2 Profiler uses API’s provided by Blizzard Entertainment in order to fetch data for specific StarCraft 2 accounts. Unfortunately there is no real way to get the data unless the user can obtain the parameters of their URL but I made it so the exact URL doesn’t have to be entered and created a much friendlier login type screen. Being an avid fan of the game and part of the SC2 community, I was able to style and theme the application in an extremely SC2 fashion, creating an application which works seamlessly and looks fantastic along with user-customisable features.\nAs I have done with majority of my recent apps, the Live Tile is an extremely important aspect. For Weather Phone 8 I created the Live Tile from scratch, then Steam Live Tile was built on from that and then SC2 Profiler from that. This is partly the reason why I was able to create this application so fast.\nWhen I first set out to create SC2 Profiler (As I do with all my apps) I tried to create it in an extremely efficient manner, where everything was planned out, code would not be duplicated and big tasks would be split into simple functions and such. While every application I have made has always got far more complicated than anticipated at the start, with SC2 Profiler I can hands down say it is the most efficient app I have created which means future updates will be much easier to implement. Also, understandable code is just generally good practice.\n","permalink":"https://alexanderhoughton.co.uk/programming/starcraft-ii-profiler/","summary":"Latest and Greatest app. Consolidates and builds upon all previous Windows Phone knowledge, having spent months creating previous applications as I was going through large learning curves, I was able to create StarCraft II Profiler in less than one week. SC2 Profiler uses API’s provided by Blizzard Entertainment in order to fetch data for specific […]","title":"StarCraft II Profiler"},{"content":"In order to broaden my skill base and allow my applications to reach a larger audience, I decided to finally begin development on the Android platform. After years of solely developing for Windows Phone it was a brand new experience to being developing for an entirely different platform. While there are features which are amazingly similar there are also others which are very different, for both good and bad reasons! It has given me such a huge insight into the platform as well as the powerful features available to it during the short time I have been working with it.\nHaving all the files from my previous Windows Phone application, I decided to start my Android development by converting one of my existing projects, namely my ‘True or False?” app. This was a great opportunity to improve on my previous code as well as the challenges of brining it over from C# with Windows Phone to Java with Android.\nI also spent extra time improving the application over the Windows Phone version by adding animation with XML.\n","permalink":"https://alexanderhoughton.co.uk/programming/first-android-development-eclipse-java-xml/","summary":"In order to broaden my skill base and allow my applications to reach a larger audience, I decided to finally begin development on the Android platform. After years of solely developing for Windows Phone it was a brand new experience to being developing for an entirely different platform. While there are features which are amazingly […]","title":"First Android Development (Eclipse, Java, XML)"},{"content":"After completing my Weather Phone 8 application I had grasped some very complex skills within the Windows Phone operating system as well as PHP, upon realising there was not application in the marketplace which would create a Live Tile out of Steam profiles I began work on Steam Live Tile.\nExpanding on my knowledge of web based services and API’s as well as creating efficient XML parsing algorithms along with unwanted text removal I was able to download user profile data with ease.\nHaving a good understanding of Steam I was able to achieve a sense of style which replicated the official Steam application perfectly, giving it a professional and slick look.\nWith Steam Live Tile I also delved into an area of mobile applications I had not explored before, implementing in-app purchasing. I was eager to implement this feature in some way because I know some developers have had great success with it. With this application the user is limited to adding one profile to the application, if they wish to purchase more then they can purchase a single, one-time purchase which will then unlock an unlimited number of profile additions to the application. With a system implemented into the app to download a users friends list and add then easily without manual entry, this promotes the in-app purchasing much better.\nDespite this application being similar to Weather Phone 8 in certain respects, it is still amazing to me how complex things can become very quickly, despite my vision being fairly simple. The amount I have learnt from creating Steam Live Tile as well as all my other applications is incredible, each application I make I am extending my knowledge further and further no matter how similar they may be. If I had a chance to create SLT (Steam Live Tile) again I would definitely be more organised with my shared classes, for example I had forgotten that in order to add a scheduled task agent in Windows Phone I would be adding a new project which meant it wouldn’t be able to access files from my original projects leading to a few duplications. I would happily work on the application more to improve its efficiency from a back-end point of view.\nA valuable lesson I have learnt from this application and Weather Phone 8 is the importance of backing up data and how much time can be saved by re-using code. After my external Hard Drive crashed recently I lost almost all my code for Weather Phone 8. Sometimes you’ve got to learn things the hard way though, backing up data now is extremely important to me and that you can never back up your data too much, nor across too many mediums. Through a mixture of external, internal and online storage now, I can be confident that my data is always safe.\nMotivation was something I had a lot of during the development of this application, I was able to turn this application from a simple idea to a marketplace submission in less than a week despite re-creating and re-learning about code I had already made previously with Weather Phone 8.\nWindows Phone official store link: http://www.windowsphone.com/en-us/store/app/steam-live-tile/6fb43bb9-07c3-48f5-a5cf-cfefb1b539ba\n","permalink":"https://alexanderhoughton.co.uk/programming/steam-live-tile-windows-phone/","summary":"After completing my Weather Phone 8 application I had grasped some very complex skills within the Windows Phone operating system as well as PHP, upon realising there was not application in the marketplace which would create a Live Tile out of Steam profiles I began work on Steam Live Tile. Expanding on my knowledge of […]","title":"Steam Live Tile (Windows Phone)"},{"content":" For an assignment at university, we were required to form a group and begin the development of a game, based on a clients brief. Upon assigning the programming roles to myself and another member of the team, we worked extensively together to create something truly special. From the start I constructed the foundation for the game and the designed it so that we could easily share responsibilities and work on the code simultaneously.\nOr Die Trying is a game similar to Smash TV, the classic arcade, retro style game but with a modern look and awesome weapons.\nThe game was programmed using an Xbox 360 controller with XNA using C’#.\nThe game is easily the most complex and feature filled game I have ever worked on. It feature a full achievement service, offline high score file saving, a shop to upgrade your weapons, menus, game over screens and much more. We used a combination of graphics we created ourselves and open source ones for the game, although a lot of the open source content was edited highly.\nThe development of this game taught me a lot about working in code as part of a team and how to manage the workload accordingly. We both help one another with individual problems and overcame them together to create a game which really is competitive and fun. We really went above and beyond with this project.\n","permalink":"https://alexanderhoughton.co.uk/programming/or-die-trying/","summary":"For an assignment at university, we were required to form a group and begin the development of a game, based on a clients brief. Upon assigning the programming roles to myself and another member of the team, we worked extensively together to create something truly special. From the start I constructed the foundation for the […]","title":"Or Die Trying… (Complex XNA Game)"},{"content":"A recent assignment from Bournemouth University required me to form a group and construct a game which demonstrated Newton’s three laws of motion.\nOnce a group was formed it was decided that I would understake all of the programming on the task while my class mate worked on all the art and audio.\nWe ended up deciding to make a game very similar to a ‘Catapult Wars’ type game where players much hurl objects at one another in order to score points. We decided on ‘Tribal Wars’ where tribe members would shoot arrows at one another in order to score points. The players were able to move and aim in any direction as well as adjust their velocity. Obstacles were added in the sky to increase difficulty which were subject to Newton’s laws of motion when they were hit by the arrows.\nThe game demonstrates the laws as well as the effects of gravity, the game for me was one I felt really organised with. All my code is very clean and runs perfectly which I am very proud of.\nPer-Pixel collision was integrated into the game which is something I had not previously tackled. I used it for collision between the obstacles and arrows and characters with the hill in the game. Since the hill is based purely on its pixels it makes the game very easily expandable because by just changing the hill texture, you have a brand new map essentially.\nApplying Gravity: “What goes up, must come down” – Isacc Newton\nOne of the initial problems encountered with adding gravity to the game was understanding how to increase the acceleration at a steady rate. After initially applying gravity to the game objects it was apparent very quickly that they were accelerating far too quickly to simulate real gravity.\nThis was because the game was ticking over at a rate of 60 update calls per second while the rate of acceleration due to gravity is 9.81 meters pers second2. This meant I was essentially accelerating my objects at a rate of 588 m/s2 (Essentially 60 g’s!) The solution was to apply the acceleration values at a rate of 1/60th of the rate of gravity per tick which equates to 9.81 m/s2.\nProblems Encountered: 1) One of the first problems which was encountered was adding the effects of gravity which I spoke about earlier on. Understanding the formula for physics problems is one thing but applying it to a real time computer simulation requires a bit more though!\nCollision detection was a large part of the game and was an essential requirement from the very start. With Tribal Wars a simple flat surface was not used for the game, instead a large, pretty hill with varying heights was implements which was destined to be difficult for collision detection since it wouldn’t be viable to calculate it with simple shapes. In order to allow for extremely accurate collision a ‘per-pixel’ type of detection was implemented in which the whole texture for the background was placed into an array of colour types (RGBA). With this array the collision could easily be detected by whether the area we were checking collision for contained a pixel which was not transparent.\nIf a pixel which was not transparent was detected then that means a collision had occurred. This system is brilliant because it is so dynamic, for future iterations of the game different hills could be created really quickly and added to the game and the collision would still work perfectly.\nRotating the arrows to the face the direction was an aspect of the game which required a bit of maths to complete. The main problem was the initial rotation of the arrow because it was not facing directly upwards are 0 degrees but upon rotating the source image the problem was solved. Normalization was also required in the algorithm in order to fully understand the relationship between the X and Y velocity values.\nInfluenced from other hugely popular 2D physics games such as Angry Birds, the trajectory visualisation was an aspect I was keen to implement as it gives the whole game a great quality feel and guides the user. The trajectory was difficult to implement because it essentially required time travelling a few seconds into the future at a time and plotting where the arrow would be. Initially the trajectory followed the whole path of the arrow but obviously collision detection was not implemented into just a visualisation so the trajectory path continued forever until the graphics processer ran out of memory!\nAfterwards it was updated to stop drawing the trajectory until the path was off the screen which was accomplished with a while loop.\nLater on in development however it was clear that showing the player the whole trajectory path took the fun and unpredictability out of the game since you always knew where the arrow was going to land. It was decided that just 5 plot points would be shown so the players ability to predict the physics of it was a key skill in the game.\n","permalink":"https://alexanderhoughton.co.uk/programming/tribal-wars-physics-game/","summary":"A recent assignment from Bournemouth University required me to form a group and construct a game which demonstrated Newton’s three laws of motion. Once a group was formed it was decided that I would understake all of the programming on the task while my class mate worked on all the art and audio. We ended […]","title":"Tribal Wars (Physics Game)"},{"content":"Check out the embedded SoundCloud songs below. They can all also be found at: http://soundcloud.com/comeradealexi\nMy latest ventures:\nMy initial ventures:\n","permalink":"https://alexanderhoughton.co.uk/music-audio/fl-studios/","summary":"Check out the embedded SoundCloud songs below. They can all also be found at: \u003ca href=\"http://soundcloud.com/comeradealexi\"\u003ehttp://soundcloud.com/comeradealexi\u003c/a\u003e My latest ventures: My initial ventures:","title":"FL Studios"},{"content":"Top-Ten.TV is a project I am currently working on with my father. It is a website about top ten lists of tv shows such as the best characters, episodes or moments etc. Recently I have been working with an experienced writer from the USA as well as undertaking rigerious SEO techniques in order to maximise site popularity so it can achieve the reputation I feel it deserves.\nMe and Colin are both writing articles for the website on a regular basis while I also manage all the back end stuff for the site.\nI created all the visuals on the site and think it has a really nice feel and visual appearance to it.\nhttp://www.top-ten.tv/ ","permalink":"https://alexanderhoughton.co.uk/websites/top-ten-tv/","summary":"Top-Ten.TV is a project I am currently working on with my father. It is a website about top ten lists of tv shows such as the best characters, episodes or moments etc. Recently I have been working with an experienced writer from the USA as well as undertaking rigerious SEO techniques in order to maximise […]","title":"Top-Ten.TV"},{"content":"Spaceman \u0026amp; Slime is a game I created for one of my assignments at Bournemouth University. The game is a re-skinned version of the classic, tactical board game Hounds and Hares built using C# and XNA for the Windows Phone OS.\nHaving used XNA and C# extensively before I was keen to finally put all my skills towards completing a project all the way through. I had dabbled with a few projects and framework projects before so I had a good understanding of how to construct a game but never really put it into full practice. This project allowed me to fully complete a game from beginning to end which was fully functional, showing great planning and class structure.\n","permalink":"https://alexanderhoughton.co.uk/programming/spaceman-slime-c-xna/","summary":"Spaceman \u0026amp; Slime is a game I created for one of my assignments at Bournemouth University. The game is a re-skinned version of the classic, tactical board game Hounds and Hares built using C# and XNA for the Windows Phone OS. Having used XNA and C# extensively before I was keen to finally put all […]","title":"Spaceman \u0026 Slime: C# + XNA"},{"content":"For my AlcoWiki application for the Windows Phone I wanted to created a promotional website which would allow me to better present its features and capabilities.\nI feel AlcoWiki.com gives off a strong, professional and slick approach to promoting AlcoWiki.\nYou can view the website here: www.AlcoWiki.com\nAlong with the site I have also created social media engagement for my app via Facebook and Twitter.\n","permalink":"https://alexanderhoughton.co.uk/websites/alcowiki-com/","summary":"For my AlcoWiki application for the Windows Phone I wanted to created a promotional website which would allow me to better present its features and capabilities. I feel AlcoWiki.com gives off a strong, professional and slick approach to promoting AlcoWiki. You can view the website here: \u003ca href=\"https://www.AlcoWiki.com\"\u003ewww.AlcoWiki.com\u003c/a\u003e Along with the site I have also created […]","title":"AlcoWiki.com"},{"content":"For the website you are currently viewing I have solely created all of the content, assets and documents which it features. Though careful PHP editing and HTML tweaking I was able to adapt the WordPress theme I used as a foundation to create a great place to showcase my creative and technical work over the years.\n","permalink":"https://alexanderhoughton.co.uk/websites/alexanderhoughton-co-uk/","summary":"For the website you are currently viewing I have solely created all of the content, assets and documents which it features. Though careful PHP editing and HTML tweaking I was able to adapt the WordPress theme I used as a foundation to create a great place to showcase my creative and technical work over the […]","title":"AlexanderHoughton.co.uk"},{"content":"One of my latest software development venture was Weather Phone 8, combining the skills of all my previous applications together, allowing me to create something truly powerful.\nWeather Phone 8 Product Description:\n“Keep up to date with all your weather locations and even pin a special live tile which will always update weather for your current location.\nDesigned from the ground up for Windows Phone 8. Power \u0026amp; Simplicity Combined.\nKey Features:\\\nSpecial live tile which will always update your weather at your current location.\n+ Windows Phone 8 deep integration with all tile sizes supported.\\ Up to a four day forecast right from your start screen.\\ Pin as many weather locations as you want.\\ Sleek, simplistic and non-cluttered UI.\\ Customise the backgrounds on your live tiles. ” I had always wanted to allow my applications to become more versatile and live by allowing them to connect to and download data from the internet because till this point majority of the skills I have applied were all offline based. When I was creating AlcoWiki I taught myself PHP from knowing nothing about it to allowing me to program it to my needs so having that understanding turned out to be a massive help for Weather Phone 8 as I utilised those skills and built upon them further.\nWeather Phone 8 is my first application to make use of and run exclusively on the Windows Phone 8 operating system which opened me up to a world of new features and assets. My primary idea behind the application was to create a useful and easy to understand live tile for users which made use of all three sizes now available (small, medium and wide).\nOf course the area I first began programming in the application was the downloading of weather data from an online source and then parsing the returned XML file. Since I had never worked with reading XML file data before I researched the area a lot before perusing until I was able to create a dynamic and re-usable function to extract all the information my application required.\nOnce I’d built the whole application UI and allows the user to add their own custom locations or find their location based on current GPS coordinates I moved on to creating the live tiles for the application… At first I planned on rendering the live tiles locally for the application but due to memory restrictions on Windows Phone Scheduled Background Agents I decided to engineer a much easier and brilliant solution which involved sending the basic weather data for the live tiles to a PHP script online which would return the live tile image. I used 4 PHP scripts in total to render all the required live tile aspects which worked perfectly and looked fantastic.\nOverall Weather Phone 8 taught me a great deal more about data handling, online services and just application development in general.\nUPDATE: As of the 17th of July 2013, Weather Phone 8 has been a featured item in the Windows Phone store 4 times across 4 different countries! The Windows Phone team picks apps to be featured based on how useful and quality they are. This has resulted in Weather Phone 8 being downloaded a total of 18,000 times.\nUPDATE 2: As of 2014 Weather Phone 8 has been taken down from the Windows Phone Store due to its huge number of downloads. Live tiles were generated on a server I was renting via PHP Script and as I was paying for a shared hosting environment, 1\u0026amp;1.co.uk stopped all my scripts from running, essentially making Weather Phone 8 useless. It’s an unfortunate end for the app, however important lessons have been learnt.\n","permalink":"https://alexanderhoughton.co.uk/programming/weather-phone-8/","summary":"One of my latest software development venture was Weather Phone 8, combining the skills of all my previous applications together, allowing me to create something truly powerful. Weather Phone 8 Product Description: “Keep up to date with all your weather locations and even pin a special live tile which will always update weather for your […]","title":"Weather Phone 8 (C#, PHP, SQL)"},{"content":"Feel free to contact me on LinkedIn: https://www.linkedin.com/in/alex-houghton\n","permalink":"https://alexanderhoughton.co.uk/contact/","summary":"\u003cp\u003eFeel free to contact me on LinkedIn: \u003ca href=\"https://www.linkedin.com/in/alex-houghton\"\u003ehttps://www.linkedin.com/in/alex-houghton\u003c/a\u003e\u003c/p\u003e","title":"Contact"},{"content":"[quote]AlcoWiki is a comprehensive and detailed alcoholic drink database for the Windows Phone OS. Through the use of Windows Phone magnificent user interface integration and brilliant graphics, AlcoWiki presents a fantastic way to discover new drinks and learn loads about the ones you already love.\nWhether you love nursing a nice cold pint or downing a sweet liqueur, AlcoWiki caters to everyone. From beer to whiskey and spirits to rum, AlcoWiki has it all for your to enjoy.\nThe AlcoWiki community is here to give solid advice on every single drink on the app. With just the click of a button you can add a review for your favourite drinks to share your greatest recipes or best serving styles as well as instantly browsing others.\nWith every review a rating out of 5 thumbs is given to provide you with an overall impression of each drink from other alcohol lovers from across the world.”\nOfficial website:www.AlcoWiki.com[/quote]\nAlcoWiki has been my most ambitious and time consuming application to date while at the same time, most rewarding. I began work on AlcoWiki after I noticed there wasn’t any other app currently in the Windows Phone store offering anything similar.\nThe most rewarding part of creating AlcoWiki are the skills I have gained in making my application connect to the internet to my online database and how to efficiently and simple present a large quantity of data.\nPHP and SQL were languages I had never touched on before AlcoWiki but I was determined to set up an online review database for every drink in AlcoWiki’s database so I put in a lot of time and effort to teach it to myself. The end results were fantastic and so rewarding to see my idea become a reality.\nFor more information about AlcoWiki please visit the official website I have created for it: http://www.AlcoWiki.com/\n","permalink":"https://alexanderhoughton.co.uk/programming/alcowiki/","summary":"[quote]AlcoWiki is a comprehensive and detailed alcoholic drink database for the Windows Phone OS. Through the use of Windows Phone magnificent user interface integration and brilliant graphics, AlcoWiki presents a fantastic way to discover new drinks and learn loads about the ones you already love. Whether you love nursing a nice cold pint or downing […]","title":"AlcoWiki (C#, SQL, PHP, XAML)"},{"content":"After becoming well acquainted with the C++ programming language at university I was eager to being creating applications which could be used in the real world and I could publish. I took it upon my self to teach myself everything I needed to know about the Windows Phone OS, C# and XNA to make it possible. Below are a list of the first 5 applications I have created for Windows Phone and are all currently live in the marketplace.\nTo date, the applications below have accumulated over 10,000 downloads.\n‘True or False’ [hr]\nTrue or False presents you with either a genuine fact or complete fiction. Your job is to decide which it is!\nYour guaranteed to learn something new and have fun at the same time. With hundreds of facts and fiction and more on the way, True or False will keep you entertained for hours.\nEnjoy the awesome facts, subtle fiction \u0026amp; fantastic graphics.\nTrue or False is a great example of my use of Photoshop skills within mobile games to create a fun and quirky environment, it also challanged me in creating a reliable and efficient database which can easily be handled by the app.\nLink to the Windows Phone store: http://www.windowsphone.com/s?appid=9f71a823-1df4-4b4e-b44c-2bf5a445d1fd\n‘Ultimate Car Quiz’ [hr]\n“Take the Ultimate Car Quiz and truly test your knowledge of cars.\nWith over FIVE HUNDRED unique questions you will certainly be tested to the limit and be sure to learn something new.\nPush to Start, Amazing visuals, Personalised messages from Jezza.\nChoose from either 10, 25, 50 or All the questions in the database to truly test your knowledge of cars. ”\nUltimate Car Quiz is another prime example of some really slick and professional visuals and a massive database of questions. Ultimate Car Quiz challenged me by my decision to add animation and audio to the app to make for a brilliant experience.\nLink to the Windows Phone store: http://www.windowsphone.com/s?appid=4eda32cb-0f5f-47e2-bc7e-2bb07e5594f5\n‘Call of Duty Quiz’ [hr]\n“The ultimate way to test your knowledge of Call of Duty with high quality pictures!\nWith the Call of Duty Quiz you’ll be able to test your knowledge of Guns, Perks, Characters and Maps with over 100 different questions!\nMassive Update: Huge amount of extra and tougher questions have been added and an exciting ending to the game with Captain Price!”\nCall of Duty Quiz is by far my most popular application, it features tonnes of different images and categories to make for a comprehensive app.\nLink to the Windows Phone store: http://www.windowsphone.com/s?appid=6f3d830a-3afb-4c68-b6f1-1a35834d6261\n‘Sleep Calculator’ [hr]\n“This app will stop you from waking up tired and groggy in the morning by calculating sleep cycles!\nAs you sleep, your body goes through different stages of the sleeping process. These stages are known as cycles. In humans, each sleep cycle lasts around 90 minutes on average.\nWaking up in the middle of one of these cycles will leave you feeling grumpy and tired. It is therefore important to fall asleep and wake up at the correct time.\nBy using this app you can calculate either when you should go to bed or when you need to wake up!\nUpdate: Added how many hours each cycle equates to.”\nSleep Calculator was the first application I submitted to the Windows Phone store, it is the application that taught me all the fundamentals of the Windows Phone OS, Silverlight and C# programming so it was a good basis for future applications.\nLink to the Windows Phone store: http://www.windowsphone.com/s?appid=9bfea70c-d7e2-4b4c-8cbb-d33558d93739\n‘Black Ops II Countdown’ [hr]\n“Countdown to the 13th of November 2011 to the millisecond!\nAuthentic Black Ops II theme \u0026amp; Call of Duty feel.\nBlack Ops II is the first Call of Duty game ever to be set in the future.”\nSimilar to Sleep Calculator in that Black Ops II Countdown was an application that introduced me to the XNA game studio which allowed me to use some great looking custom fonts and designs.\nLink to the Windows Phone store: http://www.windowsphone.com/s?appid=2b562ca8-2a25-4e3b-825e-3504e4945680\n","permalink":"https://alexanderhoughton.co.uk/programming/first-windows-phone-apps/","summary":"After becoming well acquainted with the C++ programming language at university I was eager to being creating applications which could be used in the real world and I could publish. I took it upon my self to teach myself everything I needed to know about the Windows Phone OS, C# and XNA to make it […]","title":"First Windows Phone Apps (5 Different Apps)"},{"content":"Bournemouth University Software Programming: Assignment 2\nCloud Breaker was my first ever game I created for my University Assignments at Bournemouth, it taught me the fundamentals of how to draw images to buffers and screens and all the fundamentals for future games. Cloud Breaker was created using the open source Allegro API and C++;\nSince Cloud Breaker my skills have been transferred into XNA where my concepts of OOP have greatly improved and become much more integrated into my entire programming experience.\nAbout:\nCloud Breaker is a fairly simple game yet hugely addictive. With quirky graphics and funky sounds, in Cloud Breaker you must destroy / break the clouds in the sky to allow the sun to shine!\nThe aim of the game is to destroy the clouds by launching your bouncing ball at them which you must keep in the sky without touching the ground, otherwise it will damage your precious plants! When a cloud is destroyed it drops rain which can be used to bring plants back.\nHow the idea for the game developed:\nWhen I first started learning the Allegro game programming library I had no idea what kind of game I wanted to create so I just stuck with the tutorials in the book (All in one game programming: Third Edition) which I used mainly to learn the library.\nThrough the learning process I started to get some idea of the kind of game I wanted to create, it wasn’t until the later tutorials came along which featured a ball simply bouncing around the corners of the screen when I had the head for a ball breaker kind of game. So I decided to create a game in which you destroy boxes in the sky and stop the ball from falling by deflecting it with a platform.\nI wanted to get away from the grey and space themed types of this game I had seen before so I decided to go for a colourful green and plant themed game. I eventually decided that clouds would be a great thing to be placed in the air since they occur naturally in the air in the real world but I wanted to give it all a twist.\nSo I gave the clouds some character by adding faces which change every time they are hit, increasing in unhappiness and eventually shock up until the point when they burst and they release a rain drop which is happy and falls to the floor.\nIn an interesting way to represent the player’s lives, rather than text I decided to have plants along the bottom.\nGame Screenshots:\nHow requirements of the Assignment have been met:\nThe game has to be in graphics mode: The game has been created using a wide variety of Bitmap images and animation. The game must contain a user controllable object: The user controls the leaf which bounces the ball around the screen. The game must contain at least one additional non-user controller object: The clouds, rain drop, flowers and ball are all objects which the user does not directly control. The game must allow user input / control by both keyboard and mouse: Both forms of input are supported. You can control the base leaf with the two arrow keys or by using the mouse and clicking where you want it to go. The game must provide the user with feedback: Noises are made when the ball hits an object including the leaf you control. The game may contain sound: Game music and bouncing sounds are featured. The game must provide the current score: Score is kept and presented at the end of the level if you win. It is also displayed at the top at all times. The game should be single player only: Yes. The game must provide the user with simple instructions: Prompts are given for the user to launch the ball and the rules can be viewed from the level select menu. The game must begin and end in a controlled manner: Menus and dedicated closing and starting buttons are used (ESCAPE and ENTER). The game must implement at least one C++ class: The ball which the game features is implemented using a class, which stores its features and functions directly related to it. The code:\nThe code is constructed with 4 main files C++ files. These are:\nCloudbreaker.h Levels.cpp BallClass.cpp Main.cpp “Cloudbreaker.h”: The cloudbreaker.h file is included by all the .cpp files. The header file includes all the definitions in the file, such as #define BLACK makecol(0,0,0) and #define WHITE makecol(255,255,255) and #define WIDTH 480. Along with definitions which are used throughout the program, the cloudsremaining array is declared in here as it is used within the level.cpp and main.cpp file: extern int cloudsremaining[15][4];.\nFunctions used within the Levels.cpp files are declared in the header file, so that they can be used in the main program. The class for the ball is also declared in the header.\n“Levels.cpp”: The levels.cpp file consist of 5 functions which relates directly to the 5 levels which the user can play in the game.\nEach function returns the number of clouds in the level, which is used throughout the main program and also uses the cloudsremaining variable to set which clouds are where and initialize them.\n“BallClass.cpp”: The ballclass.cpp file creates the class for the ball and all the functions that are associated with it.\n“Main.cpp”: The main.cpp file is where the main bulk of the game will occur, it contains the large loops which the game and make use of all the other C++ files mentioned above.\nCode Listings will be found on the next pages:\ncloudbreaker.h\n#ifndef CLOUDBREAKER_H // Makes sure the code in the header is only run once\n#define CLOUDBREAKER_H\n#include “allegro.h”\n#include \u0026lt;stdlib.h\u0026gt;\n#include \u0026lt;stdio.h\u0026gt;\n// Definitions\n#define BLACK makecol(0,0,0)\n#define WHITE makecol(255,255,255)\n#define WIDTH 480\n#define HEIGHT 800\n#define GAMEPLAYDISTANCEFROMSCREENWIDTH 18\n#define GAMEPLAYDISTANCEFROMSCREENTOP 208\n#define GAMEPLAYDISTANCEFROMSCREENBOTTOM 44\n#define MODE GFX_AUTODETECT_WINDOWED\n#define BASEYPOSITION 680\n// Definitons\nextern int cloudsremaining[15][4]; // CLOUD NUMBER, CLOUD FACE, CLOUD X POSITION, CLOUD Y POSITION\n//function prototypes\nint loadpresetslevel_1();\nint loadpresetslevel_2();\nint loadpresetslevel_3();\nint loadpresetslevel_4();\nint loadpresetslevel_5();\nclass ballclass;\n//function prototypes\n//class\nclass ballclass\n{\npublic:\nint x,y;\nint width,height;\nint xspeed,yspeed;\nint xdelay,ydelay;\nint xcount,ycount;\nint curframe,maxframe,animdir;\nint framecount,framedelay;\nbool balllaunched;\nBITMAP *ballimage;\n//Constructor and Descructor\nballclass(BITMAP *theballimg);\n~ballclass();\nvoid reset();\nvoid updateposition();\nbool ballmissed(int basexpos,int baselength, bool isballbelow);\n};\n//class\n#endif\nlevels.cpp\n#include “cloudbreaker.h”\nint loadpresetslevel_1()\n{\n//for level 1\ncloudsremaining[0][0] = 1;\ncloudsremaining[1][0] = 1;\ncloudsremaining[2][0] = 1;\ncloudsremaining[0][1] = 0;\ncloudsremaining[1][1] = 0;\ncloudsremaining[2][1] = 0;\ncloudsremaining[0][2] = 72 + GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[0][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP;\ncloudsremaining[1][2] = 172 + GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[1][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP;\ncloudsremaining[2][2] = 272 + GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[2][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP;\n//for level 1\nreturn 3; //Return number of clouds in the level\n}\nint loadpresetslevel_2(){\n//for level 2\n//Set ALIVE and reset faces\ncloudsremaining[0][0] = 1;\ncloudsremaining[1][0] = 1;\ncloudsremaining[2][0] = 1;\ncloudsremaining[3][0] = 1;\ncloudsremaining[4][0] = 1;\ncloudsremaining[0][1] = 0;\ncloudsremaining[1][1] = 0;\ncloudsremaining[2][1] = 0;\ncloudsremaining[3][1] = 0;\ncloudsremaining[4][1] = 0;\n//Set ALIVE and reset faces\n//Positions\ncloudsremaining[0][2] = GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[0][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP;\ncloudsremaining[1][2] = 172 + GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[1][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP;\ncloudsremaining[2][2] = (480 – GAMEPLAYDISTANCEFROMSCREENWIDTH) – 100;\ncloudsremaining[2][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP;\ncloudsremaining[3][2] = 172 + GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[3][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP – 50;\ncloudsremaining[4][2] = 172 + GAMEPLAYDISTANCEFROMSCREENWIDTH;\ncloudsremaining[4][3]= 90 + GAMEPLAYDISTANCEFROMSCREENTOP + 50;\n//Positions\n//for level 2\nreturn 5;//Return number of clouds in the level\n}\nint loadpresetslevel_3(){\n//for level 3\n//Set ALIVE and Face\ncloudsremaining[0][0] = 1;\ncloudsremaining[1][0] = 1;\ncloudsremaining[2][0] = 1;\ncloudsremaining[3][0] = 1;\ncloudsremaining[4][0] = 1;\ncloudsremaining[5][0] = 1;\ncloudsremaining[0][1] = 0;\ncloudsremaining[1][1] = 0;\ncloudsremaining[2][1] = 0;\ncloudsremaining[3][1] = 0;\ncloudsremaining[4][1] = 0;\ncloudsremaining[5][1] = 0;\n//Positions\ncloudsremaining[0][2] = 19;\ncloudsremaining[0][3]= 208;\ncloudsremaining[1][2] = 363;\ncloudsremaining[1][3]= 208;\ncloudsremaining[2][2] = 19;\ncloudsremaining[2][3]= 310;\ncloudsremaining[3][2] = 363;\ncloudsremaining[3][3]= 310;\ncloudsremaining[4][2] = 19;\ncloudsremaining[4][3]= 408;\ncloudsremaining[5][2] = 363;\ncloudsremaining[5][3]= 408;\n//Positions\n//for level 3\n//Return number of clouds in the level\nreturn 6;\n}\nint loadpresetslevel_4(){\n//for level 3\n//Set ALIVE and Face\ncloudsremaining[0][0] = 1;\ncloudsremaining[1][0] = 1;\ncloudsremaining[2][0] = 1;\ncloudsremaining[3][0] = 1;\ncloudsremaining[4][0] = 1;\ncloudsremaining[5][0] = 1;\ncloudsremaining[6][0] = 1;\ncloudsremaining[7][0] = 1;\ncloudsremaining[8][0] = 1;\ncloudsremaining[0][1] = 0;\ncloudsremaining[1][1] = 0;\ncloudsremaining[2][1] = 0;\ncloudsremaining[3][1] = 0;\ncloudsremaining[4][1] = 0;\ncloudsremaining[5][1] = 0;\ncloudsremaining[6][1] = 0;\ncloudsremaining[7][1] = 0;\ncloudsremaining[8][1] = 0;\n//187\n//Positions\ncloudsremaining[0][2] = 19;\ncloudsremaining[0][3]= 208;\ncloudsremaining[1][2] = 363;\ncloudsremaining[1][3]= 208;\ncloudsremaining[2][2] = 19;\ncloudsremaining[2][3]= 310;\ncloudsremaining[3][2] = 363;\ncloudsremaining[3][3]= 310;\ncloudsremaining[4][2] = 19;\ncloudsremaining[4][3]= 408;\ncloudsremaining[5][2] = 363;\ncloudsremaining[5][3]= 408;\ncloudsremaining[6][2] = 187;\ncloudsremaining[6][3]= 208;\ncloudsremaining[7][2] = 187;\ncloudsremaining[7][3]= 310;\ncloudsremaining[8][2] = 187;\ncloudsremaining[8][3]= 408;\n//for level 3\n//Return number of clouds in the level\nreturn 9;\n}\nint loadpresetslevel_5(){\n//for level 3\n//Set ALIVE and Face\ncloudsremaining[0][0] = 1;\ncloudsremaining[1][0] = 1;\ncloudsremaining[2][0] = 1;\ncloudsremaining[3][0] = 1;\ncloudsremaining[4][0] = 1;\ncloudsremaining[5][0] = 1;\ncloudsremaining[6][0] = 1;\ncloudsremaining[7][0] = 1;\ncloudsremaining[8][0] = 1;\ncloudsremaining[9][0] = 1;\ncloudsremaining[10][0] = 1;\ncloudsremaining[11][0] = 1;\ncloudsremaining[12][0] = 1;\ncloudsremaining[13][0] = 1;\ncloudsremaining[14][0] = 1;\ncloudsremaining[8][0] = 1;\ncloudsremaining[0][1] = 0;\ncloudsremaining[1][1] = 0;\ncloudsremaining[2][1] = 0;\ncloudsremaining[3][1] = 0;\ncloudsremaining[4][1] = 0;\ncloudsremaining[5][1] = 0;\ncloudsremaining[6][1] = 0;\ncloudsremaining[7][1] = 0;\ncloudsremaining[8][1] = 0;\ncloudsremaining[9][1] = 0;\ncloudsremaining[10][1] = 0;\ncloudsremaining[11][1] = 0;\ncloudsremaining[12][1] = 0;\ncloudsremaining[13][1] = 0;\ncloudsremaining[14][1] = 0;\n//left\ncloudsremaining[0][2] = 19;\ncloudsremaining[0][3]= 208;\ncloudsremaining[1][2] = 19;\ncloudsremaining[1][3]= 258;\ncloudsremaining[2][2] = 19;\ncloudsremaining[2][3]= 308;\ncloudsremaining[3][2] = 19;\ncloudsremaining[3][3]= 358;\ncloudsremaining[4][2] = 19;\ncloudsremaining[4][3]= 408;\ncloudsremaining[5][2] = 119;\ncloudsremaining[5][3]= 408;\n//left\n//right\ncloudsremaining[6][2] = 363;\ncloudsremaining[6][3]= 208;\ncloudsremaining[7][2] = 363;\ncloudsremaining[7][3]= 258;\ncloudsremaining[8][2] = 363;\ncloudsremaining[8][3]= 308;\ncloudsremaining[9][2] = 363;\ncloudsremaining[9][3]= 358;\ncloudsremaining[10][2] = 363;\ncloudsremaining[10][3]= 408;\ncloudsremaining[11][2] = 263;\ncloudsremaining[11][3]= 408;\n//right\n//middle clouds\ncloudsremaining[12][2] = 190;\ncloudsremaining[12][3]= 208;\ncloudsremaining[13][2] = 190;\ncloudsremaining[13][3]= 258;\ncloudsremaining[14][2] = 190;\ncloudsremaining[14][3]= 308;\n//middle clouds\n//Return number of clouds in the level\nreturn 15;\n}\nBallClass.cpp\n#include “cloudbreaker.h”\n//ballcalss\nballclass::ballclass(BITMAP *theballimg)\n{\nballimage = theballimg;\nx = SCREEN_W / 2 + ballimage-\u0026gt;w;\ny = BASEYPOSITION – ballimage-\u0026gt;h;\nwidth = ballimage-\u0026gt;w;\nheight = ballimage-\u0026gt;h;\nxdelay = 1;\nydelay = 1;\nxcount = 0;\nycount = 0;\nif (rand() % 2 == 0) // chooses a random x speed for the ball, whether it goes left or right\n{\nxspeed = rand() % 2 + 1;\n}\nelse\n{\nxspeed = rand() % 1 -2;\n}\nyspeed = rand() % 2 – 3;\ncurframe = rand() % 64;\nmaxframe = 63;\nframecount = 0;\nframedelay = rand() % 5 + 1;\nballlaunched = false;\n}\nballclass::~ballclass()\n{\n//Destructor\n}\nvoid ballclass::reset() // resets all variables in the class to their standard values\n{\nx = SCREEN_W / 2 + ballimage-\u0026gt;w;\ny = BASEYPOSITION – ballimage-\u0026gt;h;\nwidth = ballimage-\u0026gt;w;\nheight = ballimage-\u0026gt;h;\nxdelay = 1;\nydelay = 1;\nxcount = 0;\nycount = 0;\nif (rand() % 2 == 0)\n{\nxspeed = rand() % 2 + 1;\n}\nelse\n{\nxspeed = rand() % 1 -2;\n}\nyspeed = rand() % 2 – 3;\ncurframe = rand() % 64;\nmaxframe = 63;\nframecount = 0;\nframedelay = rand() % 5 + 1;\nballlaunched = false;\n}\nvoid ballclass::updateposition()\n{\n//update x position\nif (++xcount \u0026gt; xdelay)\n{\nxcount = 0;\nx += xspeed;\n}\n//update y position\nif (++ycount \u0026gt; ydelay)\n{\nycount = 0;\ny += yspeed;\n}\n}\nbool ballclass::ballmissed(int basexpos,int baselength,bool isballbelow)\n{\nif (y \u0026gt; BASEYPOSITION) // IF YOU HAVE MISSED THE BALL\n{\nisballbelow = true;\nif(y + height \u0026gt; (SCREEN_H – GAMEPLAYDISTANCEFROMSCREENBOTTOM))\n{\nisballbelow = true;\nx = (basexpos + (baselength / 2) – (width / 2));\ny = BASEYPOSITION – height;\nxspeed = 3;\nyspeed = -2;\nreturn true;\n}\n}\nreturn false;\n}\n//ballclass\nMain.cpp\nAs the Main.cpp file is the largest one in the game I have only included the functions that are included within the main program. To view all code in Main.cpp check the DVD.\n//function prototypes\nint main(void);\nvoid init();\nvoid erasesprite(BITMAP *dest);\nvoid bouncesprite(ballclass \u0026amp;spr);\nint collidedcheck(ballclass \u0026amp;ball, int cloudsleft[][4],int numberofclouds);\nvoid drawcloudslevel(BITMAP *dest, int cloudsleft[][4],int noofclouds);\nvoid resetcloudarray(int cloudsleft[][4]);\nvoid restingcallback(void);\nvoid mousecontrols (bool currentgameover, int \u0026amp;basexpos, BITMAP *base);\nvoid updatebasepos(int \u0026amp;basexpos,bool currentgameover, BITMAP *base);\nvoid basehitcheck(int basexpos, ballclass \u0026amp;ball, int baselength);\nbool ballmissed(ballclass \u0026amp;ball,int basexpos,int baselength);\nvoid drawflowers(BITMAP *dest);\nvoid Drawmainscreen(BITMAP *dest, ballclass \u0026amp;ball, int basexpos, BITMAP *ballimage, int currentlevelselection);\nvoid gameovercheckanddrawrain(bool \u0026amp;currentgameover, BITMAP *dest);\nvoid levelselectionloop(BITMAP *buffer1, BITMAP *arrow,BITMAP *levelbackground,BITMAP *rules);\nvoid drawsunrotate(BITMAP *sunface, BITMAP *sunflare, BITMAP *dest, float \u0026amp;angle);\nvoid updateframerate();\nvoid waitforusertolaunch(ballclass \u0026amp;theball,int \u0026amp;basexpos,BITMAP *buffer1, BITMAP *theballimg,bool \u0026amp;currentgameover,int \u0026amp;temploop);\nvoid WINorLOSE(bool \u0026amp;currentgameover, BITMAP *buffer1,ballclass \u0026amp;theball, int basexpos, BITMAP *theballimg,BITMAP *sunface, BITMAP *sunflare, float angle);\n//function prototypes\nTesting \u0026amp; problems:\nOne of the biggest problems I faced while creating the game was the collision detection of the ball with the clouds. I came up with the algorithm to detect whether the cloud had been hit fairly quickly as it was simple seeing if the x and y positions are inside the clouds.\nThe big problems raised when I had to detect which side the cloud was hit and what the ball should do afterwards since. I drew out lots of ideas on paper in order to try and get the ball to collide and then bounce off in the opposite direction but there was always something that went wrong, usually the ball colliding and the direction of the ball not changing properly so the cloud would collide with the ball over 5 times and would be destroyed instantly with just one hit.\nAfter much thought and design I eventually came up with a design which decides where the ball collides by using a different corner of the ball to decide which edge has been hit because there is always one corner that cannot be above one edge of the cloud if another is elsewhere so drawing that out I managed to work out the algorithm.\nThe image below shows my notes for my final design of the ball collision and the code can be found in the function: int collidedcheck(ballclass \u0026amp;ball, int cloudsleft[][4],int numberofclouds);\nOther tests once the game was complete and expected results:\nTest Expected Result Actual Result Pressing Enter at the welcome screen Game progresses to level select screen Game progresses to level select screen Pressing up and down arrow keys moves on the level selection Pressing down button moves arrow down 1 level until the bottom and the same for the up button. Pressing down button moves arrow down 1 level until the bottom and the same for the up button. Press “R” to view rules Rule screen appears Rule screen appears When playing the game, lose all lives Game over screen displayed and game ends Game over screen displayed and game ends Win a game on any level Game win screen and score displayed Game win screen and score displayed When ball hits the darkest grey cloud Cloud destroyed and rain starts falling Cloud destroyed and rain starts falling When the main game background music ends Main game background music restarts Main game background music restarts ","permalink":"https://alexanderhoughton.co.uk/programming/cloud-breaker/","summary":"Bournemouth University Software Programming: Assignment 2 Cloud Breaker was my first ever game I created for my University Assignments at Bournemouth, it taught me the fundamentals of how to draw images to buffers and screens and all the fundamentals for future games. Cloud Breaker was created using the open source Allegro API and C++; Since […]","title":"Cloud Breaker (C++ \u0026 Allegro)"},{"content":"At the start of September I was offered the chance to start writing technology articles for my nextdoor neighbour, head of the company EMR Digital.\n“Entertainment Media Research was founded in 1997 by Peter Ruppert, formerly Head of Music Information at MTV Europe in anticipation of the digital entertainment revolution.\nToday, Entertainment Media Research is Europe’s foremost entertainment research consultancy. Headquartered in London it serves the film, music, broadcast and advertising industries in the UK, Continental Europe, Scandinavia, USA and Australasia. The company is independent and privately-owned.”\nI am currently writing four unique technology related articles per month. The articles are media rich and contain reviews of the latest technology and hardware. They are all around 700 to 1000 words in length.\nThe Articles range from gaming reviews, mobile phone reviews, gadget reviews and other types of technology and gadget related items on the market today.\nI am responsible for creating, writing and submitting a set amount of articles on a weekly / monthly basis for a huge range of different technology, gadgets, games and more. The job has improved my communication skills greatly as well as my ability manage time and balance work.\nTo date I have written over 100 unique articles for EMR Digital for a variety of different websites.\nIn addition to work for EMR, I have written countless number of articles for CallofDutyMapPacks.com as well as Top-Ten.TV.\n","permalink":"https://alexanderhoughton.co.uk/creative-writing/creative-writing/","summary":"At the start of September I was offered the chance to start writing technology articles for my nextdoor neighbour, head of the company EMR Digital. “Entertainment Media Research was founded in 1997 by Peter Ruppert, formerly Head of Music Information at MTV Europe in anticipation of the digital entertainment revolution. Today, Entertainment Media Research is […]","title":"Creative Writing"},{"content":"After finishing my A Levels and was about to begin studying Games Technology at Bournemouth University I knew I would have to start learning a completely new programming langauge to Visual Basic: C++. I’d heard a lot about C++ and knew it wasn’t going to be as simple and straight forward as learning VB as the code writing was a lot more technical and complex.\nI began learning about C++ through university and a beginners guide I had bought and it just started coming to me naturally, once I realised that essentially the algorithms and strategies to writing code were essentially identical to VB other than it was phrased different it became a breeze. From this I learnt that one of the most important aspects of programming is principle, if you’ve got that learnt well then applying it in different languages really isn’t too hard!\nMy first C++ project was a BlackJack game based on a Windows Console which was perfect for easing me into the new language and becoming reaquainted with all my programming skills. Within the program I implemented Bubble searches, strings and decent visuals (for a console game!).\nThe report and preliminary design for the BlackJack game also taught me a great deal about how programmers would work in commercial companies, planning out there strategies before hand with flow diagrams and pseudo code.\n","permalink":"https://alexanderhoughton.co.uk/programming/c-programming/","summary":"After finishing my A Levels and was about to begin studying Games Technology at Bournemouth University I knew I would have to start learning a completely new programming langauge to Visual Basic: C++. I’d heard a lot about C++ and knew it wasn’t going to be as simple and straight forward as learning VB as […]","title":"C++ Programming"},{"content":"Welcome to AlexanderHoughton.co.uk, a creative showcase of all my work over the years.\nMy name is Alex Houghton, I am a student at Bournemouth University in the United Kingdom currently studying Computer Games Technology.\nI’ve always loved computer games and technology since I first started playing them on my family’s first ever PC. The classic games that opened the world of computing and video games to me were Doom 2 and Abe’s Oddyseyy. Compared to what games look like currently it really is amazing how fast the technology and software has developed over the years. I’ve seen over the years how the games industry has progressed and become one of the biggest entertainment industries in the world, the fantastic part is, it’s still growing. Games are getting better and better, more realistic in terms of graphics and gameplay and I wish someday to be a part of this brilliant industry.\nThrough my love of Games has developed a passion for all areas of computing and programming, leading me to creating a number of unique applications and games outside the bounds of my learning curriculum.\nPlease click on one of the categories on the right to see all my work in that particular field.\n","permalink":"https://alexanderhoughton.co.uk/welcome/","summary":"\u003cp\u003e\u003ca href=\"/images/welcome/alex-houghton-photo.png\"\u003e\u003cimg src=\"/images/welcome/alex-houghton-photo-262x300.webp\" alt=\"Photo of Alex Houghton sitting outdoors in a black hoodie among green trees\" width=\"183\" height=\"210\" class=\"alignright\" loading=\"lazy\"\u003e\u003c/a\u003eWelcome to AlexanderHoughton.co.uk, a creative showcase of all my work over the years.\u003c/p\u003e\n\u003cp\u003eMy name is Alex Houghton, I am a student at Bournemouth University in the United Kingdom currently studying Computer Games Technology.\u003c/p\u003e\n\u003cp\u003eI’ve always loved computer games and technology since I first started playing them on my family’s first ever PC. The classic games that opened the world of computing and video games to me were Doom 2 and Abe’s Oddyseyy. Compared to what games look like currently it really is amazing how fast the technology and software has developed over the years. I’ve seen over the years how the games industry has progressed and become one of the biggest entertainment industries in the world, the fantastic part is, it’s still growing. Games are getting better and better, more realistic in terms of graphics and gameplay and I wish someday to be a part of this brilliant industry.\u003c/p\u003e","title":"Welcome!"},{"content":"I first started learning the Visual Basic.NET programming at the beginning of my A Levels. Visual Basic.NET opened the world of programming to me and taught me all the fundamentals I needed to know. We started off learning console programming and basic loops and ended up creating full, form based programmes using Object Oriented Programming (OOP).\nThe programming aspect was my favourite part of my Computing course since it allowed me freedom to create things in my own way and challange me logically.\nFor my end of year project, I created a program for my driving instructor so that he could manage all his lessons and bookings in one, user friendly environment.\nThe project was implemented with objects, binary files and printed outputs in a Windows form based environment. The whole project took me through the stages of analysis, development, design, implementation, testing, user manuals and evaluation which brilliant since it gave me an insight to how programs and projects are created in industy….\nThrough the use of Objects I realised how useful and versatile they are, I learnt about relationships between different objects and the heirarchy that they can be used to form.\nI recieved an A* grade for the project part of my computing course.\n","permalink":"https://alexanderhoughton.co.uk/programming/visual-basic-net/","summary":"I first started learning the Visual Basic.NET programming at the beginning of my A Levels. Visual Basic.NET opened the world of programming to me and taught me all the fundamentals I needed to know. We started off learning console programming and basic loops and ended up creating full, form based programmes using Object Oriented Programming […]","title":"Visual Basic.NET"},{"content":"Again around the time of my GCSE’s and early into my A levels I started playing around with Adobe Photoshop, having heard of it before I always wanted to see what the buzz was all about and what the software was capable of.\nHaving no prior knowledge to the tool I joined a small online community called SimpleGFX.net which supplied members with tutorials and tips on how to use Photoshop and encouraged users to post and show off the pictures that they had created.\nThere were many types of images people showcased but the area which interested me most was creating so called “Signiture” images which are commonly used in all types of forums and such.\nThe basic idea behind each signiture was to base it around an image of a character or model image you find anywhere on the internet which you then cut out completely and build a background and signiture around it. You usually include you online alias somewhere in the image to mark it as you own and make it more like a proper signiture.\nMaking it all blend in and look really nice what you are trying to achieve and the results look really good.\nCheck out the images below of some of the Photoshop signutures I have created over the years:\nAlong with all the content above, I also designed the banner and buttons on this website.\n","permalink":"https://alexanderhoughton.co.uk/photoshop/showcase-adobe-photoshop/","summary":"Again around the time of my GCSE’s and early into my A levels I started playing around with Adobe Photoshop, having heard of it before I always wanted to see what the buzz was all about and what the software was capable of. Having no prior knowledge to the tool I joined a small online […]","title":"Showcase: Adobe Photoshop"},{"content":"Towards the end of my GCSE’s I started experimenting with the extremely powerful Adobe Premiere Pro video editing software, learning how it worked all through experimentation and self teaching I started creating karaoke style DVD’s for my Dad for his social gatherings.\nMy Dad also created his own music songs which I created the videos for in my own unique way. Through the use of Photoshop and Premiere Pro I was able to create some really interesting and entertaining music videos.\nI uploaded majority of the videos I created to YouTube to share my videos with the world, some videos have gained some fairly substantial viewing figures. I’ve selected some of the best videos that I have created and embedded them below, enjoy!\nAdobe Premiere Pro gave me a great insight and taught me how certain effects and techniques are used in commercial videos and television and how much potential the piece of software has in terms of what it is capable of accomplishing.\n","permalink":"https://alexanderhoughton.co.uk/premiere-pro/showcase-premiere-pro-music-videos/","summary":"Towards the end of my GCSE’s I started experimenting with the extremely powerful Adobe Premiere Pro video editing software, learning how it worked all through experimentation and self teaching I started creating karaoke style DVD’s for my Dad for his social gatherings. My Dad also created his own music songs which I created the videos […]","title":"Showcase: Premiere Pro music videos"},{"content":"","permalink":"https://alexanderhoughton.co.uk/curriculum-vitae/","summary":"","title":"Curriculum Vitae"}]