This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void check_for_leaks() | |
| { | |
| GLuint max_id = 10000; // better idea would be to keep track of assigned names. | |
| GLuint id; | |
| // if brute force doesn't work, you're not applying it hard enough | |
| for ( id = 1 ; id <= max_id ; id++ ) | |
| { | |
| #define CHECK( type ) if ( glIs##type( id ) ) fprintf( stderr, "GLX: leaked " #type " handle 0x%x\n", (unsigned int) id ) | |
| CHECK( Texture ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implicit conversion in ndx = 0 assignment, should be ndx = 0u | |
| for (uint ndx = 0; ndx < count; ndx+++) | |
| ... | |
| // Implicit conversion in ndx+2, should be ndx+2u | |
| uint ndx = ...; | |
| myArray[ndx+2] = value; | |
| // Implicit conversion, array.length() returns int | |
| uint threadCount = ...; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.highlight = function(text, sample) { | |
| var escapedSample = sample.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); | |
| var reSample = new RegExp(escapedSample, 'g'); | |
| var args = ['']; | |
| var highlightedText = text.replace(reSample, function(match) { | |
| args.push('background-color: #ffc', 'background-color: none'); | |
| return '%c' + match + '%c'; | |
| }); | |
| args[0] = highlightedText; | |
| console.log.apply(console, args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Uses pycgen: https://github.com/Celtoys/pycgen | |
| // Generates code for C, HLSL, CUDA and OpenCL | |
| // | |
| void SH_Y2(float3 n, cmp_out float y[9]) | |
| { | |
| /*$pycgen | |
| from math import pi | |
| from math import sqrt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ////////////////////////////////////////////////////////////////////////////////// | |
| // console.log to screen | |
| ////////////////////////////////////////////////////////////////////////////////// | |
| ;(function(){ | |
| var container = document.createElement('div') | |
| container.dataset.name = 'consoleLogOnScreen' | |
| container.style.width = '100%'; | |
| container.style.height = '100%'; | |
| container.style.position = 'absolute'; | |
| container.style.fontSize = '100%'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require 'cl) | |
| (require 'peg) | |
| (defcustom dbg-mi-process-name "dbg-mi" "") | |
| (defcustom dbg-mi-buffer-name "*dbg-mi*" "") | |
| (defvar dbg-mi-process nil) | |
| (defvar dbg-mi-buffer nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun dbg-watch (expression) | |
| (interactive "sExpression: ") | |
| (dbg-mi-command (list 'dbg-watch-handler expression) "-var-create - @ %s" (prin1-to-string expression))) | |
| (defun dbg-watch-handler (status result expression) | |
| (case status | |
| ((done) | |
| (push (cons (cons 'expression expression) result) dbg-watches))) | |
| (dbg-render-watches)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // C/C++ tips for using printf-style functions | |
| // Lots of manipulation can be expressed simply and fast with printf-style formatting | |
| // Also helps reducing the number of temporaries, memory allocations or copies | |
| // ( If you are looking for a simple C++ string class that is printf-friendly and not heap-abusive, | |
| // I've been using this one: https://github.com/ocornut/Str ) | |
| // If you are interested in a FASTER implementation of sprintf functions, see stb_sprintf.h | |
| // https://github.com/nothings/stb/blob/master/stb_sprintf.h | |
| // How to concatenate non-zero terminated strings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html lang="en"> | |
| <head> | |
| <title>Listing 2-2, Load Shaders From DOM</title> | |
| <meta charset="utf-8"> | |
| <script id="shader-vs" type="x-shader/x-vertex"> | |
| attribute vec3 aVertexPosition; | |
| void main() { | |
| gl_Position = vec4(aVertexPosition, 1.0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Delta Compression by Glenn Fiedler. | |
| This source code is placed in the public domain. | |
| http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/ | |
| */ | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <assert.h> | |
| #include <string.h> |