Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.5 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. //
  3. // cglmfbo.h
  4. // GLMgr FBO's (render targets)
  5. //
  6. //===============================================================================
  7. #ifndef CGLMFBO_H
  8. #define CGLMFBO_H
  9. #pragma once
  10. #include "glmgr/cglmtex.h"
  11. // good FBO references / recaps
  12. // http://www.songho.ca/opengl/gl_fbo.html
  13. // http://www.gamedev.net/reference/articles/article2331.asp
  14. // ext links
  15. // http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
  16. // http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt
  17. //===============================================================================
  18. // tokens not in the SDK headers
  19. #ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
  20. #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
  21. #endif
  22. //===============================================================================
  23. // forward declarations
  24. class GLMContext;
  25. // implicitly 16 maximum color attachments possible
  26. enum EGLMFBOAttachment {
  27. kAttColor0, kAttColor1, kAttColor2, kAttColor3,
  28. kAttColor4, kAttColor5, kAttColor6, kAttColor7,
  29. kAttColor8, kAttColor9, kAttColor10, kAttColor11,
  30. kAttColor12, kAttColor13, kAttColor14, kAttColor15,
  31. kAttDepth, kAttStencil, kAttDepthStencil,
  32. kAttCount
  33. };
  34. struct GLMFBOTexAttachParams
  35. {
  36. CGLMTex *m_tex;
  37. int m_face; // keep zero if not cube map
  38. int m_mip; // keep zero if notmip mapped
  39. int m_zslice; // keep zero if not a 3D tex
  40. };
  41. class CGLMFBO
  42. {
  43. public:
  44. protected:
  45. friend class GLMContext; // only GLMContext can make CGLMFBO objects
  46. friend class GLMTester;
  47. friend class CGLMTex;
  48. friend class IDirect3D9;
  49. friend class IDirect3DDevice9;
  50. CGLMFBO( GLMContext *ctx );
  51. ~CGLMFBO( );
  52. void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
  53. void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
  54. // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other.
  55. void TexScrub( CGLMTex *tex );
  56. // search and destroy any attachment for the named texture
  57. bool IsReady( void ); // aka FBO completeness check - ready to draw
  58. GLMContext *m_ctx; // link back to parent context
  59. GLuint m_name; // name of this FBO in the context
  60. GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment
  61. int m_sizeX,m_sizeY;
  62. };
  63. #endif