Skip to content

Instantly share code, notes, and snippets.

@mousebird
Created August 7, 2013 22:25
Show Gist options
  • Select an option

  • Save mousebird/6179430 to your computer and use it in GitHub Desktop.

Select an option

Save mousebird/6179430 to your computer and use it in GitHub Desktop.
// 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};
float size[3] = {0.5,0.5,0.5};
FlexiVertexBuffer *flexiBuffer = [[FlexiVertexBuffer alloc] init];
[flexiBuffer addSphereAt:origin sized:size];
// If we got a valid texture, we'll use that
// This works because there's only the one.
if (texture)
{
self.effect.texture2d0.envMode = GLKTextureEnvModeModulate;
self.effect.light0.diffuseColor = GLKVector4Make(1.0f, 1.0f, 1.0f, 1.0f);
self.effect.texture2d0.target = GLKTextureTarget2D;
self.effect.texture2d0.name = texture.name;
}
SimpleGLObject *glObject = [flexiBuffer makeSimpleGLObject];
[_glObjects addObject:glObject];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment