Skip to content

Commit

Permalink
Fix Kode#1345
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous authored and sh-dave committed Jan 13, 2022
1 parent 9e50bb3 commit 58714c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Backends/Kinc-HL/KoreC/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@
#include <Kore/Video.h>
#include <hl.h>

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) {
Expand Down
2 changes: 1 addition & 1 deletion Backends/Kinc-HL/kha/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 58714c1

Please sign in to comment.