Skip to content

Commit

Permalink
Improve the stride-fix for HL
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jul 20, 2023
1 parent f4246d3 commit 4c75fe3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Backends/Kinc-HL/kha/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Image implements Canvas implements Resource {
public var stride(get, never): Int;

function get_stride(): Int {
return kinc_g4_texture_stride(_texture);
return _texture != null ? kinc_texture_get_stride(_texture) : (formatByteSize(myFormat) * width);
}

public function isOpaque(x: Int, y: Int): Bool {
Expand Down Expand Up @@ -410,6 +410,10 @@ class Image implements Canvas implements Resource {
return 0;
}

@:hlNative("std", "kinc_texture_get_stride") static function kinc_texture_get_stride(texture: Pointer): Int {
return 0;
}

@:hlNative("std", "kinc_texture_at") static function kinc_texture_at(texture: Pointer, x: Int, y: Int): Int {
return 0;
}
Expand Down
5 changes: 5 additions & 0 deletions Backends/Kinc-HL/kinc-bridge/texture.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ int hl_kinc_texture_get_real_height(vbyte *texture) {
return tex->tex_height;
}

int hl_kinc_texture_get_stride(vbyte *texture) {
kinc_g4_texture_t *tex = (kinc_g4_texture_t *)texture;
return kinc_g4_texture_stride(tex);
}

int hl_kinc_texture_at(vbyte *texture, int x, int y) {
tex_and_data_t *tex = (tex_and_data_t *)texture;
assert(tex->data != NULL);
Expand Down

0 comments on commit 4c75fe3

Please sign in to comment.