UiSprite.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreHardwareVertexBuffer.h>
  17. #include <OgreRenderQueueListener.h>
  18. #include <OgreRoot.h>
  19. #include "UiWidget.h"
  20. /**
  21. * A sprite.
  22. */
  23. class UiSprite : public UiWidget{
  24. public:
  25. /**
  26. * Constructor.
  27. *
  28. * @param name[in] The sprite name.
  29. */
  30. UiSprite(const Ogre::String& name);
  31. /**
  32. * Constructor.
  33. *
  34. * @param name[in] The sprinte name.
  35. * @param path_name[in] Path to the sprite file.
  36. * @param parent[in] Widget to be set as parent of the sprite.
  37. * @todo path_name is relative to data? Filename is needed?
  38. */
  39. UiSprite(
  40. const Ogre::String& name, const Ogre::String& path_name,
  41. UiWidget* parent
  42. );
  43. /**
  44. * Destructor.
  45. */
  46. virtual ~UiSprite();
  47. /**
  48. * Loads an initializes the sprite.
  49. */
  50. void Initialise();
  51. /**
  52. * Updates the sprite state.
  53. */
  54. virtual void Update();
  55. /**
  56. * Renders the sprite.
  57. */
  58. virtual void Render();
  59. /**
  60. * Updates the sprite state.
  61. */
  62. virtual void UpdateTransformation();
  63. /**
  64. * Sets the sprite image.
  65. *
  66. * @param image[in] @todo file path or just a name?
  67. */
  68. void SetImage(const Ogre::String& image);
  69. /**
  70. * Sets the vertex shader for the sprite.
  71. *
  72. * @param shader[in] The shader to set.
  73. */
  74. void SetVertexShader(const Ogre::String& shader);
  75. /**
  76. * Sets the fragment shader for the sprite.
  77. *
  78. * @param shader[in] The shader to set.
  79. */
  80. void SetFragmentShader(const Ogre::String& shader);
  81. /**
  82. * Recalculates the sprite geometry.
  83. */
  84. void UpdateGeometry();
  85. private:
  86. /**
  87. * Constructor.
  88. */
  89. UiSprite();
  90. /**
  91. * Creates a vertex buffer for the sprite.
  92. */
  93. void CreateVertexBuffer();
  94. /**
  95. * Destroys a vertex buffer for the sprite.
  96. */
  97. void DestroyVertexBuffer();
  98. /**
  99. * The sprite material.
  100. */
  101. Ogre::MaterialPtr material_;
  102. /**
  103. * The scene manager.
  104. */
  105. Ogre::SceneManager* scene_manager_;
  106. /**
  107. * The render system.
  108. */
  109. Ogre::RenderSystem* render_system_;
  110. /**
  111. * The render operation.
  112. */
  113. Ogre::RenderOperation render_operation_;
  114. /**
  115. * The vertex buffer.
  116. */
  117. Ogre::HardwareVertexBufferSharedPtr vertex_buffer_;
  118. };