Graphics Reference
In-Depth Information
}
- ( void )drawFrame
{
//bind framebuffer & set viewport
glBindFramebuffer ( GL_FRAMEBUFFER , _framebuffer );
glViewport ( 0 , 0 , _framebufferWidth , _framebufferHeight );
//bind shader program
[ self . effect prepareToDraw ];
//clear the screen
glClear ( GL_COLOR_BUFFER_BIT );
glClearColor ( 0.0 , 0.0 , 0.0 , 1.0 );
//set up vertices
GLfloat vertices[] =
{
- 0.5f , - 0.5f , - 1.0f ,
0.0f , 0.5f , - 1.0f ,
0.5f , - 0.5f , - 1.0f ,
};
//set up colors
GLfloat colors[] =
{
0.0f , 0.0f , 1.0f , 1.0f ,
0.0f , 1.0f , 0.0f , 1.0f ,
1.0f , 0.0f , 0.0f , 1.0f ,
};
//draw triangle
glEnableVertexAttribArray ( GLKVertexAttribPosition );
glEnableVertexAttribArray ( GLKVertexAttribColor );
glVertexAttribPointer ( GLKVertexAttribPosition ,
3 , GL_FLOAT , GL_FALSE , 0 , vertices);
glVertexAttribPointer ( GLKVertexAttribColor ,
4 , GL_FLOAT , GL_FALSE , 0 , colors);
glDrawArrays ( GL_TRIANGLES , 0 , 3 );
//present render buffer
glBindRenderbuffer ( GL_RENDERBUFFER , _colorRenderbuffer );
[ self . glContext presentRenderbuffer : GL_RENDERBUFFER ];
}
- ( void )viewDidLoad
Search WWH ::




Custom Search