linting docstring line lengths
This commit is contained in:
parent
a9665c7e37
commit
0aafdb1ff0
|
@ -20,23 +20,23 @@
|
|||
namespace sb
|
||||
{
|
||||
/*!
|
||||
* A Sprite is a wrapper around an sb::Plane object that resets and stores scale, translation, and rotation matrices every time they are set
|
||||
* and combines them automatically when getting the full transformation. This allows those transformations to be set repeatedly without having
|
||||
* to call sb::Plane::untransform() after each set. In the case of translation, there is also a move function that allows the translation to be
|
||||
* modified without resetting, so the sprite can move relative amounts.
|
||||
* A Sprite is a wrapper around an sb::Plane object that resets and stores scale, translation, and rotation matrices every time
|
||||
* they are set and combines them automatically to get the full transformation. This allows those transformations to be set
|
||||
* repeatedly without having to call sb::Plane::untransform() after each set. In the case of translation, there is also a move
|
||||
* function that allows the translation to be modified without resetting, so the sprite can move relative amounts.
|
||||
*/
|
||||
class Sprite
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
/* The plane is a class member rather than the class's inherited type, allowing the user to define a custom plane. When the sprite is copied,
|
||||
* the plane is copied with its references to GPU memory preserved. */
|
||||
/* The plane is a class member rather than the class's inherited type, allowing the user to define a custom plane. When the
|
||||
* sprite is copied, the plane is copied with its references to GPU memory preserved. */
|
||||
sb::Plane plane;
|
||||
|
||||
/* Keep a copy of the matrix transformations generated when the user applies a transformation, so that each can be reapplied
|
||||
* without having to set all the transformations every time one is changed. When the sprite is copied, the transformation values are
|
||||
* copied to the new object, so the new sprite can alter the transformations independently. */
|
||||
* without having to set all the transformations every time one is changed. When the sprite is copied, the transformation
|
||||
* values are copied to the new object, so the new sprite can alter the transformations independently. */
|
||||
glm::mat4 _scale {1.0f}, _translation {1.0f}, _rotation {1.0f};
|
||||
|
||||
/* A sprite by definition has only one texture per draw, so keep an index to the currently active texture. */
|
||||
|
@ -55,8 +55,8 @@ namespace sb
|
|||
sb::Animation frames;
|
||||
|
||||
/*!
|
||||
* Construct an instance of Sprite using an existing plane object. The plane will be copied into the Sprite, so further edits must
|
||||
* be made using the Sprite class.
|
||||
* Construct an instance of Sprite using an existing plane object. The plane will be copied into the Sprite, so further edits
|
||||
* must be made using the Sprite class.
|
||||
*
|
||||
* @param plane flat model of the sprite
|
||||
*/
|
||||
|
@ -73,8 +73,8 @@ namespace sb
|
|||
}
|
||||
|
||||
/*!
|
||||
* Construct a Sprite with a default constructed sb::Plane and attach a list of textures to the plane. Each texture is a frame of the
|
||||
* sprite's animation. The texture is the 2D graphic drawn at the sprite's location.
|
||||
* Construct a Sprite with a default constructed sb::Plane and attach a list of textures to the plane. Each texture is a
|
||||
* frame of the sprite's animation. The texture is the 2D graphic drawn at the sprite's location.
|
||||
*
|
||||
* @param textures list of textures
|
||||
* @param scale amount to scale
|
||||
|
@ -88,8 +88,8 @@ namespace sb
|
|||
}
|
||||
|
||||
/*!
|
||||
* Construct a Sprite with a default constructed sb::Plane and give the plane a texture. The texture is the 2D graphic drawn at the
|
||||
* sprite's location.
|
||||
* Construct a Sprite with a default constructed sb::Plane and give the plane a texture. The texture is the 2D graphic drawn
|
||||
* at the sprite's location.
|
||||
*
|
||||
* @param texture sprite's 2D graphic
|
||||
* @param scale amount to scale
|
||||
|
@ -108,7 +108,8 @@ namespace sb
|
|||
* @param scale Amount to scale
|
||||
* @param filter Resize filter to use when rendering textures
|
||||
*/
|
||||
Sprite(std::initializer_list<fs::path> paths, glm::vec2 scale = glm::vec2{1.0f}, std::optional<GLint> filter = std::nullopt) : Sprite(scale)
|
||||
Sprite(std::initializer_list<fs::path> paths, glm::vec2 scale = glm::vec2{1.0f},
|
||||
std::optional<GLint> filter = std::nullopt) : Sprite(scale)
|
||||
{
|
||||
for (const fs::path& path : paths)
|
||||
{
|
||||
|
@ -125,7 +126,8 @@ namespace sb
|
|||
* @param scale Amount to scale
|
||||
* @param filter Resize filter to use when rendering textures
|
||||
*/
|
||||
Sprite(const fs::path& path, glm::vec2 scale = glm::vec2{1.0f}, std::optional<GLint> filter = std::nullopt) : Sprite({path}, scale, filter) {};
|
||||
Sprite(const fs::path& path, glm::vec2 scale = glm::vec2{1.0f}, std::optional<GLint> filter = std::nullopt) :
|
||||
Sprite({path}, scale, filter) {};
|
||||
|
||||
/*!
|
||||
* Add a previously constructed sb::Texture to the sprite's plane object.
|
||||
|
@ -197,7 +199,8 @@ namespace sb
|
|||
}
|
||||
|
||||
/*!
|
||||
* Increment the texture index the given number of times. Defaults to 1. It will wrap around at the end. Negative increment can be used.
|
||||
* Increment the texture index the given number of times. Defaults to 1. It will wrap around at the end. Negative increment
|
||||
* can be used.
|
||||
*
|
||||
* @param increment amount to increment the texture index
|
||||
*/
|
||||
|
@ -217,8 +220,8 @@ namespace sb
|
|||
}
|
||||
|
||||
/*!
|
||||
* Add all attributes to the given vertex buffer object. The buffer object should have been previously allocated to at least the
|
||||
* size of this sprite by passing Sprite::size() to VBO::allocate(GLsizeiptr, GLenum).
|
||||
* Add all attributes to the given vertex buffer object. The buffer object should have been previously allocated to at least
|
||||
* the size of this sprite by passing Sprite::size() to VBO::allocate(GLsizeiptr, GLenum).
|
||||
*
|
||||
* The VBO must currently be bound.
|
||||
*
|
||||
|
@ -230,8 +233,9 @@ namespace sb
|
|||
}
|
||||
|
||||
/*!
|
||||
* Bind all of this sprite's attributes and its active texture by calling each of their bind methods. Textures and attributes all must already
|
||||
* have GL indices set, for example by calling Texture::generate() and Attributes::index(GLint) on each.
|
||||
* Bind all of this sprite's attributes and its active texture by calling each of their bind methods. Textures and
|
||||
* attributes all must already have GL indices set, for example by calling Texture::generate() and
|
||||
* Attributes::index(GLint) on each.
|
||||
*/
|
||||
void bind()
|
||||
{
|
||||
|
@ -244,7 +248,8 @@ namespace sb
|
|||
* object is fully exposed, meaning it can be edited, and both its const and non-const methods can be used.
|
||||
*
|
||||
* @param name name of the attributes, see Model::attributes(const sb::Attributes&, const std::string&)
|
||||
* @return const reference to a shared pointer held by the plane object that points to the attributes with the given name
|
||||
* @return const reference to a shared pointer held by the plane object that points to the attributes with the given
|
||||
* name
|
||||
*/
|
||||
const std::shared_ptr<sb::Attributes>& attributes(const std::string name) const
|
||||
{
|
||||
|
@ -335,8 +340,8 @@ namespace sb
|
|||
* optional arbitrary transformation, apply the given view and projection transformations, and pass the transformation to the
|
||||
* shader at the given transformation uniform. The uniform is not checked for existence, so it must be present in the shader.
|
||||
*
|
||||
* Then enable the plane's attributes, and draw the amount of vertices in the plane's position attributes using `glDrawArrays`.
|
||||
* Disable the plane's attributes after the draw.
|
||||
* Then enable the plane's attributes, and draw the amount of vertices in the plane's position attributes using
|
||||
* `glDrawArrays`. Disable the plane's attributes after the draw.
|
||||
*
|
||||
* The optional texture flag uniform can be passed to automatically set that uniform to true if there are textures attached to
|
||||
* this sprite, and false if not. The currently bound shader should be written to use that flag. For example, it could use the
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* ✨ +------------------------------------------------------+
|
||||
____/ \____ ✨/| Open source game framework licensed to freely use, |
|
||||
✨\ / / | copy, and modify. Created for 🌠dank.game🌠 |
|
||||
+--\ . . /--+ | |
|
||||
| ~/ ︶ \👍| | 🌐 https://open.shampoo.ooo/shampoo/spacebox |
|
||||
| ~~~🌊~~~~🌊~ | +------------------------------------------------------+
|
||||
| SPACE 🪐🅱 OX | /
|
||||
| 🌊 ~ ~~~~ ~~ |/
|
||||
/* +------------------------------------------------------+
|
||||
____/ \____ /| - Open source game framework licensed to freely use, |
|
||||
\ / / | copy, modify and sell without restriction |
|
||||
+--\ ^__^ /--+ | |
|
||||
| ~/ \~ | | - created for <https://foam.shampoo.ooo> |
|
||||
| ~~~~~~~~~~~~ | +------------------------------------------------------+
|
||||
| SPACE ~~~~~ | /
|
||||
| ~~~~~~~ BOX |/
|
||||
+-------------*/
|
||||
|
||||
#include "Texture.hpp"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* +------------------------------------------------------+
|
||||
____/ \____ /| - Open source game framework licensed to freely use, |
|
||||
\ / / | copy, modify and sell without restriction |
|
||||
+--\ ^__^ /--+ | |
|
||||
| ~/ \~ | | - created for <https://foam.shampoo.ooo> |
|
||||
| ~~~~~~~~~~~~ | +------------------------------------------------------+
|
||||
/* +-------------------------------------------------------+
|
||||
____/ \____ /| Open source game framework licensed to freely use, |
|
||||
\ / / | copy, and modify, created for dank.game |
|
||||
+--\ ^__^ /--+ | |
|
||||
| ~/ \~ | | Download at https://open.shampoo.ooo/shampoo/spacebox |
|
||||
| ~~~~~~~~~~~~ | +-------------------------------------------------------+
|
||||
| SPACE ~~~~~ | /
|
||||
| ~~~~~~~ BOX |/
|
||||
+-------------*/
|
||||
|
@ -27,8 +27,8 @@ namespace sb
|
|||
{
|
||||
|
||||
/*!
|
||||
* The Texture class abstracts the image file opening, data loading and binding steps of Open GL texture creation. Currently it supports only
|
||||
* the GL_TEXTURE_2D target with one mipmap level. Support for other types of textures may be added in the future.
|
||||
* The Texture class abstracts the image file opening, data loading and binding steps of Open GL texture creation. Currently it
|
||||
* supports only the GL_TEXTURE_2D target with one mipmap level. Support for other types of textures may be added in the future.
|
||||
*
|
||||
* The texture object's ID can be used to pass this texture directly to OpenGL functions.
|
||||
*/
|
||||
|
@ -44,8 +44,8 @@ namespace sb
|
|||
std::optional<glm::vec2> _size;
|
||||
std::optional<GLenum> _format;
|
||||
|
||||
/* The filter will be applied using glTexParameter whenever Texture::generate(glm::vec2, GLenum, std::optional<GLint>) is called without a filter
|
||||
* specified. */
|
||||
/* The filter will be applied using glTexParameter whenever Texture::generate(glm::vec2, GLenum, std::optional<GLint>) is
|
||||
* called without a filter specified. */
|
||||
GLint _filter = GL_NEAREST;
|
||||
|
||||
public:
|
||||
|
@ -71,8 +71,8 @@ namespace sb
|
|||
void associate(fs::path path);
|
||||
|
||||
/*!
|
||||
* Set the resize filter of the texture. This must be set before Texture::generate(glm::vec2, GLenum, std::optional<GLint>) is called for it
|
||||
* to be applied.
|
||||
* Set the resize filter of the texture. This must be set before Texture::generate(glm::vec2, GLenum, std::optional<GLint>)
|
||||
* is called for it to be applied.
|
||||
*
|
||||
* @param value Resize filter to use (see `glTexParameter` for options)
|
||||
*/
|
||||
|
@ -102,8 +102,8 @@ namespace sb
|
|||
void load();
|
||||
|
||||
/*!
|
||||
* Load a texture from a path to an image file. This will create an SDL Surface from the image file at a given path and forward it
|
||||
* to the load overload which accepts a surface pointer.
|
||||
* Load a texture from a path to an image file. This will create an SDL Surface from the image file at a given path and
|
||||
* forward it to the load overload which accepts a surface pointer.
|
||||
*
|
||||
* Unless the texture has already been generated, the texture will be generated with storage for the size of the image.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue