Sample.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Copyright (c) 2008-2014 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "Application.h"
  24. namespace Urho3D
  25. {
  26. class Sprite;
  27. }
  28. // All Urho3D classes reside in namespace Urho3D
  29. using namespace Urho3D;
  30. /// Sample class, as framework for all samples.
  31. /// - Initialization of the Urho3D engine (in Application class)
  32. /// - Modify engine parameters for windowed mode and to show the class name as title
  33. /// - Create Urho3D logo at screen;
  34. /// - Set custom window title and icon;
  35. /// - Create Console and Debug HUD, and use F1 and F2 key to toggle them;
  36. /// - Toggle rendering options from the keys 1-8;
  37. /// - Take screenshot with key 9
  38. /// - Handle Esc key down to hide Console or exit application;
  39. class Sample : public Application
  40. {
  41. // Enable type information.
  42. OBJECT(Sample);
  43. public:
  44. /// Construct.
  45. Sample(Context* context);
  46. /// Setup before engine initialization. Modifies the engine parameters.
  47. virtual void Setup();
  48. /// Setup after engine initialization. Creates the logo, console & debug HUD.
  49. virtual void Start();
  50. /// Control logo visibility.
  51. void SetLogoVisible(bool enable);
  52. protected:
  53. /// Logo sprite.
  54. SharedPtr<Sprite> logoSprite_;
  55. private:
  56. /// Create logo.
  57. void CreateLogo();
  58. /// Set custom window Title & Icon
  59. void SetWindowTitleAndIcon();
  60. /// Create console and debug HUD.
  61. void CreateConsoleAndDebugHud();
  62. /// Handle key down event to process key controls common to all samples.
  63. void HandleKeyDown(StringHash eventType, VariantMap& eventData);
  64. };
  65. #include "Sample.inl"