SHARE
TWEET

Untitled

a guest Jun 27th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this->width = width;
  2. this->height = height;
  3. glGenFramebuffers(1, &framebuffer);
  4. glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
  5.  
  6. glGenTextures(1, &texture);
  7. glBindTexture(GL_TEXTURE_2D, texture);
  8.  
  9. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  10. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  11. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  12. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  13.  
  14. switch (components) {
  15.     case 1: glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, height, 0, GL_RED, GL_HALF_FLOAT, 0); break;
  16.     case 2: glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, height, 0, GL_RG, GL_HALF_FLOAT, 0); break;
  17.     case 3: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, width, height, 0, GL_RGB, GL_HALF_FLOAT, 0); break;
  18.     case 4: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_HALF_FLOAT, 0); break;
  19.     default: Log::Write("Unknown format");
  20. }
  21.  
  22.  
  23. if(GL_NO_ERROR != glGetError()) Log::Write("Could not create texture");
  24.  
  25. GLuint colorbuffer;
  26. glGenRenderbuffers(1, &colorbuffer);
  27. glBindRenderbuffer(GL_RENDERBUFFER, colorbuffer);
  28. glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
  29.  
  30. if(GL_NO_ERROR != glGetError()) Log::Write("Could not attach framebuffer");
  31.  
  32. if(GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER)) Log::Write("Could not create framebuffer");
  33.  
  34. glClearColor(0, 0, 0, 0);
  35. glClear(GL_COLOR_BUFFER_BIT);
  36. glBindFramebuffer(GL_FRAMEBUFFER, 0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top