1
1

renderTarget.d 748 B

123456789101112131415161718192021222324
  1. module three.renderTarget;
  2. import three.common;
  3. struct RenderTarget {
  4. uint width;
  5. uint height;
  6. GLuint textureTarget;
  7. }
  8. void construct(out RenderTarget renderTarget, uint width, uint height) nothrow {
  9. renderTarget.width = width;
  10. renderTarget.height = height;
  11. glCheck!glGenTextures(1, &renderTarget.textureTarget);
  12. glCheck!glBindTexture(GL_TEXTURE_2D, renderTarget.textureTarget);
  13. glCheck!glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, width, height);
  14. glCheck!glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_FLOAT, null);
  15. glCheck!glBindTexture(GL_TEXTURE_2D, 0);
  16. }
  17. void destruct(ref RenderTarget renderTarget) nothrow {
  18. glCheck!glDeleteTextures(1, &renderTarget.textureTarget);
  19. renderTarget = RenderTarget.init;
  20. }