Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
//
// SimpleGLObject.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "SimpleGLObject.h"
#import <GLKit/GLKit.h>
//
// FlexiVertexBuffer.h
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import <UIKit/UIKit.h>
#import "SimpleGLObject.h"
//
// FlexiVertexBuffer.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "FlexiVertexBuffer.h"
GLfloat gCubeVertexData[216] =
//
// ViewController.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "ViewController.h"
#import "SimpleGLObject.h"
#import "FlexiVertexBuffer.h"
@mousebird
mousebird / Sphere FlexiVertexBuffer.mm
Last active December 20, 2015 18:58
FlexiVertexBuffer Sphere
// Number of samples in each direction
static const int LongitudeSample=20,LatitudeSample=10;
- (void)addSphereAt:(float *)org sized:(float *)size
{
// We'll generate the coordinates and normals ahead of time
float coords[3*LongitudeSample*LatitudeSample];
float norms[3*LongitudeSample*LatitudeSample];
float texCoords[2*LongitudeSample*LatitudeSample];
// Create a single sphere, with texture
- (void)setupTexturedSphere
{
// We need an earth texture
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"NaturalEarth" ofType:@"tif"];
texture = [GLKTextureLoader textureWithContentsOfFile:filePath options:nil error:&error];
// A single cube, centered at the origin
float origin[3] = {0,0.5,0};
// Set up the vertex array (note this can only be done on the main thread)
- (void)makeVertexArray
{
// Create a vertex array object and set up its internal state
glGenVertexArraysOES(1, &_vertexArray);
glBindVertexArrayOES(_vertexArray);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
// Normally you'd have to do this each time
// For elevation mode, we need to do some other stuff
if (startupMapType == MaplyGlobeWithElevation)
{
// Tilt, so we can see it
if (globeViewC)
[globeViewC setTiltMinHeight:0.001 maxHeight:0.04 minTilt:1.21771169 maxTilt:0.0];
globeViewC.frameInterval = 2; // 30fps
// An elevation source. This one just makes up sine waves to get some data in there
elevSource = [[MaplyElevationDatabase alloc] initWithName:@"world_web_mercator"];
/** The Elevation Source Delegate provides elevation data on demand for
a given tile. It returns a MaplyElevationChunk or nil if no data
is available. Your delegate may be called on a random thread, act accordingly.
*/
@protocol MaplyElevationSourceDelegate
/// Coordinate system we're providing the data in (and extents)
- (MaplyCoordinateSystem *)getCoordSystem;
/// Minimum zoom level (e.g. 0)
@mousebird
mousebird / gist:6816008
Created October 3, 2013 19:49
MicroStyles Example
"styles" :
[
{
"name": "fire station",
"type": "marker",
"color": "#FFFFFFFF",
"sizeX": 20.0,
"sizeY": 20.0,
"fade": 0.5,
"icon": "fire_station.png"