@@ -30,13 +30,15 @@ import dev.deftu.omnicore.api.client.render.OmniTextureUnit
3030import dev.deftu.omnicore.api.paddedMinecraftVersion
3131import dev.deftu.omnicore.internal.client.textures.TextureInternals
3232import org.apache.logging.log4j.LogManager
33+ import org.lwjgl.nanovg.NanoVG
3334import org.lwjgl.opengl.GL11
3435import org.lwjgl.opengl.GL20
3536import org.lwjgl.opengl.GL30
3637import org.polyfrost.oneconfig.api.platform.v1.Platform
3738import org.polyfrost.oneconfig.api.ui.v1.api.NanoSvgApi
3839import org.polyfrost.oneconfig.api.ui.v1.api.NanoVgApi
3940import org.polyfrost.oneconfig.api.ui.v1.api.StbApi
41+ import org.polyfrost.oneconfig.api.ui.v1.image.NVGImageFlags
4042import org.polyfrost.polyui.PolyUI
4143import org.polyfrost.polyui.color.PolyColor
4244import org.polyfrost.polyui.data.Font
@@ -437,8 +439,10 @@ class NVGRendererImpl(
437439 image.loadAsync(errorHandler) {
438440 queue.add { loadSvg(image, it.toDirectByteBufferNT()) }
439441 }
442+
440443 return defaultImage
441444 }
445+
442446 map.getOrPut(width.hashCode() * 31 + height.hashCode()) { resizeSvg(svg, width, height) }
443447 }
444448
@@ -447,6 +451,7 @@ class NVGRendererImpl(
447451 image.loadAsync(errorHandler) {
448452 queue.add { images[image] = loadImage(image, it.toDirectByteBuffer()) }
449453 }
454+
450455 defaultImage
451456 }
452457 }
@@ -478,7 +483,7 @@ class NVGRendererImpl(
478483 val h = IntArray (1 )
479484 val d = stb.image_load_from_memory(data, w, h, IntArray (1 ), 4 ) ? : throw IllegalStateException (" Failed to load image ${image.resourcePath} : ${stb.image_failure_reason()} " )
480485 if (! image.size.isPositive) PolyImage .setImageSize(image, Vec2 (w[0 ].toFloat(), h[0 ].toFloat()))
481- return vg.createImage(w[0 ].toFloat(), h[0 ].toFloat(), d, 0 )
486+ return vg.createImage(w[0 ].toFloat(), h[0 ].toFloat(), d, image[ NVGImageFlags . KEY ] ? : NVGImageFlags . NONE )
482487 }
483488
484489 private fun loadSvg (image : PolyImage , data : ByteBuffer ): Int {
@@ -487,6 +492,7 @@ class NVGRendererImpl(
487492 if (! image.size.isPositive) PolyImage .setImageSize(image, Vec2 (svg.width, svg.height).also {
488493 if (! it.isPositive) throw IllegalArgumentException (" SVG ${image.resourcePath} has invalid size ($it ), maybe it is missing/corrupted?" )
489494 })
495+
490496 val o = resizeSvg(svg, svg.width, svg.height)
491497 map[image.size.hashCode()] = o
492498 svgs[image] = svg to map
0 commit comments