| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #pragma once
- #include "TextureLayoutRectangle.h"
- #include "TextureLayoutTexture.h"
- namespace Rml {
- /**
- A texture layout generates and stores a layout of rectangles within a series of textures. It is
- used primarily by the font system for generating font textures.
- */
- class TextureLayout {
- public:
- TextureLayout();
- ~TextureLayout();
- /// Adds a rectangle to the list of rectangles to be laid out. All rectangles must be added to
- /// the layout before the layout is generated.
- /// @param[in] id The id of the rectangle; used to identify the rectangle after it has been positioned.
- /// @param[in] dimensions The dimensions of the rectangle.
- void AddRectangle(int id, Vector2i dimensions);
- /// Returns one of the layout's rectangles.
- /// @param[in] index The index of the desired rectangle.
- /// @return The desired rectangle.
- TextureLayoutRectangle& GetRectangle(int index);
- /// Returns the number of rectangles in the layout.
- /// @return The layout's rectangle count.
- int GetNumRectangles() const;
- /// Returns one of the layout's textures.
- /// @param[in] index The index of the desired texture.
- /// @return The desired texture.
- TextureLayoutTexture& GetTexture(int index);
- /// Returns the number of textures in the layout.
- /// @return The layout's texture count.
- int GetNumTextures() const;
- /// Attempts to generate an efficient texture layout for the rectangles.
- /// @param[in] max_texture_dimensions The maximum dimensions allowed for any single texture.
- /// @return True if the layout was generated successfully, false if not.
- bool GenerateLayout(int max_texture_dimensions);
- private:
- using RectangleList = Vector<TextureLayoutRectangle>;
- using TextureList = Vector<TextureLayoutTexture>;
- TextureList textures;
- RectangleList rectangles;
- };
- } // namespace Rml
|