Skip to content

Instantly share code, notes, and snippets.

@DanielGibson
DanielGibson / gist:4526283
Created January 13, 2013 21:25
try to fix longnecks
diff --git a/neo/d3xp/anim/Anim_Blend.cpp b/neo/d3xp/anim/Anim_Blend.cpp
index cacf5f1..4215336 100644
--- a/neo/d3xp/anim/Anim_Blend.cpp
+++ b/neo/d3xp/anim/Anim_Blend.cpp
@@ -5490,19 +5490,19 @@ bool idAnimator::GetJointLocalTransform( jointHandle_t jointHandle, int currentT
// FIXME: overkill
CreateFrame( currentTime, false );
- if( jointHandle > 0 )
- {
@DanielGibson
DanielGibson / gist:5595590
Last active December 17, 2015 10:29
idGameLocal::CalcFov from dhewm3/neo/game/Game_local.cpp - modified with additional assertions and debug-prints and some comments on how [https://github.com/dhewm/dhewm3/issues/70] shouldn't happen (my guess is that renderSystem->GetScreenWidth() and/or renderSystem->GetScreenHeight() return 0 or a negative value)
void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const {
float x;
float y;
float ratio_x;
float ratio_y;
assert(base_fov > 0);
// first, calculate the vertical fov based on a 640x480 view
// XXX: will be positive because tan() is positive if the given value is positive as asserted above
@DanielGibson
DanielGibson / Makefile
Created September 25, 2013 23:14
Makefile for Deep Impact: Freefall
# Makefile for Deep Impact: Freefall
# (C) 2013 Daniel Gibson, do whatever you want with it
#
# needs GNU make, tested on Linux, should work on other unix-like systems as well
# also needs SDL2, SDL2 image and SDL2 ttf + development headers etc
# and a C++11 and GCC compatible C++ compiler (tested g++ 4.7 and clang++ 3.3)
# CC := clang
# CXX := clang++
@DanielGibson
DanielGibson / imgLoadBench.c
Last active August 29, 2015 14:17
Crappy benchmark for stb_image, lodepng, libjpeg and libpng
// The Results: http://wp.me/pEPJ4-4S
// you can define USE_LIBPNG to decode with libpng XOR USE_LODEPNG to decode with lodepng
// XOR USE_LIBJPEG to decode with libjpeg or libjpeg-turbo XOR nothing to use stb_image.
// you'll have to provide the corresponding headers and (for libjpeg and libpng) libs to link against
// for lodepng also compile lodepng.c into the binary
// ex: gcc -O4 -DUSE_LODEPNG imgLoadBench.c lodepng.c -o imgLoadBench_lodepng_gcc_O4
// or: gcc -O0 -DUSE_LIBPNG imgLoadBench.c -o imgLoadBench_libpng_gcc_O0 -lpng
// or: gcc -O2 -DUSE_LIBJPEG imgLoadBench.c -o imgLoadBench_libjpeg_gcc_O2 -ljpeg
// or: clang -O3 imgLoadBench.c -o imgLoadBench_stb_clang_O3
@DanielGibson
DanielGibson / sdl2test.c
Last active April 22, 2024 18:13
test SDL2 input (mouse and keyboard events)
/*
* SDL2 mousebutton test
*
* build with:
* $ gcc $(sdl2-config --cflags) -o sdl2test sdl2test.c $(sdl2-config --libs)
*/
#include <stdio.h>
#include <SDL.h>
#include <errno.h>
@DanielGibson
DanielGibson / FrameAlloc.hpp
Last active August 29, 2015 14:22
Simple C++ Allocator that doesn't reuse memory until it's Reset()
/*
* A simple allocator that uses a fixed sized memory buffer and doesn't reuse
* memory until it's Reset()
* It's untested and not thread-safe (achieving that shouldn't be hard, though,
* see comment at AllocBlock())
*
*
* (C) 2015 Daniel Gibson
*
* License:
@DanielGibson
DanielGibson / encPng.c
Created July 18, 2015 02:30
Hacky cmdline app that converts to png with several encoders for comparison
/*
* Encodes a given file to png using stb_image_write, miniz, lodepng and libpng
*
* Useful to compare the compression ratios achievable with the different encoders.
* Blog post with results: http://wp.me/pEPJ4-5U
*
* Needs:
* - stb_image.h and stb_image_write.h from https://github.com/nothings/stb
* - lodepng.c and lodepng.h from http://lodev.org/lodepng/
* - miniz.c from https://github.com/richgel999/miniz
@DanielGibson
DanielGibson / daikatana-wal.txt
Last active March 2, 2018 20:42
Description of the .wal format as used in Daikatana
The Daikatana .wal format is similar to Quake2, but supports a palette per texture
(even if it's not always used, see below) and 9 mipmap levels instead of 4.
If you wanna check whether a .wal is in daikatana or q2 format, check whether
the first byte is == 3 (daikatana) or > 32 (ASCII ' '; then it's likely Quake2)
because in Quake2 it's the name which should start with a printable ASCII char.
Having 9 MipMap levels implies that for many textures, the last levels will be
1x1 pixels... Daikatana itself stops loading more mipmaps once the last loaded
one has a width or height of 1.
Each mipmap level has half the width and height of the previous one.
@DanielGibson
DanielGibson / daikatana-pak.txt
Last active April 1, 2016 19:32
Description of Daikatana .pak format
// Daikatana .pak format. It's similar to Quake/Quake2 format, but supports compressed files as well.
// I think that only the following file types are compressed: .tga .bmp .wal .pcx .bsp
// I wouldn't rely on this list when unpacking, but when packing, only compress those.
// the structs are based on pakextract.c from https://github.com/yquake2/pakextract
// all ints are 32bit Little Endian.
struct pak_header
{
char signature[4]; // {'P','A','C','K'}, like in Quake/Quake2
@DanielGibson
DanielGibson / parse_dk_wal_and_8bit_bmp.c
Last active April 4, 2016 01:28
Hacky code that parses and displays Daikatana .wal files and 8bit BMP files
/*
* Kinda messy code to parse and display 8bit BMPs and Daikatana wals
* Can also be compiled to check whether the colormaps of textures in a
* directory match that of the corresponding colormap.bmp
*
* Note that it currently only displays the first mipmap level of a .wal texture
* and ignores the animname, flags, contents and value fields of the header.
*
* (C) 2016 Daniel Gibson
*