Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. glGenTextures(1, &tex);
  2. glBindTexture(GL_TEXTURE_2D, tex);
  3. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  4. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  5. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  6. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  7. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
  8. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
  9. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
  10.  
  11. glGenFramebuffers(1, &renderTexture);
  12. glBindFramebuffer(GL_FRAMEBUFFER, renderTexture);
  13. glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex, 0);
  14.  
  15. if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
  16. {
  17. std::cout <<"n Error in framebuffer";
  18. }
  19.  
  20. GLint val = glCheckFramebufferStatus(GL_FRAMEBUFFER);
  21.  
  22. if(val != GL_FRAMEBUFFER_COMPLETE)
  23. {
  24. std::cout <<"n Error in framebuffer : 2";
  25. }
  26.  
  27. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  28. glClearColor(0.0f,1.0f,0.0f,0.0f);
  29.  
  30. glBindFramebuffer(GL_FRAMEBUFFER, 0);
  31. glBindFramebuffer(GL_READ_FRAMEBUFFER, renderTexture);
  32.  
  33. glBlitFramebuffer(0, 0, 128, 128, 0, 0, 128, 128, GL_COLOR_BUFFER_BIT, GL_NEAREST);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement