Sky.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. //========================================================================
  3. // Sky.h - implements a sky box in either D3D9 or D3D11
  4. //
  5. // Part of the GameCode4 Application
  6. //
  7. // GameCode4 is the sample application that encapsulates much of the source code
  8. // discussed in "Game Coding Complete - 4th Edition" by Mike McShaffry and David
  9. // "Rez" Graham, published by Charles River Media.
  10. // ISBN-10: 1133776574 | ISBN-13: 978-1133776574
  11. //
  12. // If this source code has found it's way to you, and you think it has helped you
  13. // in any way, do the authors a favor and buy a new copy of the book - there are
  14. // detailed explanations in it that compliment this code well. Buy a copy at Amazon.com
  15. // by clicking here:
  16. // http://www.amazon.com/gp/product/1133776574/ref=olp_product_details?ie=UTF8&me=&seller=
  17. //
  18. // There's a companion web site at http://www.mcshaffry.com/GameCode/
  19. //
  20. // The source code is managed and maintained through Google Code:
  21. // http://code.google.com/p/gamecode4/
  22. //
  23. // (c) Copyright 2012 Michael L. McShaffry and David Graham
  24. //
  25. // This program is free software; you can redistribute it and/or
  26. // modify it under the terms of the GNU Lesser GPL v3
  27. // as published by the Free Software Foundation.
  28. //
  29. // This program is distributed in the hope that it will be useful,
  30. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  32. // http://www.gnu.org/licenses/lgpl-3.0.txt for more details.
  33. //
  34. // You should have received a copy of the GNU Lesser GPL v3
  35. // along with this program; if not, write to the Free Software
  36. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  37. //
  38. //========================================================================
  39. #include "Geometry.h"
  40. #include "SceneNodes.h"
  41. #include "Material.h"
  42. #include "Shaders.h"
  43. // Forward declarations
  44. class Scene;
  45. ////////////////////////////////////////////////////
  46. //
  47. // class SkyNode - Chapter 16, page 554
  48. //
  49. // Implements a believable sky that follows
  50. // the camera around - this is a base class that the D3D9 and D3D11 classes
  51. // inherit from
  52. //
  53. ////////////////////////////////////////////////////
  54. class SkyNode : public SceneNode
  55. {
  56. protected:
  57. unsigned int m_numVerts;
  58. unsigned int m_sides;
  59. const char * m_textureBaseName;
  60. std::shared_ptr<CameraNode> m_camera;
  61. bool m_bActive;
  62. std::string GetTextureName(const int side);
  63. public:
  64. SkyNode(const char *textureFile);
  65. virtual ~SkyNode();
  66. int VPreRender(Scene *pScene);
  67. bool VIsVisible(Scene *pScene) const { return m_bActive; }
  68. };
  69. class OpenGLSkyNode46 : public SkyNode
  70. {
  71. public:
  72. OpenGLSkyNode46(const char* pTextureBaseName);
  73. virtual ~OpenGLSkyNode46();
  74. int VOnRestore(Scene *pScene);
  75. int VRender(Scene *pScene);
  76. protected:
  77. GLuint m_vao;
  78. GLuint m_vbo;
  79. GLuint m_ebo;
  80. size_t m_numIndices;
  81. OpenGLShaderProgram m_ShaderProgram;
  82. };