31 Sprite(
const unsigned char* bytes,
size_t width,
size_t height);
40 void draw()
const override;
85 operator
bool() const;
120 drawClipped(
float xstart,
float xend,
float ystart,
float yend) const;
133 void setBytes(const
unsigned char*);
142 static
void cleanUpRowPointers(
std::vector<
unsigned char*>& buf);
143 void loadTexture(
int scaledWidth,
int scaledHeight, const
std::
string& filename,
bool halfLoad,
144 unsigned int format, const
unsigned char* const* rowPointers,
145 const
unsigned char* data =
nullptr);
146 Finally LoadPNG(const
std::
string& filename, FILE* fp,
bool halfLoad);
148 unsigned int dataOffset;
149 unsigned int headerSize;
152 unsigned short planes;
154 unsigned int compression;
155 unsigned int dataSize;
167template <
class Vect>
void draw(
const std::string& filename, Vect pos) {
168 draw(filename, pos.x, pos.y);
181 float xend,
float ystart,
float yend);
183void setSpriteColor(
unsigned char red,
unsigned char green,
unsigned char blue,
184 unsigned char alpha);
186void setSpriteColor(
unsigned char red,
unsigned char green,
unsigned char blue);
191void setSpriteAlpha(
unsigned char alpha);
193void pushSpriteAlpha(
unsigned char alpha = 255);
195void popSpriteAlpha();
201#if __cplusplus >= 201703L
Contains jngl::Drawable class.
Contains jngl::Rgb class.
Contains jngl::ShaderProgram class.
Contains jngl::Vec2 class.
Base class for drawable objects with a position and a rectangle size.
float getWidth() const
Returns the width in screen coordinates.
float getHeight() const
Returns the height in screen coordinates.
Helper class which calls a function when being destroyed.
Containing the pixel data of an image file.
Object representing a RGB color, new version of jngl::Color (which will be deprecated in the future)
Linked vertex and fragment shaders.
Fragment or vertex GLSL shader.
Use this class to load a Sprite asynchronously.
~Loader() noexcept
Blocks until the Sprite has been loaded.
Loader(std::string filename) noexcept
Starts a thread to load filename and returns instantly.
std::shared_ptr< Sprite > shared() const
Blocks until the Sprite has been loaded and returns a non-nullptr std::shared_ptr.
Higher-level representation of an image.
void draw() const override
Draws the Sprite, centered by default.
void drawScaled(float xfactor, float yfactor, const ShaderProgram *shaderProgram=nullptr) const
Draws the image scaled by xfactor and yfactor
std::shared_ptr< Finally > loader
Function which actually loads the sprite.
void drawClipped(float xstart, float xend, float ystart, float yend) const
void drawMesh(const std::vector< Vertex > &vertexes, const ShaderProgram *=nullptr) const
Draws a list of triangles with the sprite's texture on it using the global modelview from jngl::model...
static const Shader & vertexShader()
Returns a reference to JNGL's default vertex shader used to draw textures.
void step() override
Does nothing.
Sprite(const std::string &filename, LoadType loadType=LoadType::NORMAL)
void scale(double factor)
Multiplies the global ModelView matrix by a scaling matrix.
Finally load(const std::string &filename)
Starts a thread to load filename and returns a Finally which will join it.
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.
Position and texture coordinates.