Skip to content

Instantly share code, notes, and snippets.

View DavidLudwig's full-sized avatar

David Ludwig DavidLudwig

View GitHub Profile
@DavidLudwig
DavidLudwig / MSVC_AST_GEN.cmd
Created September 18, 2022 02:39 — forked from K2/MSVC_AST_GEN.cmd
MSVC AST generation
REM AST generation from MSVC
cl /analyze /d1Aprintast %1 > %1.ast
constexpr bool constexpr_strequal(const char * a, const char * b)
{
// Assume that NULL != NULL
if (!a || !b) {
return false;
}
// If pointers are equal, values are equal
if (a == b) {
return true;
#include <QtWidgets>
static uchar pixel_buffer[512 * 512 * 4];
class MyWidget : public QWidget {
Q_OBJECT
private:
QImage * _image = nullptr;
//
// Compile with: em++ test-threads.cpp -o test-threads.html -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -s USE_SDL=2
//
// Expected behavior: program starts with a black screen, smoothly fades it to
// green, then resets (show black screen, fades-in green, rinse and repeat).
//
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
/*
A proposal to reduce io2d's namespace, by combining 'basic_FOO' and 'FOO' typenames, to 'FOO'
Author: David Ludwig <dludwig@pobox.com>
Version: 1
@DavidLudwig
DavidLudwig / portfile.cmake
Last active August 1, 2018 19:01
io2d + vcpkg, portfile.cmake
include(vcpkg_common_functions)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO cpp-io2d/P0267_RefImpl
REF 51fb21aaf4d2d4ef96d6e13ce3a2880a024a3058
SHA512 6080e7ebd6de186801ab9ca5da01c4ed08c5b58de611e8f8323d449794a91a30897a746761f86de7f0f2786eac46bbcb69afd0d542736be1e9c5385853636ba7
HEAD_REF master
)
file(INSTALL ${SOURCE_PATH}/P0267_RefImpl/P0267_RefImpl DESTINATION ${CURRENT_PACKAGES_DIR}/include)
#include <io2d.h>
#include <mutex>
using namespace std;
using namespace std::experimental;
using namespace std::experimental::io2d;
static output_surface & display() {
static auto surface = output_surface{500, 500, format::argb32, scaling::none, refresh_style::fixed, 30.f};
return surface;
//
// ShowBitmap_Mac68k.cpp
// by David Ludwig <dludwig@pobox.com>
//
// Shows a 1-bit, XBM bitmap on an emulated (via pce-macplus) 4 MB Mac Plus.
//
// Compiled with g++ flags:
// -Os -o romtest.o -fno-builtin -m68000 -nostdlib -mpcrel -Xlinker --oformat=binary
@DavidLudwig
DavidLudwig / Vagrantfile
Created September 12, 2017 18:30
BasiliskII, make Linux build via Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "fedora/26-cloud-base"
config.vm.box_version = "20170705"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
void DrawTestPattern_OpenGL1(float w, float h)
{
glCullFace(GL_FRONT_AND_BACK);
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0); // top-left
glVertex2f(-w, h); // triangle 1
glVertex2f(-w, 0);
glVertex2f( 0, 0);
glVertex2f( 0, 0); // triangle 2
glVertex2f( 0, h);