title: Why doesn't multisampling work?
body: <p>I'm trying to get multisampling to work in my OpenGL ES app.</p>
  
  <p>Framebuffer setup code:</p>
  
  <pre><code>glGenFramebuffersOES(1, &amp;framebuffer);
  glGenRenderbuffersOES(1, &amp;colorRenderbuffer);
  
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);  
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
  [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id&lt;EAGLDrawable&gt;)self.layer];
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);
  
  GLint backingWidth;
  GLint backingHeight;
  glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &amp;backingWidth);
  glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &amp;backingHeight);
  
  glGenFramebuffersOES(1, &amp;sampleFramebuffer);
  glBindFramebufferOES(GL_FRAMEBUFFER_OES, sampleFramebuffer);
  
  glGenRenderbuffersOES(1, &amp;sampleColorRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
  glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_RGBA8_OES, backingWidth, backingWidth);
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, sampleColorRenderbuffer);
  
  glGenRenderbuffersOES(1, &amp;sampleDepthRenderbuffer);
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, sampleDepthRenderbuffer);
  glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, 4, GL_DEPTH_COMPONENT16_OES, backingWidth, backingWidth);
  glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, sampleDepthRenderbuffer);
  </code></pre>
  
  <p>Rendering code:</p>
  
  <pre><code>glBindFramebufferOES(GL_RENDERBUFFER_OES, sampleFramebuffer);
  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
  
  GLfloat vertices[] = {
      1.0f, 1.0f, 0.0f,
      2.0f, 4.0f, 0.0f,
      1.0f, 3.0f, 0.0f
  };
  glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
  glVertexPointer(3, GL_FLOAT, 0, vertices);
  glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
  
  glBindFramebufferOES(GL_READ_FRAMEBUFFER_APPLE, sampleFramebuffer);
  glBindFramebufferOES(GL_DRAW_FRAMEBUFFER_APPLE, framebuffer);
  glResolveMultisampleFramebufferAPPLE();
  
  glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
  [context presentRenderbuffer:GL_RENDERBUFFER_OES];
  </code></pre>
  
  <p>Result:</p>
  
  <p><img src="https://i.stack.imgur.com/jk1JX.png" alt="Rendering result"></p>
  
  <p>As you can see triangle still has aliased sides.</p>