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
#include <stdio.h> | |
int glfwInit(); | |
void glfwOpenWindowHint(int, int); | |
int glfwOpenWindow(int, int, int, int, int, int, int, int, int); | |
const unsigned char * glGetString(unsigned int); | |
void glfwTerminate(); | |
int main() | |
{ |
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
import Control.Monad (when) | |
import Data.Bits ((.|.)) | |
import Foreign.C.String (withCString) | |
import Foreign.Marshal.Alloc (alloca) | |
import Foreign.Marshal.Array (withArray) | |
import Foreign.Ptr (nullPtr) | |
import Foreign.Storable (peek) | |
import Graphics.Rendering.OpenGL.Raw -- OpenGLRaw-1.3.0.0 | |
import Graphics.UI.GLFW -- GLFW-b-0.1.0.5 |
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
module Vector3 where | |
data Vector3 = Vector3 Double Double Double deriving (Eq, Show) | |
add (Vector3 x1 y1 z1) (Vector3 x2 y2 z2) = Vector3 (x1+x2) (y1+y2) (z1+z2) |
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
#define PRINT_VAR(NAME, FORMAT) fprintf(stderr, "%20s: "FORMAT"\n", #NAME, NAME) | |
#define PRINT_PTR(NAME) PRINT_VAR(NAME, "%p") |
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
// FIXME: does not work as intended if both left and right modifier key are pressed simultaneously!!! | |
- (NSUInteger)modifierFlagMaskForKeyCode:(unsigned short)keyCode | |
{ | |
switch(keyCode) | |
{ | |
case 54: // right cmd | |
case 55: // left cmd | |
return NSCommandKeyMask; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
// assumes abs is branch-free | |
// see http://graphics.stanford.edu/~seander/bithacks.html#IntegerAbs | |
int triangle_wave_gen0(int i, int max_value) // min_value fixed to 0 | |
{ | |
i += max_value; | |
i %= max_value * 2; |
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
div.ii, textarea.Ak | |
{ | |
font-family: monospace !important; | |
font-size: 10pt !important; | |
} |
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
- (void)startAnimating | |
{ | |
if(self.displayLink) | |
return; | |
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(tick:)]; | |
[self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; | |
} | |
- (void)stopAnimating |
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
#define A(...) [NSArray arrayWithObjects:__VA_ARGS__, nil] | |
#define D(...) [NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil] | |
NSArray *a = A(@"foo", @"bar"); | |
NSDictionary *d = D(@"1", @"foo", @"2", @"bar"); |
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
// get list of all fonts on iPhone | |
for(NSString *familyName in [UIFont familyNames]) | |
{ | |
NSLog(@"%@", familyName); | |
for(NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) | |
NSLog(@" %@", fontName); | |
} |