mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
gg: fix cached images loaded from memory
This commit is contained in:
parent
fb9db11a00
commit
576396cf20
2
thirdparty/sokol/sokol_gfx.h
vendored
2
thirdparty/sokol/sokol_gfx.h
vendored
@ -9490,7 +9490,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
|
||||
|
@ -31,9 +31,7 @@ pub fn (mut ctx Context) create_image(file string) Image {
|
||||
if !C.sg_isvalid() {
|
||||
// Sokol is not initialized yet, add stbi object to a queue/cache
|
||||
// ctx.image_queue << file
|
||||
stb_img := stbi.load(file) or {
|
||||
return Image{}
|
||||
}
|
||||
stb_img := stbi.load(file) or { return Image{} }
|
||||
img := Image{
|
||||
width: stb_img.width
|
||||
height: stb_img.height
|
||||
@ -59,9 +57,7 @@ fn create_image(file string) Image {
|
||||
println('gg.create_image(): file not found: $file')
|
||||
return Image{} // none
|
||||
}
|
||||
stb_img := stbi.load(file) or {
|
||||
return Image{}
|
||||
}
|
||||
stb_img := stbi.load(file) or { return Image{} }
|
||||
mut img := Image{
|
||||
width: stb_img.width
|
||||
height: stb_img.height
|
||||
@ -75,10 +71,8 @@ fn create_image(file string) Image {
|
||||
return img
|
||||
}
|
||||
|
||||
pub fn create_image_from_memory(buf byteptr, bufsize int) Image {
|
||||
stb_img := stbi.load_from_memory(buf, bufsize) or {
|
||||
return Image{}
|
||||
}
|
||||
pub fn (mut ctx Context) create_image_from_memory(buf byteptr, bufsize int) Image {
|
||||
stb_img := stbi.load_from_memory(buf, bufsize) or { return Image{} }
|
||||
mut img := Image{
|
||||
width: stb_img.width
|
||||
height: stb_img.height
|
||||
@ -86,12 +80,14 @@ pub fn create_image_from_memory(buf byteptr, bufsize int) Image {
|
||||
ok: stb_img.ok
|
||||
data: stb_img.data
|
||||
ext: stb_img.ext
|
||||
id: ctx.image_cache.len
|
||||
}
|
||||
ctx.image_cache << img
|
||||
return img
|
||||
}
|
||||
|
||||
pub fn create_image_from_byte_array(b []byte) Image {
|
||||
return create_image_from_memory(b.data, b.len)
|
||||
pub fn (mut ctx Context) create_image_from_byte_array(b []byte) Image {
|
||||
return ctx.create_image_from_memory(b.data, b.len)
|
||||
}
|
||||
|
||||
pub fn (mut img Image) init_sokol_image() &Image {
|
||||
|
Loading…
Reference in New Issue
Block a user