Posts

Showing posts from May, 2011

Gymboree Starship

The prototype can be seen on Caspian's T-Shirt from Gymboree.

_
,'|`.
/ | \
/ | \
/. / \ .\
/. / \ .\
/. | | .\
/| /_____|___|_____\ |\
|| | | -= =- | | ||
.|| ,-'| | | |`-. ||.
| `-'___| | | |___`-' |
|________| | =---= | |________|
| | | |
| |___H___| |
| [| | |] |
|__|___|___|__|
\ /
\ /

ASCII Art

I'm starting to migrate my Star Trek ASCII Art Archive to ye olde blogosphere. Seems like the right thing to do.
Probably about 10 minutes after I finish I'll realize I should have used gist.github.com or a wiki or something so people could collaborate on it.

requestAnimationFrame Shim/Polyfill

Trying out GitHub just for kicks. (Still preferring Mercurial as a VCS though.)

Don't use this - see the code in Web Standards Polyfill instead // requestAnimationFrame polyfill // http://webstuff.nfshost.com/anim-timing/Overview.html /*jslint browser:true*/ window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || (function () { var requests = {}, TARGET_FPS = 60, raf_handle = 1, timeout_handle = -1; function isVisible(element) { return element.offsetWidth > 0 && element.offsetHeight > 0; } window.requestAnimationFrame = function requestAnimationFrame(callback, element) { var cb_handle = raf_handle; raf_handle = raf_handle + 1; requests[cb_handle] = {callback: callb…

Applesoft BASIC in JavaScript updated

My Applesoft BASIC in JavaScript page is updated. It now actually compiles the BASIC program to JavaScript before running... although the executor, library, and I/O are all linked in during compilation so it's not emitting anything re-usable. Sorry.

C++ Optimization Trick

Maybe this is old hat, but when I was writing a software rasterizer several years ago I came up with a trick for getting optimized variations for different render states (textured, flat shaded, Gouraud shaded, wireframe, z-write, z-test, cull-ccw, etc) without hand-writing multiple permutations of the rasterizer as is recommended by LaMothe and others. It requires an optimizing C++ compiler that supports template functions. The trick is to pack as much state as possible into a single POD value like a 32-bit integer, write your function so that all of the if() tests for render state look at the integer for branching decisions, and call a template function that takes this value as a template parameter in a constant context like a switch statement. Here's the base function full of nasty branches: result_t func(int flags, const data_t& data) { if (flags & OPT_A) { // ... } if (flags & OPT_B) { if (flags & OPT_C) { // ... } else { // ... }…