QGearsTexCodec.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 <OgreImageCodec.h>
  17. #include <OgreCodec.h>
  18. #include "QGearsPrerequisites.h"
  19. namespace QGears{
  20. /**
  21. * Handles text encoding from font images.
  22. */
  23. class _QGearsExport TexCodec : public Ogre::ImageCodec{
  24. public:
  25. /**
  26. * Constructor.
  27. */
  28. TexCodec();
  29. /**
  30. * Destructor.
  31. */
  32. virtual ~TexCodec();
  33. /**
  34. * Retrieves the codec type.
  35. *
  36. * @return The codec type.
  37. */
  38. virtual Ogre::String getType() const;
  39. /**
  40. * Encodes data.
  41. *
  42. * Unimplemented, not required.
  43. *
  44. * @param input[in] Data to encode.
  45. * @param output[out] Encoded data.
  46. */
  47. virtual Ogre::DataStreamPtr encode(
  48. Ogre::MemoryDataStreamPtr& input, CodecDataPtr& output
  49. ) const final;
  50. /**
  51. * Encodes data to a file.
  52. *
  53. * Unimplemented, not required.
  54. *
  55. * @param input[in] Data to encode.
  56. * @param output[in] Nome for the file with the encoded data.
  57. * @param extra[in] Extra information for the encoder.
  58. */
  59. virtual void encodeToFile(
  60. Ogre::MemoryDataStreamPtr& input, const Ogre::String& output,
  61. CodecDataPtr& extra
  62. ) const final;
  63. /**
  64. * Decodes data.
  65. *
  66. * @param input[in] Data to encode.
  67. * @return Decoded data.
  68. */
  69. Ogre::Codec::DecodeResult decode(Ogre::DataStreamPtr& input) const;
  70. /**
  71. * Maps a magic number header to a file extension.
  72. *
  73. * @param magic_number[in] Pointer to a stream of bytes which
  74. * should identify the file. Note that this may be more than
  75. * needed - each codec may be looking for a different size magic
  76. * number.
  77. * @param max_bytes[in] The number of bytes passed.
  78. * @return A blank string if the magic number was unknown, or a
  79. * file extension.
  80. */
  81. virtual Ogre::String magicNumberToFileExt(
  82. const char *magic_number, size_t max_bytes
  83. ) const;
  84. /**
  85. * The codec type name.
  86. */
  87. static Ogre::String TYPE_NAME;
  88. /**
  89. * Perform the plugin initial installation sequence.
  90. *
  91. * An implementation must be supplied for this method. It must
  92. * perform the startup tasks necessary to install any rende rsystem
  93. * customizations or anything else that is not dependent on system
  94. * initialization, ie only dependent on the core of Ogre. It must
  95. * not perform any operations that would create
  96. * rendersystem-specific objects at this stage, that should be done
  97. * in {@see initialise()}.
  98. */
  99. static void install();
  100. /**
  101. * Perform any tasks the plugin needs to perform initialization.
  102. *
  103. * An implementation must be supplied for this method. It is called
  104. * just after the system is fully initialised (either after
  105. * Root::initialise if a window is created then, or after the first
  106. * window is created) and therefore all rendersystem functionality
  107. * is available at this time. You can use this hook to create any
  108. * resources which are dependent on a rendersystem or have
  109. * rendersystem-specific implementations.
  110. */
  111. static void initialise();
  112. /**
  113. * Perform any tasks the needed when the system is shut down.
  114. *
  115. * An implementation must be supplied for this method. This method
  116. * is called just before key parts of the system are unloaded, such
  117. * as rendersystems being shut down. This hook should be used to
  118. * free up resources and decouple custom objects from the OGRE
  119. * system, whilst all the instances of other plugins (e.g.
  120. * rendersystems) still exist.
  121. */
  122. static void shutdown();
  123. /**
  124. * Perform the final plugin uninstallation sequence.
  125. *
  126. * An implementation must be supplied for this method. It must
  127. * perform the cleanup tasks which haven't already been performed
  128. * in shutdown() (e.g. final deletion of custom instances,if they
  129. * are kept around in case the system was reinitialised). At this
  130. * stage it can't be guaranteed what other plugins are still loaded
  131. * or active. It must therefore not perform any operations that
  132. * would reference any rendersystem-specific objects - those should
  133. * have been sorted out in the 'shutdown' method.
  134. */
  135. static void uninstall();
  136. private:
  137. /**
  138. * The text codec.
  139. */
  140. static TexCodec *tex_codec_;
  141. };
  142. }