Skip to content

Instantly share code, notes, and snippets.

View DavidLudwig's full-sized avatar

David Ludwig DavidLudwig

View GitHub Profile
extern SDL_Renderer * _renderer;
static SDL_bool UI_SaveScreenshotBMP(const char * fileName)
{
int w = 0;
int h = 0;
SDL_GetWindowSize(_window, &w, &h);
const int bytesPerPixel = 4;
const int pitch = w * bytesPerPixel;
@DavidLudwig
DavidLudwig / sdl2gles2gears.c
Last active November 15, 2022 09:45
GLGears for SDL2 + OpenGL ES 2
/*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@DavidLudwig
DavidLudwig / SDLBugCount.sh
Last active August 29, 2015 14:22
SDL 2.0.4 bug tracker for OS X or KDE
#!/bin/bash
#
# SDL 2.0.4 Bug-"Count" Checker for Mac OS X or KDE
# Version 1.6
#
# Requirements:
# - any one of the following command-line notification tools:
# - Growl and growlnotify, for Mac OS X, available at http://growl.info
# - kdialog, for KDE
# - notify-send, for generic Linux notifications
#include <boost/utility/string_ref.hpp>
#include <stdio.h>
void process(boost::string_ref part) {
printf("process(\"%s\")\n", part.to_string().c_str());
}
void split(boost::string_ref s, const char delim) {
size_t p;
[Info][00:00:00.0004760] AppSession: Starting Xamarin Inspector client
[Error][00:00:03.0925560] AgentSessionWindowController: Unable to open workbook: System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: There is an error in XML document (0, 0). ---> System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) <0x11dd41a40 + 0x000b1> in <filename unknown>:0
at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo (System.String res) <0x11dd413f0 + 0x0008b> in <filename unknown>:0
at System.Xml.XmlTextReaderImpl.ParseDocumentContent () <0x11cbebb80 + 0x006db> in <filename unknown>:0
at System.Xml.XmlTextReaderImpl.Read () <0x11cbe05f0 + 0x0007c> in <filename unknown>:0
at System.Xml.XmlTextReader.Read () <0x11cbe05d0 + 0x0001a> in <filename unknown>:0
at System.Xml.XmlReader.MoveToContent () <0x11cbe0480 + 0x00084> in <filename unknown>:0
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationRe
@DavidLudwig
DavidLudwig / log_sdl_clocs.sh
Last active May 13, 2016 17:26
SDL2 backend(s), line-counts (via 'cloc')
#!/bin/bash
SRC="$1"
if [ "$SRC" == "" ]; then
SRC="src/video"
fi
HG_REV="$(hg summary | grep parent | awk '{print $2}')"
HG_REV_DATE="$(hg log -r $HG_REV | grep date | perl -pne 's/^[^:]*:\W*//')"
HG_CHANGESET="$(echo $HG_REV | perl -pne 's/.*://')"
HG_URL="https://hg.libsdl.org/SDL/rev/$HG_CHANGESET"
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);
@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
//
// 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
#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;