Skip to content

Instantly share code, notes, and snippets.

View jblocksom's full-sized avatar

Jonathan Blocksom jblocksom

View GitHub Profile
Last summer Apple introduced Metal, a new 3D graphics API for iOS devices featuring faster, more detailed access to the graphics hardware. In this session we will introduce programmers to the Metal API. We will start with a high level overview of Metal and how it compares to OpenGL, comparing the two and seeing what the cost is for the extra graphics speed. We will look at using Metal for GPU based computation, using the Metal Shading Language for rendering, and how to combine them for intense GPU powered apps.
-(void)initOffscreenContext
{
CGSize layerSize = [self bounds].size;
layerSize.height = floorf(layerSize.height);
layerSize.width = floorf(layerSize.width);
if (layerSize.height <= 0 || layerSize.width <=0)
{
self.offscreenContext = nil;
return;
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@jblocksom
jblocksom / pg76.m
Created January 7, 2014 18:02
Some handy snippets for the iCloud chapter
#pragma mark - iCloud
- (BOOL)hasiCloud
{
BOOL hasiCloud = ([self ubiquitousDocumentsURL] != nil);
return hasiCloud;
}
- (void)setUseiCloud:(BOOL)value
{
GLfloat boxVerts[] = {
// left side
-1.0, -1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, 1.0, 1.0,
// right side
for (BNRNerd *nerd in self.nerds) {
[self.geocodeQueue addOperationWithBlock:^{
NSOperationQueue *managingQueue = [NSOperationQueue currentQueue];
[geocoder geocodeAddressString:nerd.locationStr completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = placemarks[0];
nerd.location = placemark.location;
[self fetchWeatherForNerd:nerd];
[managingQueue setSuspended:NO];
}];
[managingQueue setSuspended:YES];
@jblocksom
jblocksom / Constants.m
Last active December 21, 2015 09:39
Helpers for Quartz chapter
#define RANGE (700.0f)
// RANGE is the range of values that are OK
#define B_MARGIN (10.0f)
// B_MARGIN is the bottom margin in points
#define T_MARGIN (10.0f)
// T_MARGIN is the top margin in points
#define H_GAP (10.4f)
@jblocksom
jblocksom / cubeIndices.c
Created August 9, 2013 17:27
Cube Indices for OpenGL 3D Transforms chapter
GLuint cubeTriIndicesBottomTop[] = {
// Bottom
0, 1, 2, 0, 2, 3,
// Top
4, 5, 6, 4, 6, 7,
};
GLuint cubeTriIndicesFrontBack[] = {
// Front
0, 4, 1, 4, 1, 5,
GLfloat vertices[] = {
// left side
-1.0, -1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, 1.0, 1.0,
// right side
1.0, -1.0, -1.0,
//
// BNRPerson.h
// SalesReport
//
// Created by Jonathan Blocksom on 4/1/13.
// Copyright (c) 2013 Jonathan Blocksom. All rights reserved.
//
#import <Foundation/Foundation.h>