29 Sprite(
const unsigned char* bytes,
size_t width,
size_t height);
30 explicit Sprite(
const std::string& filename, LoadType loadType = LoadType::NORMAL);
32 void draw()
const override;
51 [[deprecated(
"Scale the modelview matrix instead using jngl::Mat3::scale")]]
56 [[deprecated(
"Use new drawClipped(Vec2, Vec2) method instead")]]
void
57 drawClipped(
float xstart,
float xend,
float ystart,
float yend)
const;
65 void setBytes(
const unsigned char*);
75 void loadTexture(
int scaledWidth,
int scaledHeight,
const std::string& filename,
bool halfLoad,
76 unsigned int format,
const unsigned char*
const* rowPointers,
77 const unsigned char* data =
nullptr);
80 unsigned int dataOffset;
81 unsigned int headerSize;
84 unsigned short planes;
86 unsigned int compression;
87 unsigned int dataSize;
100 void draw(
const std::string& filename,
double x,
double y);
102 template <
class Vect>
void draw(
const std::string& filename, Vect pos) {
103 draw(filename, pos.x, pos.y);
115 void drawClipped(
const std::string& filename,
double xposition,
double yposition,
float xstart,
116 float xend,
float ystart,
float yend);
118 void setSpriteColor(
unsigned char red,
unsigned char green,
unsigned char blue,
119 unsigned char alpha);
121 void setSpriteColor(
unsigned char red,
unsigned char green,
unsigned char blue);
123 void setSpriteColor(
Color);
125 void setSpriteAlpha(
unsigned char alpha);
127 void pushSpriteAlpha(
unsigned char alpha = 255);
129 void popSpriteAlpha();
135 #if __cplusplus >= 201703L
Contains jngl::Color class.
Contains jngl::Drawable class.
Contains jngl::ShaderProgram class.
Contains jngl::Vec2 class.
Object representing a RGB color.
Base class for drawable objects with a position and a rectangle size.
Helper class which calls a function when being destroyed.
Linked vertex and fragment shaders.
Fragment or vertex GLSL shader.
Higher-level representation of an image.
void drawClipped(Vec2 start, Vec2 end) const
Draw a cutout of the sprite. drawClipped({0, 0}, {1, 1}) would draw it normally.
void draw() const override
Called when drawing a frame.
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.
static const Shader & vertexShader()
Returns a reference to JNGL's default vertex shader used to draw textures.
void step() override
Advance object's state.
void draw(Mat3 modelview, const ShaderProgram *=nullptr) const
Draws the image centered using modelview.
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.
Finally load(const std::string &filename)
Starts a thread to load filename and returns a Finally which will join it.