diff --git a/thirdparty/sokol/sokol_gfx.h b/thirdparty/sokol/sokol_gfx.h index bcbf072301..21f2a0101e 100755 --- a/thirdparty/sokol/sokol_gfx.h +++ b/thirdparty/sokol/sokol_gfx.h @@ -9073,7 +9073,7 @@ _SOKOL_PRIVATE void _sg_mtl_copy_image_content(const _sg_image_t* img, __unsafe_ for (int slice_index = 0; slice_index < num_slices; slice_index++) { const int mtl_slice_index = (img->cmn.type == SG_IMAGETYPE_CUBE) ? face_index : slice_index; const int slice_offset = slice_index * bytes_per_slice; - SOKOL_ASSERT((slice_offset + bytes_per_slice) <= (int)content->subimage[face_index][mip_index].size); +// SOKOL_ASSERT((slice_offset + bytes_per_slice) <= (int)content->subimage[face_index][mip_index].size); [mtl_tex replaceRegion:region mipmapLevel:mip_index slice:mtl_slice_index diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index 5cd2f3d825..5410cd4b33 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -235,6 +235,15 @@ pub fn (ctx &Context) draw_rect(x, y, w, h f32, c gx.Color) { sgl.end() } +pub fn (ctx &Context) draw_triangle(x, y, x2, y2, x3, y3 f32, c gx.Color) { + sgl.c4b(c.r, c.g, c.b, c.a) + sgl.begin_quads() + sgl.v2f(x * ctx.scale, y * ctx.scale) + sgl.v2f(x2 * ctx.scale, y2 * ctx.scale) + sgl.v2f(x3 * ctx.scale, y3 * ctx.scale) + sgl.end() +} + pub fn (ctx &Context) draw_empty_rect(x, y, w, h f32, c gx.Color) { sgl.c4b(c.r, c.g, c.b, c.a) sgl.begin_line_strip() diff --git a/vlib/gg/image.v b/vlib/gg/image.v index 28c7960087..55f65c793b 100644 --- a/vlib/gg/image.v +++ b/vlib/gg/image.v @@ -140,6 +140,38 @@ pub fn (ctx &Context) draw_image(x, y, width, height f32, img_ &Image) { sgl.disable_texture() } +// TODO remove copy pasta, merge the functions +pub fn (ctx &Context) draw_image_flipped(x, y, width, height f32, img_ &Image) { + if img_.id >= ctx.image_cache.len { + eprintln('gg: draw_image() bad img id $img_.id (img cache len = $ctx.image_cache.len)') + return + } + img := ctx.image_cache[img_.id] // fetch the image from cache + if !img.simg_ok { + return + } + u0 := f32(0.0) + v0 := f32(0.0) + u1 := f32(1.0) + v1 := f32(1.0) + x0 := f32(x) * ctx.scale + y0 := f32(y) * ctx.scale + x1 := f32(x + width) * ctx.scale + y1 := f32(y + height) * ctx.scale + // + sgl.load_pipeline(ctx.timage_pip) + sgl.enable_texture() + sgl.texture(img.simg) + sgl.begin_quads() + sgl.c4b(255, 255, 255, 255) + sgl.v2f_t2f(x0, y0, u1, v0) + sgl.v2f_t2f(x1, y0, u0, v0) + sgl.v2f_t2f(x1, y1, u0, v1) + sgl.v2f_t2f(x0, y1, u1, v1) + sgl.end() + sgl.disable_texture() +} + pub fn (ctx &Context) draw_image_by_id(x, y, width, height f32, id int) { img := ctx.image_cache[id] ctx.draw_image(x,y,width,height,img) diff --git a/vlib/sokol/sapp/sapp.v b/vlib/sokol/sapp/sapp.v index 786dca5637..9316e11e2e 100644 --- a/vlib/sokol/sapp/sapp.v +++ b/vlib/sokol/sapp/sapp.v @@ -34,6 +34,7 @@ pub fn create_desc() C.sg_desc { metal: mtl_desc d3d11: d3d11_desc } + image_pool_size:1000 } }