#import "Simp";
Procedures#
Images#
Mipmaps#
Image codecs#
Reads an image file into bitmap. Returns false when the file is missing or is not an image.
Like bitmap_load, for an image that is already in memory.
Writes bitmap to an image file. Returns false for any other extension, for a bitmap that is not RGB8 or RGBA8, or when the write fails.
Loaded fonts#
Dynamic fonts#
Sizes are in drawing units. With pixel_scale above 1 (a Retina window) the glyphs are rasterized
at pixel_height * pixel_scale device pixels and drawn at 1/pixel_scale, so text stays sharp.
Loads a font file at one size. Returns null when the file cannot be read.
The width in pixels of the one UTF-8 character at utf8. A byte sequence that is not valid counts as the font's unknown character.
Lays text out and returns its width in pixels. draw_prepared_text then draws it.
Starts a new run of prepared text, dropping what an earlier run gathered, glyphs and quads alike.
#import "Simp";
#import "File";
draw_label :: (font: *Dynamic_Font) {
begin_prepare_text(font);
append_prepare_text(font, "Score: ");
append_prepare_text(font, "42");
end_prepare_text(font);
// The quads are laid out from the origin, one per glyph, left to right.
last := font.current_quads[font.current_quads.count - 1];
width := last.lr.x;
draw_prepared_text(font, 20, 40, .{ 1, 1, 0, 1 });
}This one is only checked to compile, not run.
Adds the glyphs of s to the run; byte offsets count from the start of this piece.
Closes the run and lays its glyphs out as font.current_quads, with the pen at the origin and the baseline at y = 0, so the
quads can be inspected. draw_prepared_text draws the same run at a position of its choosing.
GL textures#
Uploads bitmap to the graphics card as texture. Returns false when that fails.
Reads an image file and uploads it as map. Returns false when it cannot read or decode the file.
Like texture_load_from_file, for an image that is already in memory.
Chooses between smooth (.LINEAR, the default) and hard-edged (.NEAREST, for pixel art) sampling.
Makes an empty texture that can be drawn into: make it current with set_render_target, then draw as usual.
GL shaders#
GL renderer#
Chooses where drawing goes, and what the coordinates mean. Anything drawn so far is flushed first.
The size of the window's framebuffer in device pixels.
Device pixels per window coordinate unit (2 on a Retina display).
Shows what was drawn to window. Anything still batched is drawn first.
Fills the current render target with one colour, and clears its depth and stencil.
Limits drawing to a box, in the coordinates of the current render target.
Lifts the limit set by set_scissor.
Adds one corner to the batch. Every three corners make a triangle, and the batch is drawn when it fills or when something forces a flush.
Draws the following triangles in plain colours, with no texture.
Draws the following triangles with texture, scaled by their colours.
Draws text in one line and returns its width in pixels.
Draws the text last given to prepare_text, so a text drawn many times is laid out once.
Immediate geometry#
GL pixel read#
Starts copying the pixels of source back to the CPU without waiting for them. Poll with pixel_read_is_done, then collect them with pixel_read_end.
Types#
How a texture is sampled when drawn larger or smaller than its size.
Per-context Simp settings, read as context.simp.
One glyph of prepared text: where it goes, the part of the glyph atlas it shows and its tint.