GBuffer.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <vector>
  10. class GBuffer
  11. {
  12. public:
  13. // Different types of data stored in the G-buffer
  14. enum Type
  15. {
  16. EDiffuse = 0,
  17. ENormal,
  18. EWorldPos,
  19. NUM_GBUFFER_TEXTURES
  20. };
  21. GBuffer();
  22. ~GBuffer();
  23. // Create/destroy the G-buffer
  24. bool Create(int width, int height);
  25. void Destroy();
  26. // Get the texture for a specific type of data
  27. class Texture* GetTexture(Type type);
  28. // Get the framebuffer object ID
  29. unsigned int GetBufferID() const { return mBufferID; }
  30. // Setup all the G-buffer textures for sampling
  31. void SetTexturesActive();
  32. private:
  33. // Textures associated with G-buffer
  34. std::vector<class Texture*> mTextures;
  35. // Frame buffer object ID
  36. unsigned int mBufferID;
  37. };