Skip to content

Instantly share code, notes, and snippets.

<xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://yournamespace/ui" xmlns:ui="http://yournamespace/ui" elementFormDefault="qualified">
<xs:element name="UI">
</xs:element>
</xs:schema>
@stuart6854
stuart6854 / generate_checkerboard_texture.cpp
Last active January 9, 2024 10:10
C++ Checkerboard Texture
// Credit: https://paminerva.github.io/docs/LearnDirectX/01.E-Hello-Texture.html
auto GenerateCheckerBoardTexture() -> std::vector<uint8_t>
{
const uint32_t textureWidth = 256;
const uint32_t textureHeight = 256;
const uint32_t texturePixelSize = 4; // Bytes per pixel
const uint32_t rowPitch = textureWidth * texturePixelSize;
const uint32_t cellPitch = rowPitch >> 3; // Width of a cell in the checkerboard.
const uint32_t cellHeight = textureWidth >> 3; // Height of a cell in the checkerboard.
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,bugprone*,modernize*,performance*,readability*,cppcoreguidelines*,misc*,-modernize-use-nodiscard,-*magic-numbers,-readability-uppercase-literal-suffix,-misc-non-private-member-variables-in-classes'
# Format Style Options - Created with Clang Power Tools
---
AlignAfterOpenBracket: BlockIndent
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AlignArrayOfStructures: Right
AllowAllArgumentsOnNextLine: false
AlwaysBreakTemplateDeclarations: Yes
BasedOnStyle: WebKit
@stuart6854
stuart6854 / ansi_codes.h
Created June 30, 2020 18:17
C/C++ ANSI Escape Codes for Printing
#ifndef ANSI_CODES_H
#define ANSI_CODES_H
#ifdef _WIN32
// Windows (x64 and x86)
#define ANSI_RESET
#define ANSI_BLACK
#define ANSI_RED
#define ANSI_GREEN
#define ANSI_YELLOW
@stuart6854
stuart6854 / StrMan.h
Created June 13, 2020 10:51
C++ Header-only String Manipulation Library
#ifndef STRMAN_H
#define STRMAN_H
#include <string>
namespace StrMan
{
auto is_char_number(char char_) -> bool
{
// Returns true if the character is between 0 and 9 inclusive
@stuart6854
stuart6854 / Lexer.cpp
Created June 12, 2020 17:37
Lexer/Tokeniser implementation
#include <string>
#include <string_view>
#include <cstddef>
#include <utility>
#include <ostream>
class Token
{
public:
enum class Kind