Team Fortress 2 Source Code as on 22/4/2020
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.

103 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. // TOGL CODE LICENSE
  3. //
  4. // Copyright 2011-2014 Valve Corporation
  5. // All Rights Reserved.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25. // cglmfbo.h
  26. // GLMgr FBO's (render targets)
  27. //
  28. //===============================================================================
  29. #ifndef CGLMFBO_H
  30. #define CGLMFBO_H
  31. #pragma once
  32. // good FBO references / recaps
  33. // http://www.songho.ca/opengl/gl_fbo.html
  34. // http://www.gamedev.net/reference/articles/article2331.asp
  35. // ext links
  36. // http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
  37. // http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt
  38. //===============================================================================
  39. // tokens not in the SDK headers
  40. #ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
  41. #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
  42. #endif
  43. //===============================================================================
  44. // forward declarations
  45. class GLMContext;
  46. enum EGLMFBOAttachment
  47. {
  48. kAttColor0, kAttColor1, kAttColor2, kAttColor3,
  49. kAttDepth, kAttStencil, kAttDepthStencil,
  50. kAttCount
  51. };
  52. struct GLMFBOTexAttachParams
  53. {
  54. CGLMTex *m_tex;
  55. int m_face; // keep zero if not cube map
  56. int m_mip; // keep zero if notmip mapped
  57. int m_zslice; // keep zero if not a 3D tex
  58. };
  59. class CGLMFBO
  60. {
  61. friend class GLMContext;
  62. friend class GLMTester;
  63. friend class CGLMTex;
  64. friend struct IDirect3D9;
  65. friend struct IDirect3DDevice9;
  66. public:
  67. CGLMFBO( GLMContext *ctx );
  68. ~CGLMFBO( );
  69. protected:
  70. void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
  71. void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
  72. // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other.
  73. void TexScrub( CGLMTex *tex );
  74. // search and destroy any attachment for the named texture
  75. bool IsReady( void ); // aka FBO completeness check - ready to draw
  76. GLMContext *m_ctx; // link back to parent context
  77. GLuint m_name; // name of this FBO in the context
  78. GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment
  79. };
  80. #endif