Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. const GLenum attachments[] = {GL_COLOR_ATTACHMENT1};
  2. glDrawBuffers(1, attachments);
  3.  
  4. // Assuming the FBO and the 2 requried textures were correctly generated
  5.  
  6. glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
  7. glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _fbo_tex[0], 0);
  8. glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, _fbo_tex[1], 0);
  9.  
  10. // glCheckFramebufferStatus(GL_FRAMEBUFFER) returns GL_FRAMEBUFFER_COMPLETE
  11.  
  12. #version 300 es
  13.  
  14. uniform mat4 modelviewProjectionMatrix;
  15. in vec4 position;
  16.  
  17. void main() {
  18. gl_Position = modelviewProjectionMatrix * position;
  19. }
  20.  
  21. #version 300 es
  22.  
  23. uniform lowp vec4 colorIn;
  24. layout(location = 0) out lowp vec4 colorOut;
  25.  
  26. void main() {
  27. colorOut = colorIn;
  28. }
  29.  
  30. // Assuming the correct program and vertex array is bound
  31.  
  32. glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);
  33. {
  34. const GLenum attachments[] = {GL_COLOR_ATTACHMENT0};
  35. glDrawBuffers(1, attachments); // OK
  36. glClear(GL_COLOR_BUFFER_BIT);
  37.  
  38. // Draw red quad to GL_COLOR_ATTACHMENT0
  39. }
  40. {
  41. const GLenum attachments[] = {GL_COLOR_ATTACHMENT1};
  42. glDrawBuffers(1, attachments); // GL_INVALID_OPERATION Error
  43. glClear(GL_COLOR_BUFFER_BIT);
  44.  
  45. // Draw green quad to GL_COLOR_ATTACHMENT1
  46. }
  47.  
  48. const GLenum attachments[] = {GL_NONE, GL_COLOR_ATTACHMENT1};
  49. glDrawBuffers(2, attachments); // OK
  50. glClear(GL_COLOR_BUFFER_BIT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement