Graphics Reference
In-Depth Information
//set up colors
GLfloat texCoords[] =
{
0.0f , 1.0f ,
0.0f , 0.0f ,
1.0f , 0.0f ,
1.0f , 1.0f
};
//draw triangle
glEnableVertexAttribArray ( GLKVertexAttribPosition );
glEnableVertexAttribArray ( GLKVertexAttribTexCoord0 );
glVertexAttribPointer ( GLKVertexAttribPosition , 2 ,
GL_FLOAT , GL_FALSE , 0 , vertices);
glVertexAttribPointer ( GLKVertexAttribTexCoord0 , 2 ,
GL_FLOAT , GL_FALSE , 0 , texCoords);
glDrawArrays ( GL_TRIANGLE_FAN , 0 , 4 );
//present render buffer
glBindRenderbuffer ( GL_RENDERBUFFER , _colorRenderbuffer );
[ self . glContext presentRenderbuffer : GL_RENDERBUFFER ];
}
- ( void )viewDidLoad
{
[ super viewDidLoad ];
//set up context
self . glContext =
[[ EAGLContext alloc ] initWithAPI : kEAGLRenderingAPIOpenGLES2 ];
[ EAGLContext setCurrentContext : self . glContext ];
//set up layer
self . glLayer = [ CAEAGLLayer layer ];
self . glLayer . frame = self . glView . bounds ;
self . glLayer . opaque = NO ;
[ self . glView . layer addSublayer : self . glLayer ];
self . glLayer . drawableProperties =
@{ kEAGLDrawablePropertyRetainedBacking : @NO ,
kEAGLDrawablePropertyColorFormat : kEAGLColorFormatRGBA8 } ;
//load texture
glActiveTexture ( GL_TEXTURE0 );
NSString *imageFile = [[ NSBundle mainBundle ] pathForResource : @"Snowman"
ofType : @"pvr" ];
Search WWH ::




Custom Search