From 58714c1bc289eb536f5a2403c5212f9970ac941d Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Mon, 8 Nov 2021 20:24:30 +0100 Subject: [PATCH] Fix #1345 --- Backends/Kinc-HL/KoreC/texture.cpp | 20 +++++++++++++++++++- Backends/Kinc-HL/kha/Image.hx | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Backends/Kinc-HL/KoreC/texture.cpp b/Backends/Kinc-HL/KoreC/texture.cpp index 8da624fe3..1ddf7396b 100644 --- a/Backends/Kinc-HL/KoreC/texture.cpp +++ b/Backends/Kinc-HL/KoreC/texture.cpp @@ -2,8 +2,26 @@ #include #include +static Kore::Graphics4::Image::Format convertImageFormat(int format) { + switch (format) { + default: + case 0: + return Kore::Graphics4::Image::Format::RGBA32; + case 1: + return Kore::Graphics4::Image::Format::Grey8; + case 2: + return Kore::Graphics4::Image::Format::RGBA128; + case 4: + return Kore::Graphics4::Image::Format::RGBA64; + case 5: + return Kore::Graphics4::Image::Format::A32; + case 6: + return Kore::Graphics4::Image::Format::A16; + } +} + extern "C" vbyte *hl_kore_texture_create(int width, int height, int format, bool readable) { - return (vbyte*)new Kore::Graphics4::Texture(width, height, (Kore::Graphics4::Image::Format)format, readable); + return (vbyte*)new Kore::Graphics4::Texture(width, height, convertImageFormat(format), readable); } extern "C" vbyte *hl_kore_texture_create_from_file(vbyte *filename, bool readable) { diff --git a/Backends/Kinc-HL/kha/Image.hx b/Backends/Kinc-HL/kha/Image.hx index 29d8bf831..11286dc5f 100644 --- a/Backends/Kinc-HL/kha/Image.hx +++ b/Backends/Kinc-HL/kha/Image.hx @@ -150,7 +150,7 @@ class Image implements Canvas implements Resource { image.initRenderTarget(width, height, getDepthBufferBits(depthStencil), getRenderTargetFormat(format), getStencilBufferBits(depthStencil), contextId); else - image.init(width, height, format == TextureFormat.RGBA32 ? 0 : 1); + image.init(width, height, format); return image; }