Surface.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 <Ogre.h>
  17. /**
  18. * A surface description.
  19. *
  20. * A surface is a plane of pixels. Each pixels doesn't have it's own
  21. * coordinates, but are sequentially added and their coordinates can be
  22. * calculated knowing the surface width.
  23. */
  24. struct Surface{
  25. /**
  26. * Initializator.
  27. *
  28. * Initializes an empty surface.
  29. */
  30. Surface();
  31. /**
  32. * Initializator.
  33. *
  34. * It copies another surface.
  35. */
  36. Surface(const Surface &copy);
  37. /**
  38. * Assignment operation.
  39. *
  40. * It copies another surface.
  41. */
  42. Surface& operator =(const Surface &copy);
  43. /**
  44. * Destructor.
  45. */
  46. ~Surface();
  47. /**
  48. * The list of pixels in the surface.
  49. */
  50. std::vector<unsigned char> pixels;
  51. /**
  52. * The surface width.
  53. */
  54. int width;
  55. /**
  56. * The surface height.
  57. */
  58. int height;
  59. };
  60. /**
  61. * Creates an empty surface
  62. *
  63. * @param width[in] The width for the new surface.
  64. * @param height[in] The height for the new surface.
  65. */
  66. Surface* CreateSurface(const int width, const int height);
  67. /**
  68. * Copies one surface into another.
  69. *
  70. * It can copy just sections of surfaces, but always from the top left corner.
  71. *
  72. * @param dest[out] The target surface.
  73. * @param x_d[in] Number of columns to copy.
  74. * @param y_d[in] Number of rows to copy.
  75. * @param src[in] The source surface.
  76. *
  77. */
  78. void CopyToSurface(Surface* dest, const int x_d, const int y_d, Surface* src);
  79. /**
  80. * Creates a partial surface from a surface.
  81. *
  82. * @param x[in] Starting column to copy from the original surface.
  83. * @param y[in] Starting row to copy from the original surface.
  84. * @param width[in] Number of columns to copy.
  85. * @param height[in] Number of rows to copy.
  86. * @param surface[in] The original surface.
  87. * @return the resulting subsurface.
  88. */
  89. Surface* CreateSubSurface(
  90. const int x, const int y, const int width, const int height, Surface* surface
  91. );
  92. /**
  93. * Creates a surface from a list of pixels.
  94. *
  95. * @param width[in] The width of the surface.
  96. * @param height[in] The height of the surface.
  97. * @param pixels[in] The list of pixels for the new surface. If there are not
  98. * enough pixels to cover the entire surface, the rest of pixels will be NULL.
  99. * @return The new surface.
  100. */
  101. Surface* CreateSurfaceFrom(
  102. const int width, const int height, unsigned char* pixels
  103. );