Sample.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // Copyright (c) 2008-2013 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. /// - Create Console and Debug HUD, and use F1 and F2 key to toggle them;
  35. /// - Toggle rendering options from the keys 1-8;
  36. /// - Handle Esc key down to hide Console or exit application;
  37. class Sample : public Application
  38. {
  39. // Enable type information.
  40. OBJECT(Sample);
  41. public:
  42. /// Construct.
  43. Sample(Context* context);
  44. /// Setup before engine initialization. Modifies the engine parameters.
  45. virtual void Setup();
  46. /// Setup after engine initialization. Creates the logo, console & debug HUD.
  47. virtual void Start();
  48. /// Control logo visibility.
  49. void SetLogoVisible(bool enable);
  50. protected:
  51. /// Logo sprite.
  52. SharedPtr<Sprite> logoSprite_;
  53. private:
  54. /// Create logo.
  55. void CreateLogo();
  56. /// Create console and debug HUD.
  57. void CreateConsoleAndDebugHud();
  58. /// Handle key down event to process key controls common to all samples.
  59. void HandleKeyDown(StringHash eventType, VariantMap& eventData);
  60. };
  61. #include "Sample.inl"