Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
// 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};
@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];
//
// ViewController.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "ViewController.h"
#import "SimpleGLObject.h"
#import "FlexiVertexBuffer.h"
//
// FlexiVertexBuffer.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "FlexiVertexBuffer.h"
GLfloat gCubeVertexData[216] =
//
// FlexiVertexBuffer.h
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import <UIKit/UIKit.h>
#import "SimpleGLObject.h"
//
// SimpleGLObject.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "SimpleGLObject.h"
#import <GLKit/GLKit.h>
//
// SimpleGLObject.h
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import <UIKit/UIKit.h>
/* A wrapper around the data we need to draw a single
//
// ViewController.m
// NSMeetupExample
//
// Created by [email protected] on 8/6/13.
//
#import "ViewController.h"
#import "SimpleGLObject.h"
#import "FlexiVertexBuffer.h"
/* A wrapper around the data we need to draw a single
OpenGL ES related object.
*/
@interface SimpleGLObject : NSObject
// The buffer in OpenGL driver space containing the vertices
@property GLuint vertexBuffer;
// Vertex arrays contain the state to draw our object
@property GLuint vertexArray;
MaplyPlateCarree *coordSys = [[MaplyPlateCarree alloc] initFullCoverage];
MaplyWMSTileSource *tileSource = [[MaplyWMSTileSource alloc] initWithBaseURL:@"http://raster.nationalmap.gov/ArcGIS/services/Orthoimagery/USGS_EDC_Ortho_NAIP/ImageServer/WMSServer" layers:@[@"0"] coordSys:coordSys minZoom:0 maxZoom:16 tileSize:256];
tileSource.transparent = true;
MaplyQuadEarthTilesLayer *layer = [[MaplyQuadEarthTilesLayer alloc] initWithCoordSystem:coordSys tileSource:tileSource];
layer.handleEdges = true;
layer.cacheDir = thisCacheDir;
[baseViewC addLayer:layer];