Miscellaneous small code snippets.

15
2
C++

Miscellaneous small code snippets.

PrintStream

A hierarchy of classes that represent abstract concept of a text-based stream that can be printed into, using methods like print(const char* str), printf(const char* format, ....) etc. Derived classes offer printing to console (standard output), to file, to memory buffer and more.

DisplaySettingsTest

A simple Windows console C program that demonstrates how to enumerate and change display modes (screen resolution and refresh rate). See my blog post: How to change display mode using WinAPI?.

IsLog10.c

Simple C program demonstrating multiple solutions to a question: “Write a function that checks whether an integer number is a power of 10.” Contains a set of tests. See my blog post: How to check if an integer number is a power of 10?.

QueryPerformanceCounterTest.cpp

Simple C++ console program that tests how long it takes to call WinAPI function QueryPerformanceCounter. See my blog post: When QueryPerformanceCounter call takes long time.

VulkanAfterCrash.h

Simple, single-header, C++ library for Vulkan that simplifies writing 32-bit markers to a buffer that can be read after graphics driver crash and thus help you find out which specific draw call or other command caused the crash, pretty much like NVIDIA Aftermath library for Direct3D 11/12. See my blog post: Debugging Vulkan driver crash - equivalent of NVIDIA Aftermath.

IncludeList.py

Simple Python script that parses given text file to find the list of files included by it using #include <FileName> or #include "FileName", recursively. Supports -I parameter for additional include directories. Supports any programming language that uses C-like preprocessor, e.g. C, C++, HLSL, GLSL.

Shortcomings: ► Doesn’t parse comments or perform full preprocessing, so includes commented out using multiline comment /* ... */ or macros like #if 0 are still parsed. ► File names are case-sensitive, so files includes with different capitalization are treated as separate.