title: Draw a straight line using OpenGL ES in iPhone?
body: <p>Finally i tried to draw a line using OpenGL ES framework in XCode 4.2 for iPhone simple game app.I studied something about GLKView and GLKViewController to draw a line in iPhone. Here is my sample code that was i tried in my project,</p>
  
  <pre><code>@synthesize context = _context;
  @synthesize effect = _effect;
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
  
      if (!self.context) {
          NSLog(@"Failed to create ES context");
      }
  
  
      GLKView *view = (GLKView *)self.view;
      view.context = self.context;
      view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
      [EAGLContext setCurrentContext:self.context];
  
      //[self setupGL];
  }
  
  - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
  {
      NSLog(@"DrawInRect Method");
  
      [EAGLContext setCurrentContext:self.context];
  
      // This method is calling multiple times....
  
      glClearColor(0.65f, 0.65f, 0.65f, 1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
  
     const GLfloat line[] = 
     {
          -0.5f, -0.5f, //point A 
          0.5f, -0.5f, //point B  
     };
     glVertexPointer(2, GL_FLOAT, 0, line);
     glEnableClientState(GL_VERTEX_ARRAY);
     glDrawArrays(GL_LINES, 0, 2);
  }
  </code></pre>
  
  <p>When i run the project only the gray color only appearing in the screen, the line not showing. And also the <code>- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect</code> delegate is calling infinite time. Please guide me where i am doing wrong. Why the line not appearing or drawing? Can you please help? Am trying this 2 days. Thanks in advance.</p>