forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
3
Kha/Backends/Kinc-HL/kha/Blob.hx
Normal file
3
Kha/Backends/Kinc-HL/kha/Blob.hx
Normal file
@ -0,0 +1,3 @@
|
||||
package kha;
|
||||
|
||||
typedef Blob = kha.internal.BytesBlob;
|
128
Kha/Backends/Kinc-HL/kha/Display.hx
Normal file
128
Kha/Backends/Kinc-HL/kha/Display.hx
Normal file
@ -0,0 +1,128 @@
|
||||
package kha;
|
||||
|
||||
class Display {
|
||||
static var displays: Array<Display> = null;
|
||||
|
||||
var num: Int;
|
||||
var isPrimary: Bool;
|
||||
|
||||
function new(num: Int, isPrimary: Bool) {
|
||||
this.num = num;
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
public static function init(): Void {
|
||||
if (displays == null) {
|
||||
kinc_display_init();
|
||||
displays = [];
|
||||
for (i in 0...kinc_display_count()) {
|
||||
displays.push(new Display(i, kinc_display_is_primary(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static var primary(get, never): Display;
|
||||
|
||||
static function get_primary(): Display {
|
||||
init();
|
||||
for (display in displays) {
|
||||
if (display.isPrimary) {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static var all(get, never): Array<Display>;
|
||||
|
||||
static function get_all(): Array<Display> {
|
||||
init();
|
||||
return displays;
|
||||
}
|
||||
|
||||
public var available(get, never): Bool;
|
||||
|
||||
function get_available(): Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public var name(get, never): String;
|
||||
|
||||
function get_name(): String {
|
||||
return "Display";
|
||||
}
|
||||
|
||||
public var x(get, never): Int;
|
||||
|
||||
function get_x(): Int {
|
||||
return kinc_display_x(num);
|
||||
}
|
||||
|
||||
public var y(get, never): Int;
|
||||
|
||||
function get_y(): Int {
|
||||
return kinc_display_y(num);
|
||||
}
|
||||
|
||||
public var width(get, never): Int;
|
||||
|
||||
function get_width(): Int {
|
||||
return kinc_display_width(num);
|
||||
}
|
||||
|
||||
public var height(get, never): Int;
|
||||
|
||||
function get_height(): Int {
|
||||
return kinc_display_height(num);
|
||||
}
|
||||
|
||||
public var frequency(get, never): Int;
|
||||
|
||||
function get_frequency(): Int {
|
||||
return 60;
|
||||
}
|
||||
|
||||
public var pixelsPerInch(get, never): Int;
|
||||
|
||||
function get_pixelsPerInch(): Int {
|
||||
return kinc_display_ppi();
|
||||
}
|
||||
|
||||
public var modes(get, never): Array<DisplayMode>;
|
||||
|
||||
function get_modes(): Array<DisplayMode> {
|
||||
return [];
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_init") static function kinc_display_init(): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_count") static function kinc_display_count(): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_width") static function kinc_display_width(index: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_height") static function kinc_display_height(index: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_x") static function kinc_display_x(index: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_y") static function kinc_display_y(index: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_is_primary") static function kinc_display_is_primary(index: Int): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_display_ppi") static function kinc_display_ppi(): Int {
|
||||
return 0;
|
||||
}
|
||||
}
|
3
Kha/Backends/Kinc-HL/kha/Font.hx
Normal file
3
Kha/Backends/Kinc-HL/kha/Font.hx
Normal file
@ -0,0 +1,3 @@
|
||||
package kha;
|
||||
|
||||
typedef Font = kha.Kravur;
|
463
Kha/Backends/Kinc-HL/kha/Image.hx
Normal file
463
Kha/Backends/Kinc-HL/kha/Image.hx
Normal file
@ -0,0 +1,463 @@
|
||||
package kha;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.BytesData;
|
||||
import kha.korehl.graphics4.TextureUnit;
|
||||
import kha.graphics4.TextureFormat;
|
||||
import kha.graphics4.DepthStencilFormat;
|
||||
import kha.graphics4.Usage;
|
||||
|
||||
class Image implements Canvas implements Resource {
|
||||
public var _texture: Pointer;
|
||||
public var _renderTarget: Pointer;
|
||||
public var _textureArray: Pointer;
|
||||
public var _textureArrayTextures: Pointer;
|
||||
|
||||
var myFormat: TextureFormat;
|
||||
var readable: Bool;
|
||||
|
||||
var graphics1: kha.graphics1.Graphics;
|
||||
var graphics2: kha.graphics2.Graphics;
|
||||
var graphics4: kha.graphics4.Graphics;
|
||||
|
||||
public static function fromVideo(video: Video): Image {
|
||||
var image = new Image(false);
|
||||
image.myFormat = TextureFormat.RGBA32;
|
||||
image.initVideo(cast(video, kha.korehl.Video));
|
||||
return image;
|
||||
}
|
||||
|
||||
public static function create(width: Int, height: Int, format: TextureFormat = null, usage: Usage = null, readable: Bool = false): Image {
|
||||
return create2(width, height, format == null ? TextureFormat.RGBA32 : format, readable, false, NoDepthAndStencil);
|
||||
}
|
||||
|
||||
public static function create3D(width: Int, height: Int, depth: Int, format: TextureFormat = null, usage: Usage = null, readable: Bool = false): Image {
|
||||
return create3(width, height, depth, format == null ? TextureFormat.RGBA32 : format, readable, 0);
|
||||
}
|
||||
|
||||
public static function createRenderTarget(width: Int, height: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = NoDepthAndStencil,
|
||||
antiAliasingSamples: Int = 1): Image {
|
||||
return create2(width, height, format == null ? TextureFormat.RGBA32 : format, false, true, depthStencil);
|
||||
}
|
||||
|
||||
// public static function createArray(images: Array<Image>, format: TextureFormat = null): Image {
|
||||
// var image = new Image(false);
|
||||
// image.myFormat = (format == null) ? TextureFormat.RGBA32 : format;
|
||||
// initArrayTexture(image, images);
|
||||
// return image;
|
||||
// }
|
||||
|
||||
public static function fromBytes(bytes: Bytes, width: Int, height: Int, format: TextureFormat = null, usage: Usage = null, readable: Bool = false): Image {
|
||||
var image = new Image(readable);
|
||||
image.myFormat = format;
|
||||
image.initFromBytes(bytes.getData(), width, height, getTextureFormat(format));
|
||||
return image;
|
||||
}
|
||||
|
||||
function initFromBytes(bytes: BytesData, width: Int, height: Int, format: Int): Void {
|
||||
_texture = kinc_texture_from_bytes(bytes.bytes, width, height, format, readable);
|
||||
}
|
||||
|
||||
public static function fromBytes3D(bytes: Bytes, width: Int, height: Int, depth: Int, format: TextureFormat = null, usage: Usage = null,
|
||||
readable: Bool = false): Image {
|
||||
var image = new Image(readable);
|
||||
image.myFormat = format;
|
||||
image.initFromBytes3D(bytes.getData(), width, height, depth, getTextureFormat(format));
|
||||
return image;
|
||||
}
|
||||
|
||||
function initFromBytes3D(bytes: BytesData, width: Int, height: Int, depth: Int, format: Int): Void {
|
||||
_texture = kinc_texture_from_bytes3d(bytes.bytes, width, height, depth, format, readable);
|
||||
}
|
||||
|
||||
public static function fromEncodedBytes(bytes: Bytes, format: String, doneCallback: Image->Void, errorCallback: String->Void,
|
||||
readable: Bool = false): Void {
|
||||
var image = new Image(readable);
|
||||
var isFloat = format == "hdr" || format == "HDR";
|
||||
image.myFormat = isFloat ? TextureFormat.RGBA128 : TextureFormat.RGBA32;
|
||||
image.initFromEncodedBytes(bytes.getData(), format);
|
||||
doneCallback(image);
|
||||
}
|
||||
|
||||
function initFromEncodedBytes(bytes: BytesData, format: String): Void {
|
||||
_texture = kinc_texture_from_encoded_bytes(bytes.bytes, bytes.length, StringHelper.convert(format), readable);
|
||||
}
|
||||
|
||||
function new(readable: Bool) {
|
||||
this.readable = readable;
|
||||
}
|
||||
|
||||
static function getRenderTargetFormat(format: TextureFormat): Int {
|
||||
switch (format) {
|
||||
case RGBA32: // Target32Bit
|
||||
return 0;
|
||||
case RGBA64: // Target64BitFloat
|
||||
return 1;
|
||||
case RGBA128: // Target128BitFloat
|
||||
return 3;
|
||||
case DEPTH16: // Target16BitDepth
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static function getDepthBufferBits(depthAndStencil: DepthStencilFormat): Int {
|
||||
return switch (depthAndStencil) {
|
||||
case NoDepthAndStencil: -1;
|
||||
case DepthOnly: 24;
|
||||
case DepthAutoStencilAuto: 24;
|
||||
case Depth24Stencil8: 24;
|
||||
case Depth32Stencil8: 32;
|
||||
case Depth16: 16;
|
||||
}
|
||||
}
|
||||
|
||||
static function getStencilBufferBits(depthAndStencil: DepthStencilFormat): Int {
|
||||
return switch (depthAndStencil) {
|
||||
case NoDepthAndStencil: -1;
|
||||
case DepthOnly: -1;
|
||||
case DepthAutoStencilAuto: 8;
|
||||
case Depth24Stencil8: 8;
|
||||
case Depth32Stencil8: 8;
|
||||
case Depth16: 0;
|
||||
}
|
||||
}
|
||||
|
||||
static function getTextureFormat(format: TextureFormat): Int {
|
||||
switch (format) {
|
||||
case RGBA32:
|
||||
return 0;
|
||||
case RGBA128:
|
||||
return 3;
|
||||
case RGBA64:
|
||||
return 4;
|
||||
case A32:
|
||||
return 5;
|
||||
case A16:
|
||||
return 7;
|
||||
default:
|
||||
return 1; // Grey8
|
||||
}
|
||||
}
|
||||
|
||||
public static function create2(width: Int, height: Int, format: TextureFormat, readable: Bool, renderTarget: Bool,
|
||||
depthStencil: DepthStencilFormat): Image {
|
||||
var image = new Image(readable);
|
||||
image.myFormat = format;
|
||||
if (renderTarget)
|
||||
image.initRenderTarget(width, height, getDepthBufferBits(depthStencil), getRenderTargetFormat(format), getStencilBufferBits(depthStencil));
|
||||
else
|
||||
image.init(width, height, format);
|
||||
return image;
|
||||
}
|
||||
|
||||
public static function create3(width: Int, height: Int, depth: Int, format: TextureFormat, readable: Bool, contextId: Int): Image {
|
||||
var image = new Image(readable);
|
||||
image.myFormat = format;
|
||||
image.init3D(width, height, depth, getTextureFormat(format));
|
||||
return image;
|
||||
}
|
||||
|
||||
function initRenderTarget(width: Int, height: Int, depthBufferBits: Int, format: Int, stencilBufferBits: Int): Void {
|
||||
_renderTarget = kinc_render_target_create(width, height, depthBufferBits, format, stencilBufferBits);
|
||||
_texture = null;
|
||||
}
|
||||
|
||||
function init(width: Int, height: Int, format: Int): Void {
|
||||
_texture = kinc_texture_create(width, height, format, readable);
|
||||
_renderTarget = null;
|
||||
}
|
||||
|
||||
function init3D(width: Int, height: Int, depth: Int, format: Int): Void {
|
||||
_texture = kinc_texture_create3d(width, height, depth, format, readable);
|
||||
_renderTarget = null;
|
||||
}
|
||||
|
||||
function initVideo(video: kha.korehl.Video): Void {
|
||||
_texture = kinc_video_get_current_image(video._video);
|
||||
_renderTarget = null;
|
||||
}
|
||||
|
||||
public static function fromFile(filename: String, readable: Bool): Image {
|
||||
var image = new Image(readable);
|
||||
var isFloat = StringTools.endsWith(filename, ".hdr");
|
||||
image.myFormat = isFloat ? TextureFormat.RGBA128 : TextureFormat.RGBA32;
|
||||
image.initFromFile(filename);
|
||||
if (image._texture == null) {
|
||||
return null;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
function initFromFile(filename: String): Void {
|
||||
_texture = kinc_texture_create_from_file(StringHelper.convert(filename), readable);
|
||||
_renderTarget = null;
|
||||
}
|
||||
|
||||
public var g1(get, never): kha.graphics1.Graphics;
|
||||
|
||||
function get_g1(): kha.graphics1.Graphics {
|
||||
if (graphics1 == null) {
|
||||
graphics1 = new kha.graphics2.Graphics1(this);
|
||||
}
|
||||
return graphics1;
|
||||
}
|
||||
|
||||
public var g2(get, never): kha.graphics2.Graphics;
|
||||
|
||||
function get_g2(): kha.graphics2.Graphics {
|
||||
if (graphics2 == null) {
|
||||
graphics2 = new kha.korehl.graphics4.Graphics2(this);
|
||||
}
|
||||
return graphics2;
|
||||
}
|
||||
|
||||
public var g4(get, never): kha.graphics4.Graphics;
|
||||
|
||||
function get_g4(): kha.graphics4.Graphics {
|
||||
if (graphics4 == null) {
|
||||
graphics4 = new kha.korehl.graphics4.Graphics(this);
|
||||
}
|
||||
return graphics4;
|
||||
}
|
||||
|
||||
public static var maxSize(get, never): Int;
|
||||
|
||||
static function get_maxSize(): Int {
|
||||
return 4096;
|
||||
}
|
||||
|
||||
public static var nonPow2Supported(get, never): Bool;
|
||||
|
||||
static function get_nonPow2Supported(): Bool {
|
||||
return kinc_non_pow2_textures_supported();
|
||||
}
|
||||
|
||||
public static function renderTargetsInvertedY(): Bool {
|
||||
return kinc_graphics_render_targets_inverted_y();
|
||||
}
|
||||
|
||||
public var width(get, never): Int;
|
||||
|
||||
function get_width(): Int {
|
||||
return _texture != null ? kinc_texture_get_width(_texture) : kinc_render_target_get_width(_renderTarget);
|
||||
}
|
||||
|
||||
public var height(get, never): Int;
|
||||
|
||||
function get_height(): Int {
|
||||
return _texture != null ? kinc_texture_get_height(_texture) : kinc_render_target_get_height(_renderTarget);
|
||||
}
|
||||
|
||||
public var depth(get, never): Int;
|
||||
|
||||
function get_depth(): Int {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public var format(get, never): TextureFormat;
|
||||
|
||||
function get_format(): TextureFormat {
|
||||
return myFormat;
|
||||
}
|
||||
|
||||
public var realWidth(get, never): Int;
|
||||
|
||||
function get_realWidth(): Int {
|
||||
return _texture != null ? kinc_texture_get_real_width(_texture) : kinc_render_target_get_real_width(_renderTarget);
|
||||
}
|
||||
|
||||
public var realHeight(get, never): Int;
|
||||
|
||||
function get_realHeight(): Int {
|
||||
return _texture != null ? kinc_texture_get_real_height(_texture) : kinc_render_target_get_real_height(_renderTarget);
|
||||
}
|
||||
|
||||
public var stride(get, never): Int;
|
||||
|
||||
function get_stride(): Int {
|
||||
return _texture != null ? kinc_texture_get_stride(_texture) : (formatByteSize(myFormat) * width);
|
||||
}
|
||||
|
||||
public function isOpaque(x: Int, y: Int): Bool {
|
||||
return atInternal(x, y) & 0xff != 0;
|
||||
}
|
||||
|
||||
function atInternal(x: Int, y: Int): Int {
|
||||
return kinc_texture_at(_texture, x, y);
|
||||
}
|
||||
|
||||
public inline function at(x: Int, y: Int): Color {
|
||||
return Color.fromValue(atInternal(x, y));
|
||||
}
|
||||
|
||||
public function unload(): Void {
|
||||
_texture != null ? kinc_texture_unload(_texture) : kinc_render_target_unload(_renderTarget);
|
||||
}
|
||||
|
||||
var bytes: Bytes = null;
|
||||
|
||||
public function lock(level: Int = 0): Bytes {
|
||||
bytes = Bytes.alloc(formatByteSize(myFormat) * width * height);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public function unlock(): Void {
|
||||
kinc_texture_unlock(_texture, bytes.getData().bytes);
|
||||
bytes = null;
|
||||
}
|
||||
|
||||
var pixels: Bytes = null;
|
||||
|
||||
public function getPixels(): Bytes {
|
||||
if (_renderTarget == null)
|
||||
return null;
|
||||
if (pixels == null) {
|
||||
var size = formatByteSize(myFormat) * width * height;
|
||||
pixels = Bytes.alloc(size);
|
||||
}
|
||||
kinc_render_target_get_pixels(_renderTarget, pixels.getData().bytes);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
static function formatByteSize(format: TextureFormat): Int {
|
||||
return switch (format) {
|
||||
case RGBA32: 4;
|
||||
case L8: 1;
|
||||
case RGBA128: 16;
|
||||
case DEPTH16: 2;
|
||||
case RGBA64: 8;
|
||||
case A32: 4;
|
||||
case A16: 2;
|
||||
default: 4;
|
||||
}
|
||||
}
|
||||
|
||||
public function generateMipmaps(levels: Int): Void {
|
||||
_texture != null ? kinc_generate_mipmaps_texture(_texture, levels) : kinc_generate_mipmaps_target(_renderTarget, levels);
|
||||
}
|
||||
|
||||
public function setMipmaps(mipmaps: Array<Image>): Void {
|
||||
for (i in 0...mipmaps.length) {
|
||||
var image = mipmaps[i];
|
||||
var level = i + 1;
|
||||
kinc_set_mipmap_texture(_texture, image._texture, level);
|
||||
}
|
||||
}
|
||||
|
||||
public function setDepthStencilFrom(image: Image): Void {
|
||||
kinc_render_target_set_depth_stencil_from(_renderTarget, image._renderTarget);
|
||||
}
|
||||
|
||||
public function clear(x: Int, y: Int, z: Int, width: Int, height: Int, depth: Int, color: Color): Void {
|
||||
kinc_texture_clear(_texture, x, y, z, width, height, depth, color);
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_create") static function kinc_texture_create(width: Int, height: Int, format: Int, readable: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_create_from_file") static function kinc_texture_create_from_file(filename: hl.Bytes, readable: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_create3d") static function kinc_texture_create3d(width: Int, height: Int, depth: Int, format: Int,
|
||||
readable: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_get_current_image") static function kinc_video_get_current_image(video: Pointer): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_from_bytes") static function kinc_texture_from_bytes(bytes: Pointer, width: Int, height: Int, format: Int,
|
||||
readable: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_from_bytes3d") static function kinc_texture_from_bytes3d(bytes: Pointer, width: Int, height: Int, depth: Int, format: Int,
|
||||
readable: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_from_encoded_bytes") static function kinc_texture_from_encoded_bytes(bytes: Pointer, length: Int, format: hl.Bytes,
|
||||
readable: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_non_pow2_textures_supported") static function kinc_non_pow2_textures_supported(): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_render_targets_inverted_y") static function kinc_graphics_render_targets_inverted_y(): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_get_width") static function kinc_texture_get_width(texture: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_get_height") static function kinc_texture_get_height(texture: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_get_real_width") static function kinc_texture_get_real_width(texture: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_get_real_height") static function kinc_texture_get_real_height(texture: Pointer): Int {
|
||||
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;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_unload") static function kinc_texture_unload(texture: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_unload") static function kinc_render_target_unload(renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_create") static function kinc_render_target_create(width: Int, height: Int, depthBufferBits: Int, format: Int,
|
||||
stencilBufferBits: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_get_width") static function kinc_render_target_get_width(renderTarget: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_get_height") static function kinc_render_target_get_height(renderTarget: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_get_real_width") static function kinc_render_target_get_real_width(renderTarget: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_get_real_height") static function kinc_render_target_get_real_height(renderTarget: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_unlock") static function kinc_texture_unlock(texture: Pointer, bytes: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_get_pixels") static function kinc_render_target_get_pixels(renderTarget: Pointer, pixels: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_generate_mipmaps_texture") static function kinc_generate_mipmaps_texture(texture: Pointer, levels: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_generate_mipmaps_target") static function kinc_generate_mipmaps_target(renderTarget: Pointer, levels: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_set_mipmap_texture") static function kinc_set_mipmap_texture(texture: Pointer, mipmap: Pointer, level: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_render_target_set_depth_stencil_from") static function kinc_render_target_set_depth_stencil_from(renderTarget: Pointer,
|
||||
from: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_texture_clear") static function kinc_texture_clear(texture: Pointer, x: Int, y: Int, z: Int, width: Int, height: Int, depth: Int,
|
||||
color: Color): Void {}
|
||||
}
|
74
Kha/Backends/Kinc-HL/kha/LoaderImpl.hx
Normal file
74
Kha/Backends/Kinc-HL/kha/LoaderImpl.hx
Normal file
@ -0,0 +1,74 @@
|
||||
package kha;
|
||||
|
||||
import kha.Blob;
|
||||
import haxe.io.Bytes;
|
||||
import kha.Kravur;
|
||||
import sys.io.File;
|
||||
|
||||
class LoaderImpl {
|
||||
public static function loadSoundFromDescription(desc: Dynamic, done: kha.Sound->Void, failed: AssetError->Void) {
|
||||
done(new kha.korehl.Sound(desc.files[0]));
|
||||
}
|
||||
|
||||
public static function getSoundFormats(): Array<String> {
|
||||
return ["wav", "ogg"];
|
||||
}
|
||||
|
||||
public static function loadImageFromDescription(desc: Dynamic, done: kha.Image->Void, failed: AssetError->Void) {
|
||||
var readable = Reflect.hasField(desc, "readable") ? desc.readable : false;
|
||||
var image = kha.Image.fromFile(desc.files[0], readable);
|
||||
if (image == null) {
|
||||
failed({
|
||||
url: desc.files.join(","),
|
||||
error: "Could not load image(s)",
|
||||
});
|
||||
}
|
||||
else {
|
||||
done(image);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getImageFormats(): Array<String> {
|
||||
return ["png", "jpg", "hdr"];
|
||||
}
|
||||
|
||||
public static function loadBlobFromDescription(desc: Dynamic, done: Blob->Void, failed: AssetError->Void) {
|
||||
// done(new Blob(File.getBytes(desc.files[0])));
|
||||
var size = 0;
|
||||
var bytes = kinc_file_contents(StringHelper.convert(desc.files[0]), size);
|
||||
if (bytes == null) {
|
||||
failed({
|
||||
url: desc.files.join(","),
|
||||
error: "Could not load blob(s)",
|
||||
});
|
||||
}
|
||||
else {
|
||||
done(new Blob(@:privateAccess new haxe.io.Bytes(bytes, size)));
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadFontFromDescription(desc: Dynamic, done: Font->Void, failed: AssetError->Void): Void {
|
||||
loadBlobFromDescription(desc, function(blob: Blob) {
|
||||
done(new Kravur(blob));
|
||||
}, (a: AssetError) -> {
|
||||
a.error = "Could not load font(s)";
|
||||
failed(a);
|
||||
});
|
||||
}
|
||||
|
||||
public static function loadVideoFromDescription(desc: Dynamic, done: Video->Void, failed: AssetError->Void) {
|
||||
done(new kha.korehl.Video(desc.files[0]));
|
||||
}
|
||||
|
||||
public static function getVideoFormats(): Array<String> {
|
||||
return [StringHelper.fromBytes(kinc_video_format())];
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_file_contents") static function kinc_file_contents(name: hl.Bytes, size: hl.Ref<Int>): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_format") static function kinc_video_format(): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
3
Kha/Backends/Kinc-HL/kha/Pointer.hx
Normal file
3
Kha/Backends/Kinc-HL/kha/Pointer.hx
Normal file
@ -0,0 +1,3 @@
|
||||
package kha;
|
||||
|
||||
typedef Pointer = hl.Bytes;
|
15
Kha/Backends/Kinc-HL/kha/Storage.hx
Normal file
15
Kha/Backends/Kinc-HL/kha/Storage.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package kha;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.BytesBuffer;
|
||||
import haxe.io.BytesData;
|
||||
|
||||
class Storage {
|
||||
public static function namedFile(name: String): StorageFile {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function defaultFile(): StorageFile {
|
||||
return namedFile("default.kha");
|
||||
}
|
||||
}
|
17
Kha/Backends/Kinc-HL/kha/StringHelper.hx
Normal file
17
Kha/Backends/Kinc-HL/kha/StringHelper.hx
Normal file
@ -0,0 +1,17 @@
|
||||
package kha;
|
||||
|
||||
@:access(String)
|
||||
class StringHelper {
|
||||
public static inline function convert(s: String): hl.Bytes {
|
||||
var size = 0;
|
||||
return s.bytes.utf16ToUtf8(0, size);
|
||||
}
|
||||
|
||||
public static inline function fromBytes(bytes: hl.Bytes): String {
|
||||
var s = "";
|
||||
var size = 0;
|
||||
s.bytes = bytes.utf8ToUtf16(0, size);
|
||||
s.length = Std.int(size / 2);
|
||||
return s;
|
||||
}
|
||||
}
|
496
Kha/Backends/Kinc-HL/kha/SystemImpl.hx
Normal file
496
Kha/Backends/Kinc-HL/kha/SystemImpl.hx
Normal file
@ -0,0 +1,496 @@
|
||||
package kha;
|
||||
|
||||
import kha.graphics4.TextureFormat;
|
||||
import kha.input.Gamepad;
|
||||
import kha.input.KeyCode;
|
||||
import kha.input.Keyboard;
|
||||
import kha.input.Mouse;
|
||||
import kha.input.MouseImpl;
|
||||
import kha.input.Pen;
|
||||
import kha.input.Surface;
|
||||
import kha.System;
|
||||
|
||||
class SystemImpl {
|
||||
static var framebuffer: Framebuffer;
|
||||
static var keyboard: Keyboard;
|
||||
static var mouse: kha.input.Mouse;
|
||||
static var pen: kha.input.Pen;
|
||||
static var gamepads: Array<Gamepad>;
|
||||
static var surface: Surface;
|
||||
static var mouseLockListeners: Array<Void->Void>;
|
||||
|
||||
public static function init(options: SystemOptions, callback: Window->Void): Void {
|
||||
haxe.Log.trace = function(v: Dynamic, ?infos: haxe.PosInfos) {
|
||||
var message = infos != null ? infos.className + ":" + infos.lineNumber + ": " + v : Std.string(v);
|
||||
kinc_log(StringHelper.convert(message));
|
||||
};
|
||||
init_kore(StringHelper.convert(options.title), options.width, options.height, options.framebuffer.samplesPerPixel, options.framebuffer.verticalSync,
|
||||
cast options.window.mode, options.window.windowFeatures);
|
||||
|
||||
new Window(0);
|
||||
Scheduler.init();
|
||||
Shaders.init();
|
||||
|
||||
var g4 = new kha.korehl.graphics4.Graphics();
|
||||
framebuffer = new Framebuffer(0, null, null, g4);
|
||||
framebuffer.init(new kha.graphics2.Graphics1(framebuffer), new kha.korehl.graphics4.Graphics2(framebuffer), g4);
|
||||
final samplesRef: hl.Ref<Int> = kha.audio2.Audio.samplesPerSecond;
|
||||
kinc_init_audio(kha.audio2.Audio._callCallback, kha.audio2.Audio._readSample, samplesRef);
|
||||
kha.audio2.Audio.samplesPerSecond = samplesRef.get();
|
||||
kha.audio1.Audio._init();
|
||||
kha.audio2.Audio._init();
|
||||
keyboard = new kha.input.Keyboard();
|
||||
mouse = new kha.input.MouseImpl();
|
||||
pen = new kha.input.Pen();
|
||||
gamepads = new Array<Gamepad>();
|
||||
for (i in 0...4) {
|
||||
gamepads[i] = new kha.input.Gamepad(i);
|
||||
gamepads[i].connected = kinc_gamepad_connected(i);
|
||||
}
|
||||
surface = new kha.input.Surface();
|
||||
mouseLockListeners = new Array();
|
||||
kinc_register_keyboard(keyDown, keyUp, keyPress);
|
||||
kinc_register_mouse(mouseDown, mouseUp, mouseMove, mouseWheel);
|
||||
kinc_register_pen(penDown, penUp, penMove);
|
||||
kinc_register_gamepad(gamepadAxis, gamepadButton);
|
||||
kinc_register_surface(touchStart, touchEnd, touchMove);
|
||||
kinc_register_sensor(kha.input.Sensor._accelerometerChanged, kha.input.Sensor._gyroscopeChanged);
|
||||
kinc_register_callbacks(foreground, resume, pause, background, shutdown);
|
||||
kinc_register_dropfiles(dropFiles);
|
||||
kinc_register_copycutpaste(copy, cut, paste);
|
||||
|
||||
Scheduler.start();
|
||||
callback(Window.get(0));
|
||||
|
||||
run_kore();
|
||||
}
|
||||
|
||||
public static function initEx(title: String, options: Array<WindowOptions>, windowCallback: Int->Void, callback: Void->Void): Void {}
|
||||
|
||||
@:keep
|
||||
public static function frame(): Void {
|
||||
Scheduler.executeFrame();
|
||||
System.render([framebuffer]);
|
||||
|
||||
for (i in 0...4) {
|
||||
if (gamepads[i].connected && !kinc_gamepad_connected(i)) {
|
||||
Gamepad.sendDisconnectEvent(i);
|
||||
}
|
||||
else if (!gamepads[i].connected && kinc_gamepad_connected(i)) {
|
||||
Gamepad.sendConnectEvent(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getTime(): Float {
|
||||
return kinc_get_time();
|
||||
}
|
||||
|
||||
public static function windowWidth(windowId: Int): Int {
|
||||
return kinc_get_window_width(windowId);
|
||||
}
|
||||
|
||||
public static function windowHeight(windowId: Int): Int {
|
||||
return kinc_get_window_height(windowId);
|
||||
}
|
||||
|
||||
public static function getScreenRotation(): ScreenRotation {
|
||||
return ScreenRotation.RotationNone;
|
||||
}
|
||||
|
||||
public static function getSystemId(): String {
|
||||
final b: hl.Bytes = kinc_get_system_id();
|
||||
return @:privateAccess String.fromUTF8(b);
|
||||
}
|
||||
|
||||
public static function vibrate(ms: Int): Void {
|
||||
kinc_vibrate(ms);
|
||||
}
|
||||
|
||||
public static function getLanguage(): String {
|
||||
final b: hl.Bytes = kinc_get_language();
|
||||
return @:privateAccess String.fromUTF8(b);
|
||||
}
|
||||
|
||||
public static function requestShutdown(): Bool {
|
||||
kinc_request_shutdown();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getMouse(num: Int): Mouse {
|
||||
if (num != 0)
|
||||
return null;
|
||||
return mouse;
|
||||
}
|
||||
|
||||
public static function getPen(num: Int): Pen {
|
||||
if (num != 0)
|
||||
return null;
|
||||
return pen;
|
||||
}
|
||||
|
||||
public static function getKeyboard(num: Int): Keyboard {
|
||||
if (num != 0)
|
||||
return null;
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
public static function lockMouse(windowId: Int = 0): Void {
|
||||
if (!isMouseLocked()) {
|
||||
kinc_mouse_lock(windowId);
|
||||
for (listener in mouseLockListeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function unlockMouse(windowId: Int = 0): Void {
|
||||
if (isMouseLocked()) {
|
||||
kinc_mouse_unlock(windowId);
|
||||
for (listener in mouseLockListeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function canLockMouse(windowId: Int = 0): Bool {
|
||||
return kinc_can_lock_mouse(windowId);
|
||||
}
|
||||
|
||||
public static function isMouseLocked(windowId: Int = 0): Bool {
|
||||
return kinc_is_mouse_locked(windowId);
|
||||
}
|
||||
|
||||
public static function notifyOfMouseLockChange(func: Void->Void, error: Void->Void): Void {
|
||||
if (canLockMouse(0) && func != null) {
|
||||
mouseLockListeners.push(func);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeFromMouseLockChange(func: Void->Void, error: Void->Void): Void {
|
||||
if (canLockMouse(0) && func != null) {
|
||||
mouseLockListeners.remove(func);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hideSystemCursor(): Void {
|
||||
kinc_show_mouse(false);
|
||||
}
|
||||
|
||||
public static function showSystemCursor(): Void {
|
||||
kinc_show_mouse(true);
|
||||
}
|
||||
|
||||
public static function keyDown(code: KeyCode): Void {
|
||||
keyboard.sendDownEvent(code);
|
||||
}
|
||||
|
||||
public static function keyUp(code: KeyCode): Void {
|
||||
keyboard.sendUpEvent(code);
|
||||
}
|
||||
|
||||
public static function keyPress(char: Int): Void {
|
||||
keyboard.sendPressEvent(String.fromCharCode(char));
|
||||
}
|
||||
|
||||
public static function mouseDown(windowId: Int, button: Int, x: Int, y: Int): Void {
|
||||
mouse.sendDownEvent(windowId, button, x, y);
|
||||
}
|
||||
|
||||
public static function mouseUp(windowId: Int, button: Int, x: Int, y: Int): Void {
|
||||
mouse.sendUpEvent(windowId, button, x, y);
|
||||
}
|
||||
|
||||
public static function mouseMove(windowId: Int, x: Int, y: Int, movementX: Int, movementY: Int): Void {
|
||||
mouse.sendMoveEvent(windowId, x, y, movementX, movementY);
|
||||
}
|
||||
|
||||
public static function mouseWheel(windowId: Int, delta: Int): Void {
|
||||
mouse.sendWheelEvent(windowId, delta);
|
||||
}
|
||||
|
||||
public static function mouseLeave(windowId: Int): Void {
|
||||
mouse.sendLeaveEvent(windowId);
|
||||
}
|
||||
|
||||
public static function penDown(windowId: Int, x: Int, y: Int, pressure: Float): Void {
|
||||
pen.sendDownEvent(windowId, x, y, pressure);
|
||||
}
|
||||
|
||||
public static function penUp(windowId: Int, x: Int, y: Int, pressure: Float): Void {
|
||||
pen.sendUpEvent(windowId, x, y, pressure);
|
||||
}
|
||||
|
||||
public static function penMove(windowId: Int, x: Int, y: Int, pressure: Float): Void {
|
||||
pen.sendMoveEvent(windowId, x, y, pressure);
|
||||
}
|
||||
|
||||
public static function gamepadAxis(gamepad: Int, axis: Int, value: FastFloat): Void {
|
||||
gamepads[gamepad].sendAxisEvent(axis, value);
|
||||
}
|
||||
|
||||
public static function gamepadButton(gamepad: Int, button: Int, value: FastFloat): Void {
|
||||
gamepads[gamepad].sendButtonEvent(button, value);
|
||||
}
|
||||
|
||||
public static function touchStart(index: Int, x: Int, y: Int): Void {
|
||||
surface.sendTouchStartEvent(index, x, y);
|
||||
}
|
||||
|
||||
public static function touchEnd(index: Int, x: Int, y: Int): Void {
|
||||
surface.sendTouchEndEvent(index, x, y);
|
||||
}
|
||||
|
||||
public static function touchMove(index: Int, x: Int, y: Int): Void {
|
||||
surface.sendMoveEvent(index, x, y);
|
||||
}
|
||||
|
||||
public static function foreground(): Void {
|
||||
System.foreground();
|
||||
}
|
||||
|
||||
public static function resume(): Void {
|
||||
System.resume();
|
||||
}
|
||||
|
||||
public static function pause(): Void {
|
||||
System.pause();
|
||||
}
|
||||
|
||||
public static function background(): Void {
|
||||
System.background();
|
||||
}
|
||||
|
||||
public static function shutdown(): Void {
|
||||
System.shutdown();
|
||||
}
|
||||
|
||||
public static function dropFiles(filePath: String): Void {
|
||||
System.dropFiles(filePath);
|
||||
}
|
||||
|
||||
public static function copy(): hl.Bytes {
|
||||
if (System.copyListener != null) {
|
||||
final text = System.copyListener();
|
||||
if (text == null)
|
||||
return null;
|
||||
return StringHelper.convert(text);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function cut(): hl.Bytes {
|
||||
if (System.cutListener != null) {
|
||||
final text = System.cutListener();
|
||||
if (text == null)
|
||||
return null;
|
||||
return StringHelper.convert(text);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function paste(data: hl.Bytes): Void {
|
||||
final text = @:privateAccess String.fromUTF8(data);
|
||||
if (System.pasteListener != null) {
|
||||
System.pasteListener(text);
|
||||
}
|
||||
}
|
||||
|
||||
static var fullscreenListeners: Array<Void->Void> = new Array();
|
||||
static var previousWidth: Int = 0;
|
||||
static var previousHeight: Int = 0;
|
||||
|
||||
public static function canSwitchFullscreen(): Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function isFullscreen(): Bool {
|
||||
return kinc_system_is_fullscreen();
|
||||
}
|
||||
|
||||
public static function requestFullscreen(): Void {
|
||||
if (!isFullscreen()) {
|
||||
previousWidth = kinc_get_window_width(0);
|
||||
previousHeight = kinc_get_window_height(0);
|
||||
kinc_system_request_fullscreen();
|
||||
for (listener in fullscreenListeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function exitFullscreen(): Void {
|
||||
if (isFullscreen()) {
|
||||
if (previousWidth == 0 || previousHeight == 0) {
|
||||
previousWidth = kinc_get_window_width(0);
|
||||
previousHeight = kinc_get_window_height(0);
|
||||
}
|
||||
kinc_system_exit_fullscreen(previousWidth, previousHeight);
|
||||
for (listener in fullscreenListeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function notifyOfFullscreenChange(func: Void->Void, error: Void->Void): Void {
|
||||
if (canSwitchFullscreen() && func != null) {
|
||||
fullscreenListeners.push(func);
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeFromFullscreenChange(func: Void->Void, error: Void->Void): Void {
|
||||
if (canSwitchFullscreen() && func != null) {
|
||||
fullscreenListeners.remove(func);
|
||||
}
|
||||
}
|
||||
|
||||
public static function changeResolution(width: Int, height: Int): Void {
|
||||
kinc_system_change_resolution(width, height);
|
||||
}
|
||||
|
||||
public static function setKeepScreenOn(on: Bool): Void {
|
||||
kinc_system_set_keepscreenon(on);
|
||||
}
|
||||
|
||||
public static function loadUrl(url: String): Void {
|
||||
kinc_system_load_url(StringHelper.convert(url));
|
||||
}
|
||||
|
||||
public static function getGamepadId(index: Int): String {
|
||||
final b: hl.Bytes = kinc_get_gamepad_id(index);
|
||||
return @:privateAccess String.fromUTF8(b);
|
||||
}
|
||||
|
||||
public static function getGamepadVendor(index: Int): String {
|
||||
final b: hl.Bytes = kinc_get_gamepad_vendor(index);
|
||||
return @:privateAccess String.fromUTF8(b);
|
||||
}
|
||||
|
||||
public static function setGamepadRumble(index: Int, leftAmount: Float, rightAmount: Float) {}
|
||||
|
||||
public static function safeZone(): Float {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
public static function login(): Void {}
|
||||
|
||||
public static function automaticSafeZone(): Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function setSafeZone(value: Float): Void {}
|
||||
|
||||
public static function unlockAchievement(id: Int): Void {}
|
||||
|
||||
public static function waitingForLogin(): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function disallowUserChange(): Void {}
|
||||
|
||||
public static function allowUserChange(): Void {}
|
||||
|
||||
@:hlNative("std", "init_kore") static function init_kore(title: hl.Bytes, width: Int, height: Int, samplesPerPixel: Int, vSync: Bool, windowMode: Int,
|
||||
windowFeatures: Int): Void {}
|
||||
|
||||
@:hlNative("std", "run_kore") static function run_kore(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_init_audio") static function kinc_init_audio(callCallback: Int->Void, readSample: Void->FastFloat,
|
||||
outSamplesPerSecond: hl.Ref<Int>): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_log") static function kinc_log(v: hl.Bytes): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_get_time") static function kinc_get_time(): Float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_get_window_width") static function kinc_get_window_width(window: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_get_window_height") static function kinc_get_window_height(window: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_get_system_id") static function kinc_get_system_id(): hl.Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_vibrate") static function kinc_vibrate(ms: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_get_language") static function kinc_get_language(): hl.Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_request_shutdown") static function kinc_request_shutdown(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_mouse_lock") static function kinc_mouse_lock(windowId: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_mouse_unlock") static function kinc_mouse_unlock(windowId: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_can_lock_mouse") static function kinc_can_lock_mouse(windowId: Int): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_is_mouse_locked") static function kinc_is_mouse_locked(windowId: Int): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_show_mouse") static function kinc_show_mouse(show: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_system_is_fullscreen") static function kinc_system_is_fullscreen(): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_system_request_fullscreen") static function kinc_system_request_fullscreen(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_system_exit_fullscreen") static function kinc_system_exit_fullscreen(previousWidth: Int, previousHeight: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_keyboard") static function kinc_register_keyboard(keyDown: KeyCode->Void, keyUp: KeyCode->Void,
|
||||
keyPress: Int->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_mouse") static function kinc_register_mouse(mouseDown: Int->Int->Int->Int->Void, mouseUp: Int->Int->Int->Int->Void,
|
||||
mouseMove: Int->Int->Int->Int->Int->Void, mouseWheel: Int->Int->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_pen") static function kinc_register_pen(penDown: Int->Int->Int->Float->Void, penUp: Int->Int->Int->Float->Void,
|
||||
penMove: Int->Int->Int->Float->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_gamepad") static function kinc_register_gamepad(gamepadAxis: Int->Int->FastFloat->Void,
|
||||
gamepadButton: Int->Int->FastFloat->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_surface") static function kinc_register_surface(touchStart: Int->Int->Int->Void, touchEnd: Int->Int->Int->Void,
|
||||
touchMove: Int->Int->Int->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_sensor") static function kinc_register_sensor(accelerometerChanged: Float->Float->Float->Void,
|
||||
gyroscopeChanged: Float->Float->Float->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_callbacks") static function kinc_register_callbacks(foreground: Void->Void, resume: Void->Void, pause: Void->Void,
|
||||
background: Void->Void, shutdown: Void->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_dropfiles") static function kinc_register_dropfiles(dropFiles: String->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_register_copycutpaste") static function kinc_register_copycutpaste(copy: Void->hl.Bytes, cut: Void->hl.Bytes,
|
||||
paste: hl.Bytes->Void): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_system_change_resolution") static function kinc_system_change_resolution(width: Int, height: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_system_set_keepscreenon") static function kinc_system_set_keepscreenon(on: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_system_load_url") static function kinc_system_load_url(url: hl.Bytes): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_get_gamepad_id") static function kinc_get_gamepad_id(index: Int): hl.Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_get_gamepad_vendor") static function kinc_get_gamepad_vendor(index: Int): hl.Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_gamepad_connected") static function kinc_gamepad_connected(index: Int): Bool {
|
||||
return false;
|
||||
}
|
||||
}
|
116
Kha/Backends/Kinc-HL/kha/Window.hx
Normal file
116
Kha/Backends/Kinc-HL/kha/Window.hx
Normal file
@ -0,0 +1,116 @@
|
||||
package kha;
|
||||
|
||||
class Window {
|
||||
static var windows: Array<Window> = [];
|
||||
|
||||
var num: Int;
|
||||
|
||||
@:noCompletion
|
||||
@:noDoc
|
||||
public function new(num: Int) {
|
||||
this.num = num;
|
||||
windows.push(this);
|
||||
}
|
||||
|
||||
public static function create(win: WindowOptions = null, frame: FramebufferOptions = null): Window {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function destroy(window: Window): Void {}
|
||||
|
||||
public static function get(index: Int): Window {
|
||||
return windows[index];
|
||||
}
|
||||
|
||||
public static var all(get, never): Array<Window>;
|
||||
|
||||
static function get_all(): Array<Window> {
|
||||
return windows;
|
||||
}
|
||||
|
||||
public function resize(width: Int, height: Int): Void {}
|
||||
|
||||
public function move(x: Int, y: Int): Void {}
|
||||
|
||||
public function changeWindowFeatures(features: Int): Void {}
|
||||
|
||||
public function changeFramebuffer(frame: FramebufferOptions): Void {}
|
||||
|
||||
public var x(get, set): Int;
|
||||
|
||||
function get_x(): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function set_x(value: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public var y(get, set): Int;
|
||||
|
||||
function get_y(): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function set_y(value: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public var width(get, set): Int;
|
||||
|
||||
function get_width(): Int {
|
||||
return SystemImpl.windowWidth(num);
|
||||
}
|
||||
|
||||
function set_width(value: Int): Int {
|
||||
return 800;
|
||||
}
|
||||
|
||||
public var height(get, set): Int;
|
||||
|
||||
function get_height(): Int {
|
||||
return SystemImpl.windowHeight(num);
|
||||
}
|
||||
|
||||
function set_height(value: Int): Int {
|
||||
return 600;
|
||||
}
|
||||
|
||||
public var mode(get, set): WindowMode;
|
||||
|
||||
function get_mode(): WindowMode {
|
||||
return Windowed;
|
||||
}
|
||||
|
||||
function set_mode(mode: WindowMode): WindowMode {
|
||||
return Windowed;
|
||||
}
|
||||
|
||||
public var visible(get, set): Bool;
|
||||
|
||||
function get_visible(): Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
function set_visible(value: Bool): Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public var title(get, set): String;
|
||||
|
||||
function get_title(): String {
|
||||
return "Kha";
|
||||
}
|
||||
|
||||
function set_title(value: String): String {
|
||||
return "Kha";
|
||||
}
|
||||
|
||||
public function notifyOnResize(callback: Int->Int->Void): Void {}
|
||||
|
||||
public var vSynced(get, never): Bool;
|
||||
|
||||
function get_vSynced(): Bool {
|
||||
return true;
|
||||
}
|
||||
}
|
448
Kha/Backends/Kinc-HL/kha/arrays/ByteArray.hx
Normal file
448
Kha/Backends/Kinc-HL/kha/arrays/ByteArray.hx
Normal file
@ -0,0 +1,448 @@
|
||||
package kha.arrays;
|
||||
|
||||
class ByteArrayPrivate {
|
||||
public var self: ByteBuffer;
|
||||
public var byteArrayOffset: Int;
|
||||
public var byteArrayLength: Int;
|
||||
|
||||
public inline function new(offset: Int, length: Int) {
|
||||
this.byteArrayOffset = offset;
|
||||
this.byteArrayLength = length;
|
||||
}
|
||||
}
|
||||
|
||||
abstract ByteArray(ByteArrayPrivate) {
|
||||
public var buffer(get, never): ByteBuffer;
|
||||
|
||||
inline function get_buffer(): ByteBuffer {
|
||||
return this.self;
|
||||
}
|
||||
|
||||
public var byteLength(get, never): Int;
|
||||
|
||||
inline function get_byteLength(): Int {
|
||||
return this.byteArrayLength;
|
||||
}
|
||||
|
||||
public var byteOffset(get, never): Int;
|
||||
|
||||
inline function get_byteOffset(): Int {
|
||||
return this.byteArrayOffset;
|
||||
}
|
||||
|
||||
public inline function new(buffer: ByteBuffer, byteOffset: Int, byteLength: Int): Void {
|
||||
this = new ByteArrayPrivate(byteOffset, byteLength);
|
||||
this.self = buffer;
|
||||
}
|
||||
|
||||
public static inline function make(byteLength: Int): ByteArray {
|
||||
var buffer = ByteBuffer.create(byteLength);
|
||||
return new ByteArray(buffer, 0, byteLength);
|
||||
}
|
||||
|
||||
public inline function free() {
|
||||
this.self.free();
|
||||
}
|
||||
|
||||
public inline function getData(): Pointer {
|
||||
return this.self;
|
||||
}
|
||||
|
||||
// Get
|
||||
|
||||
public inline function getInt8(byteOffset: Int): Int {
|
||||
return kinc_bytearray_getint8(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getUint8(byteOffset: Int): Int {
|
||||
return kinc_bytearray_getuint8(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getInt16(byteOffset: Int): Int {
|
||||
return kinc_bytearray_getint16(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getUint16(byteOffset: Int): Int {
|
||||
return kinc_bytearray_getuint16(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getInt32(byteOffset: Int): Int {
|
||||
return kinc_bytearray_getint32(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getUint32(byteOffset: Int): Int {
|
||||
return kinc_bytearray_getuint32(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getFloat32(byteOffset: Int): FastFloat {
|
||||
return kinc_bytearray_getfloat32(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
public inline function getFloat64(byteOffset: Int): Float {
|
||||
return kinc_bytearray_getfloat64(this.self, this.byteArrayOffset + byteOffset);
|
||||
}
|
||||
|
||||
// Set
|
||||
|
||||
public inline function setInt8(byteOffset: Int, value: Int): Void {
|
||||
kinc_bytearray_setint8(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setUint8(byteOffset: Int, value: Int): Void {
|
||||
kinc_bytearray_setuint8(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setInt16(byteOffset: Int, value: Int): Void {
|
||||
kinc_bytearray_setint16(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setUint16(byteOffset: Int, value: Int): Void {
|
||||
kinc_bytearray_setuint16(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setInt32(byteOffset: Int, value: Int): Void {
|
||||
kinc_bytearray_setint32(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setUint32(byteOffset: Int, value: hl.I64): Void {
|
||||
kinc_bytearray_setuint32(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setFloat32(byteOffset: Int, value: FastFloat): Void {
|
||||
kinc_bytearray_setfloat32(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
public inline function setFloat64(byteOffset: Int, value: Float): Void {
|
||||
kinc_bytearray_setfloat64(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
}
|
||||
|
||||
// Get (little endian)
|
||||
|
||||
public inline function getInt16LE(byteOffset: Int): Int {
|
||||
#if !sys_bigendian
|
||||
return getInt16(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getint16_le(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getUint16LE(byteOffset: Int): Int {
|
||||
#if !sys_bigendian
|
||||
return getUint16(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getuint16_le(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getInt32LE(byteOffset: Int): Int {
|
||||
#if !sys_bigendian
|
||||
return getInt32(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getint32_le(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getUint32LE(byteOffset: Int): hl.I64 {
|
||||
#if !sys_bigendian
|
||||
return getUint32(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getuint32_le(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getFloat32LE(byteOffset: Int): FastFloat {
|
||||
#if !sys_bigendian
|
||||
return getFloat32(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getfloat32_le(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getFloat64LE(byteOffset: Int): Float {
|
||||
#if !sys_bigendian
|
||||
return getFloat64(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getfloat64_le(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
// Set (little endian)
|
||||
|
||||
public inline function setInt16LE(byteOffset: Int, value: Int): Void {
|
||||
#if !sys_bigendian
|
||||
setInt16(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setint16_le(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setUint16LE(byteOffset: Int, value: Int): Void {
|
||||
#if !sys_bigendian
|
||||
setUint16(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setuint16_le(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setInt32LE(byteOffset: Int, value: Int): Void {
|
||||
#if !sys_bigendian
|
||||
setInt32(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setint32_le(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setUint32LE(byteOffset: Int, value: hl.I64): Void {
|
||||
#if !sys_bigendian
|
||||
setUint32(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setuint32_le(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setFloat32LE(byteOffset: Int, value: FastFloat): Void {
|
||||
#if !sys_bigendian
|
||||
setFloat32(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setfloat32_le(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setFloat64LE(byteOffset: Int, value: Float): Void {
|
||||
#if !sys_bigendian
|
||||
setFloat64(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setfloat64_le(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
// Get (big endian)
|
||||
|
||||
public inline function getInt16BE(byteOffset: Int): Int {
|
||||
#if sys_bigendian
|
||||
return getInt16(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getint16_be(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getUint16BE(byteOffset: Int): Int {
|
||||
#if sys_bigendian
|
||||
return getUint16(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getuint16_be(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getInt32BE(byteOffset: Int): Int {
|
||||
#if sys_bigendian
|
||||
return getInt32(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getint32_be(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getUint32BE(byteOffset: Int): hl.I64 {
|
||||
#if sys_bigendian
|
||||
return getUint32(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getuint32_be(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getFloat32BE(byteOffset: Int): FastFloat {
|
||||
#if sys_bigendian
|
||||
return getFloat32(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getfloat32_be(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function getFloat64BE(byteOffset: Int): Float {
|
||||
#if sys_bigendian
|
||||
return getFloat64(byteOffset);
|
||||
#else
|
||||
return kinc_bytearray_getfloat64_be(this.self, this.byteArrayOffset + byteOffset);
|
||||
#end
|
||||
}
|
||||
|
||||
// Set (big endian)
|
||||
|
||||
public inline function setInt16BE(byteOffset: Int, value: Int): Void {
|
||||
#if sys_bigendian
|
||||
setInt16(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setint16_be(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setUint16BE(byteOffset: Int, value: Int): Void {
|
||||
#if sys_bigendian
|
||||
setUint16(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setuint16_be(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setInt32BE(byteOffset: Int, value: Int): Void {
|
||||
#if sys_bigendian
|
||||
setInt32(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setint32_be(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setUint32BE(byteOffset: Int, value: hl.I64): Void {
|
||||
#if sys_bigendian
|
||||
setUint32(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setuint32_be(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setFloat32BE(byteOffset: Int, value: FastFloat): Void {
|
||||
#if sys_bigendian
|
||||
setFloat32(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setfloat32_be(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public inline function setFloat64BE(byteOffset: Int, value: Float): Void {
|
||||
#if sys_bigendian
|
||||
setFloat64(byteOffset, value);
|
||||
#else
|
||||
kinc_bytearray_setfloat64_be(this.self, this.byteArrayOffset + byteOffset, value);
|
||||
#end
|
||||
}
|
||||
|
||||
public function subarray(start: Int, ?end: Int): ByteArray {
|
||||
var offset: Int = this.byteArrayOffset + start;
|
||||
var length: Int = end == null ? this.byteArrayLength - start : end - start;
|
||||
return new ByteArray(this.self, offset, length);
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint8") static function kinc_bytearray_getint8(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint8") static function kinc_bytearray_getuint8(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint16") static function kinc_bytearray_getint16(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint16") static function kinc_bytearray_getuint16(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint32") static function kinc_bytearray_getint32(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint32") static function kinc_bytearray_getuint32(bytearray: Pointer, byteOffset: Int): hl.I64 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getfloat32") static function kinc_bytearray_getfloat32(bytearray: Pointer, byteOffset: Int): FastFloat {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getfloat64") static function kinc_bytearray_getfloat64(bytearray: Pointer, byteOffset: Int): Float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint8") static function kinc_bytearray_setint8(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint8") static function kinc_bytearray_setuint8(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint16") static function kinc_bytearray_setint16(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint16") static function kinc_bytearray_setuint16(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint32") static function kinc_bytearray_setint32(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint32") static function kinc_bytearray_setuint32(bytearray: Pointer, byteOffset: Int, value: hl.I64) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setfloat32") static function kinc_bytearray_setfloat32(bytearray: Pointer, byteOffset: Int, value: FastFloat) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setfloat64") static function kinc_bytearray_setfloat64(bytearray: Pointer, byteOffset: Int, value: Float) {}
|
||||
|
||||
// Variants for little endian on big endian system
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint16_le") static function kinc_bytearray_getint16_le(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint16_le") static function kinc_bytearray_getuint16_le(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint32_le") static function kinc_bytearray_getint32_le(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint32_le") static function kinc_bytearray_getuint32_le(bytearray: Pointer, byteOffset: Int): hl.I64 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getfloat32_le") static function kinc_bytearray_getfloat32_le(bytearray: Pointer, byteOffset: Int): FastFloat {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getfloat64_le") static function kinc_bytearray_getfloat64_le(bytearray: Pointer, byteOffset: Int): Float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint16_le") static function kinc_bytearray_setint16_le(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint16_le") static function kinc_bytearray_setuint16_le(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint32_le") static function kinc_bytearray_setint32_le(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint32_le") static function kinc_bytearray_setuint32_le(bytearray: Pointer, byteOffset: Int, value: hl.I64) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setfloat32_le") static function kinc_bytearray_setfloat32_le(bytearray: Pointer, byteOffset: Int, value: FastFloat) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setfloat64_le") static function kinc_bytearray_setfloat64_le(bytearray: Pointer, byteOffset: Int, value: Float) {}
|
||||
|
||||
// Variants for big endian on little endian system
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint16_be") static function kinc_bytearray_getint16_be(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint16_be") static function kinc_bytearray_getuint16_be(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getint32_be") static function kinc_bytearray_getint32_be(bytearray: Pointer, byteOffset: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getuint32_be") static function kinc_bytearray_getuint32_be(bytearray: Pointer, byteOffset: Int): hl.I64 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getfloat32_be") static function kinc_bytearray_getfloat32_be(bytearray: Pointer, byteOffset: Int): FastFloat {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_getfloat64_be") static function kinc_bytearray_getfloat64_be(bytearray: Pointer, byteOffset: Int): Float {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint16_be") static function kinc_bytearray_setint16_be(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint16_be") static function kinc_bytearray_setuint16_be(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setint32_be") static function kinc_bytearray_setint32_be(bytearray: Pointer, byteOffset: Int, value: Int) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setuint32_be") static function kinc_bytearray_setuint32_be(bytearray: Pointer, byteOffset: Int, value: hl.I64) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setfloat32_be") static function kinc_bytearray_setfloat32_be(bytearray: Pointer, byteOffset: Int, value: FastFloat) {}
|
||||
|
||||
@:hlNative("std", "kinc_bytearray_setfloat64_be") static function kinc_bytearray_setfloat64_be(bytearray: Pointer, byteOffset: Int, value: Float) {}
|
||||
}
|
21
Kha/Backends/Kinc-HL/kha/arrays/ByteBuffer.hx
Normal file
21
Kha/Backends/Kinc-HL/kha/arrays/ByteBuffer.hx
Normal file
@ -0,0 +1,21 @@
|
||||
package kha.arrays;
|
||||
|
||||
abstract ByteBuffer(Pointer) from Pointer to Pointer {
|
||||
function new(bytearray: Pointer) {
|
||||
this = bytearray;
|
||||
}
|
||||
|
||||
public static function create(length: Int): ByteBuffer {
|
||||
return new ByteBuffer(kinc_bytebuffer_alloc(length));
|
||||
}
|
||||
|
||||
public function free() {
|
||||
kinc_bytebuffer_free(this);
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytebuffer_alloc") static function kinc_bytebuffer_alloc(elements: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_bytebuffer_free") static function kinc_bytebuffer_free(bytearray: Pointer) {}
|
||||
}
|
3
Kha/Backends/Kinc-HL/kha/audio1/Audio.hx
Normal file
3
Kha/Backends/Kinc-HL/kha/audio1/Audio.hx
Normal file
@ -0,0 +1,3 @@
|
||||
package kha.audio1;
|
||||
|
||||
typedef Audio = kha.audio2.Audio1;
|
52
Kha/Backends/Kinc-HL/kha/audio2/Audio.hx
Normal file
52
Kha/Backends/Kinc-HL/kha/audio2/Audio.hx
Normal file
@ -0,0 +1,52 @@
|
||||
package kha.audio2;
|
||||
|
||||
import kha.Sound;
|
||||
import kha.internal.IntBox;
|
||||
|
||||
class Audio {
|
||||
public static var disableGcInteractions = false;
|
||||
static var intBox: IntBox = new IntBox(0);
|
||||
static var buffer: Buffer;
|
||||
|
||||
public static function _init() {
|
||||
var bufferSize = 1024 * 2;
|
||||
buffer = new Buffer(bufferSize * 4, 2, samplesPerSecond);
|
||||
}
|
||||
|
||||
public static function _callCallback(samples: Int): Void {
|
||||
if (buffer == null)
|
||||
return;
|
||||
if (audioCallback != null) {
|
||||
intBox.value = samples;
|
||||
audioCallback(intBox, buffer);
|
||||
}
|
||||
else {
|
||||
for (i in 0...samples) {
|
||||
buffer.data.set(buffer.writeLocation, 0);
|
||||
buffer.writeLocation += 1;
|
||||
if (buffer.writeLocation >= buffer.size) {
|
||||
buffer.writeLocation = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function _readSample(): FastFloat {
|
||||
if (buffer == null)
|
||||
return 0;
|
||||
var value: FastFloat = buffer.data.get(buffer.readLocation);
|
||||
++buffer.readLocation;
|
||||
if (buffer.readLocation >= buffer.size) {
|
||||
buffer.readLocation = 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static var samplesPerSecond: Int;
|
||||
|
||||
public static var audioCallback: IntBox->Buffer->Void;
|
||||
|
||||
public static function stream(sound: Sound, loop: Bool = false): kha.audio1.AudioChannel {
|
||||
return null;
|
||||
}
|
||||
}
|
90
Kha/Backends/Kinc-HL/kha/audio2/StreamChannel.hx
Normal file
90
Kha/Backends/Kinc-HL/kha/audio2/StreamChannel.hx
Normal file
@ -0,0 +1,90 @@
|
||||
package kha.audio2;
|
||||
|
||||
import haxe.ds.Vector;
|
||||
import haxe.io.Bytes;
|
||||
|
||||
class StreamChannel implements kha.audio1.AudioChannel {
|
||||
var _vorbis: Pointer;
|
||||
var atend: Bool = false;
|
||||
@:keep var loop: Bool;
|
||||
var myVolume: Float;
|
||||
var paused: Bool = false;
|
||||
|
||||
public function new(data: Bytes, loop: Bool) {
|
||||
myVolume = 1;
|
||||
this.loop = loop;
|
||||
_vorbis = kinc_sound_init_vorbis(data.getData().bytes, data.length);
|
||||
}
|
||||
|
||||
public function nextSamples(samples: kha.arrays.Float32Array, length: Int, sampleRate: Int): Void {
|
||||
if (paused) {
|
||||
for (i in 0...length) {
|
||||
samples[i] = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
atend = kinc_sound_next_vorbis_samples(_vorbis, samples.getData(), length, loop, atend);
|
||||
}
|
||||
|
||||
public function play(): Void {
|
||||
paused = false;
|
||||
}
|
||||
|
||||
public function pause(): Void {
|
||||
paused = true;
|
||||
}
|
||||
|
||||
public function stop(): Void {
|
||||
atend = true;
|
||||
}
|
||||
|
||||
public var length(get, never): Float; // Seconds
|
||||
|
||||
function get_length(): Float {
|
||||
return kinc_sound_vorbis_get_length(_vorbis);
|
||||
}
|
||||
|
||||
public var position(get, set): Float; // Seconds
|
||||
|
||||
function get_position(): Float {
|
||||
return kinc_sound_vorbis_get_position(_vorbis);
|
||||
}
|
||||
|
||||
function set_position(value: Float): Float {
|
||||
return value;
|
||||
}
|
||||
|
||||
public var volume(get, set): Float;
|
||||
|
||||
function get_volume(): Float {
|
||||
return myVolume;
|
||||
}
|
||||
|
||||
function set_volume(value: Float): Float {
|
||||
return myVolume = value;
|
||||
}
|
||||
|
||||
public var finished(get, never): Bool;
|
||||
|
||||
function get_finished(): Bool {
|
||||
return atend;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_sound_init_vorbis") static function kinc_sound_init_vorbis(data: Pointer, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_sound_next_vorbis_samples") static function kinc_sound_next_vorbis_samples(vorbis: Pointer, samples: Pointer, length: Int,
|
||||
loop: Bool, atend: Bool): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_sound_vorbis_get_length") static function kinc_sound_vorbis_get_length(vorbis: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_sound_vorbis_get_position") static function kinc_sound_vorbis_get_position(vorbis: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
}
|
171
Kha/Backends/Kinc-HL/kha/compute/Compute.hx
Normal file
171
Kha/Backends/Kinc-HL/kha/compute/Compute.hx
Normal file
@ -0,0 +1,171 @@
|
||||
package kha.compute;
|
||||
|
||||
import kha.arrays.Float32Array;
|
||||
import kha.Image;
|
||||
import kha.FastFloat;
|
||||
import kha.math.FastMatrix3;
|
||||
import kha.math.FastMatrix4;
|
||||
import kha.math.FastVector2;
|
||||
import kha.math.FastVector3;
|
||||
import kha.math.FastVector4;
|
||||
import kha.graphics4.CubeMap;
|
||||
import kha.graphics4.TextureAddressing;
|
||||
import kha.graphics4.TextureFilter;
|
||||
import kha.graphics4.MipMapFilter;
|
||||
|
||||
class Compute {
|
||||
public static function setBool(location: kha.compute.ConstantLocation, value: Bool): Void {
|
||||
kinc_compute_set_bool(location._location, value);
|
||||
}
|
||||
|
||||
public static function setInt(location: kha.compute.ConstantLocation, value: Int): Void {
|
||||
kinc_compute_set_int(location._location, value);
|
||||
}
|
||||
|
||||
public static function setFloat(location: kha.compute.ConstantLocation, value: FastFloat): Void {
|
||||
kinc_compute_set_float(location._location, value);
|
||||
}
|
||||
|
||||
public static function setFloat2(location: kha.compute.ConstantLocation, value1: FastFloat, value2: FastFloat): Void {
|
||||
kinc_compute_set_float2(location._location, value1, value2);
|
||||
}
|
||||
|
||||
public static function setFloat3(location: kha.compute.ConstantLocation, value1: FastFloat, value2: FastFloat, value3: FastFloat): Void {
|
||||
kinc_compute_set_float3(location._location, value1, value2, value3);
|
||||
}
|
||||
|
||||
public static function setFloat4(location: kha.compute.ConstantLocation, value1: FastFloat, value2: FastFloat, value3: FastFloat,
|
||||
value4: FastFloat): Void {
|
||||
kinc_compute_set_float4(location._location, value1, value2, value3, value4);
|
||||
}
|
||||
|
||||
public static function setVector2(location: kha.compute.ConstantLocation, value: FastVector2): Void {
|
||||
kinc_compute_set_float2(location._location, value.x, value.y);
|
||||
}
|
||||
|
||||
public static function setVector3(location: kha.compute.ConstantLocation, value: FastVector3): Void {
|
||||
kinc_compute_set_float3(location._location, value.x, value.y, value.z);
|
||||
}
|
||||
|
||||
public static function setVector4(location: kha.compute.ConstantLocation, value: FastVector4): Void {
|
||||
kinc_compute_set_float4(location._location, value.x, value.y, value.z, value.w);
|
||||
}
|
||||
|
||||
public static function setFloats(location: kha.compute.ConstantLocation, values: Float32Array): Void {
|
||||
kinc_compute_set_floats(location._location, values.getData(), values.length);
|
||||
}
|
||||
|
||||
public static function setMatrix(location: kha.compute.ConstantLocation, matrix: FastMatrix4): Void {
|
||||
kinc_compute_set_matrix(location._location, matrix._00, matrix._10, matrix._20, matrix._30, matrix._01, matrix._11, matrix._21, matrix._31,
|
||||
matrix._02, matrix._12, matrix._22, matrix._32, matrix._03, matrix._13, matrix._23, matrix._33);
|
||||
}
|
||||
|
||||
public static function setMatrix3(location: kha.compute.ConstantLocation, matrix: FastMatrix3): Void {
|
||||
kinc_compute_set_matrix3(location._location, matrix._00, matrix._10, matrix._20, matrix._01, matrix._11, matrix._21, matrix._02, matrix._12,
|
||||
matrix._22);
|
||||
}
|
||||
|
||||
public static function setBuffer(buffer: ShaderStorageBuffer, index: Int) {
|
||||
// Kore::Compute::setBuffer(buffer->buffer, index);
|
||||
}
|
||||
|
||||
public static function setTexture(unit: TextureUnit, texture: Image, access: Access) {
|
||||
if (texture._texture != null)
|
||||
kinc_compute_set_texture(unit._unit, texture._texture, access);
|
||||
else
|
||||
kinc_compute_set_target(unit._unit, texture._renderTarget, access);
|
||||
}
|
||||
|
||||
public static function setSampledTexture(unit: TextureUnit, texture: Image) {
|
||||
if (texture._texture != null)
|
||||
kinc_compute_set_sampled_texture(unit._unit, texture._texture);
|
||||
else
|
||||
kinc_compute_set_sampled_target(unit._unit, texture._renderTarget);
|
||||
}
|
||||
|
||||
public static function setSampledDepthTexture(unit: TextureUnit, texture: Image) {
|
||||
kinc_compute_set_sampled_depth_target(unit._unit, texture._renderTarget);
|
||||
}
|
||||
|
||||
public static function setSampledCubeMap(unit: TextureUnit, cubeMap: CubeMap) {
|
||||
if (cubeMap._texture != null)
|
||||
kinc_compute_set_sampled_cubemap_texture(unit._unit, cubeMap._texture);
|
||||
else
|
||||
kinc_compute_set_sampled_cubemap_target(unit._unit, cubeMap._renderTarget);
|
||||
}
|
||||
|
||||
public static function setSampledDepthCubeMap(unit: TextureUnit, cubeMap: CubeMap) {
|
||||
kinc_compute_set_sampled_cubemap_depth_target(unit._unit, cubeMap._renderTarget);
|
||||
}
|
||||
|
||||
public static function setTextureParameters(unit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing,
|
||||
minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void {
|
||||
kinc_compute_set_texture_parameters(unit._unit, uAddressing, vAddressing, minificationFilter, magnificationFilter, mipmapFilter);
|
||||
}
|
||||
|
||||
public static function setTexture3DParameters(unit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing,
|
||||
wAddressing: TextureAddressing, minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void {
|
||||
kinc_compute_set_texture3d_parameters(unit._unit, uAddressing, vAddressing, wAddressing, minificationFilter, magnificationFilter, mipmapFilter);
|
||||
}
|
||||
|
||||
public static function setShader(shader: Shader) {
|
||||
kinc_compute_set_shader(shader._shader);
|
||||
}
|
||||
|
||||
public static function compute(x: Int, y: Int, z: Int) {
|
||||
kinc_compute_compute(x, y, z);
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_bool") static function kinc_compute_set_bool(location: Pointer, value: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_int") static function kinc_compute_set_int(location: Pointer, value: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_float") static function kinc_compute_set_float(location: Pointer, value: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_float2") static function kinc_compute_set_float2(location: Pointer, value1: FastFloat, value2: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_float3") static function kinc_compute_set_float3(location: Pointer, value1: FastFloat, value2: FastFloat,
|
||||
value3: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_float4") static function kinc_compute_set_float4(location: Pointer, value1: FastFloat, value2: FastFloat,
|
||||
value3: FastFloat, value4: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_floats") static function kinc_compute_set_floats(location: Pointer, values: Pointer, count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_matrix") static function kinc_compute_set_matrix(location: Pointer, _00: FastFloat, _10: FastFloat, _20: FastFloat,
|
||||
_30: FastFloat, _01: FastFloat, _11: FastFloat, _21: FastFloat, _31: FastFloat, _02: FastFloat, _12: FastFloat, _22: FastFloat, _32: FastFloat,
|
||||
_03: FastFloat, _13: FastFloat, _23: FastFloat, _33: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_matrix3") static function kinc_compute_set_matrix3(location: Pointer, _00: FastFloat, _10: FastFloat, _20: FastFloat,
|
||||
_01: FastFloat, _11: FastFloat, _21: FastFloat, _02: FastFloat, _12: FastFloat, _22: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_texture") static function kinc_compute_set_texture(unit: Pointer, texture: Pointer, access: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_target") static function kinc_compute_set_target(unit: Pointer, renderTarget: Pointer, access: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_sampled_texture") static function kinc_compute_set_sampled_texture(unit: Pointer, texture: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_sampled_target") static function kinc_compute_set_sampled_target(unit: Pointer, renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_sampled_depth_target") static function kinc_compute_set_sampled_depth_target(unit: Pointer,
|
||||
renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_sampled_cubemap_texture") static function kinc_compute_set_sampled_cubemap_texture(unit: Pointer,
|
||||
texture: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_sampled_cubemap_target") static function kinc_compute_set_sampled_cubemap_target(unit: Pointer,
|
||||
renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_sampled_cubemap_depth_target") static function kinc_compute_set_sampled_cubemap_depth_target(unit: Pointer,
|
||||
renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_texture_parameters") static function kinc_compute_set_texture_parameters(unit: Pointer, uAddressing: Int,
|
||||
vAddressing: Int, minificationFilter: Int, magnificationFilter: Int, mipmapFilter: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_texture3d_parameters") static function kinc_compute_set_texture3d_parameters(unit: Pointer, uAddressing: Int,
|
||||
vAddressing: Int, wAddressing: Int, minificationFilter: Int, magnificationFilter: Int, mipmapFilter: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_set_shader") static function kinc_compute_set_shader(shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_compute") static function kinc_compute_compute(x: Int, y: Int, z: Int): Void {}
|
||||
}
|
9
Kha/Backends/Kinc-HL/kha/compute/ConstantLocation.hx
Normal file
9
Kha/Backends/Kinc-HL/kha/compute/ConstantLocation.hx
Normal file
@ -0,0 +1,9 @@
|
||||
package kha.compute;
|
||||
|
||||
class ConstantLocation {
|
||||
public var _location: Pointer;
|
||||
|
||||
public function new(location: Pointer) {
|
||||
_location = location;
|
||||
}
|
||||
}
|
37
Kha/Backends/Kinc-HL/kha/compute/Shader.hx
Normal file
37
Kha/Backends/Kinc-HL/kha/compute/Shader.hx
Normal file
@ -0,0 +1,37 @@
|
||||
package kha.compute;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
class Shader {
|
||||
public var _shader: Pointer;
|
||||
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {
|
||||
_shader = kinc_compute_create_shader(sources[0].bytes.getData(), sources[0].bytes.getData().length);
|
||||
}
|
||||
|
||||
public function delete(): Void {
|
||||
kinc_compute_delete_shader(_shader);
|
||||
}
|
||||
|
||||
public function getConstantLocation(name: String): ConstantLocation {
|
||||
return new ConstantLocation(kinc_compute_get_constantlocation(_shader, StringHelper.convert(name)));
|
||||
}
|
||||
|
||||
public function getTextureUnit(name: String): TextureUnit {
|
||||
return new TextureUnit(kinc_compute_get_textureunit(_shader, StringHelper.convert(name)));
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_compute_create_shader") static function kinc_compute_create_shader(data: hl.Bytes, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_compute_delete_shader") static function kinc_compute_delete_shader(shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_compute_get_constantlocation") static function kinc_compute_get_constantlocation(shader: Pointer, name: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_compute_get_textureunit") static function kinc_compute_get_textureunit(shader: Pointer, name: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
26
Kha/Backends/Kinc-HL/kha/compute/ShaderStorageBuffer.hx
Normal file
26
Kha/Backends/Kinc-HL/kha/compute/ShaderStorageBuffer.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package kha.compute;
|
||||
|
||||
import kha.graphics4.VertexData;
|
||||
|
||||
class ShaderStorageBuffer {
|
||||
public var _buffer: Pointer;
|
||||
|
||||
var data: Array<Int>;
|
||||
var myCount: Int;
|
||||
|
||||
public function new(indexCount: Int, type: VertexData) {}
|
||||
|
||||
function init(indexCount: Int, type: VertexData) {}
|
||||
|
||||
public function delete(): Void {}
|
||||
|
||||
public function lock(): Array<Int> {
|
||||
return data;
|
||||
}
|
||||
|
||||
public function unlock(): Void {}
|
||||
|
||||
public function count(): Int {
|
||||
return myCount;
|
||||
}
|
||||
}
|
9
Kha/Backends/Kinc-HL/kha/compute/TextureUnit.hx
Normal file
9
Kha/Backends/Kinc-HL/kha/compute/TextureUnit.hx
Normal file
@ -0,0 +1,9 @@
|
||||
package kha.compute;
|
||||
|
||||
class TextureUnit {
|
||||
public var _unit: Pointer;
|
||||
|
||||
public function new(unit: Pointer) {
|
||||
_unit = unit;
|
||||
}
|
||||
}
|
143
Kha/Backends/Kinc-HL/kha/graphics4/CubeMap.hx
Normal file
143
Kha/Backends/Kinc-HL/kha/graphics4/CubeMap.hx
Normal file
@ -0,0 +1,143 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
class CubeMap implements Canvas implements Resource {
|
||||
public var _texture: Pointer;
|
||||
public var _renderTarget: Pointer;
|
||||
|
||||
var format: TextureFormat;
|
||||
var graphics4: kha.graphics4.Graphics;
|
||||
|
||||
function new() {}
|
||||
|
||||
public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap {
|
||||
return create2(size, format == null ? TextureFormat.RGBA32 : format, false, true, depthStencil);
|
||||
}
|
||||
|
||||
public static function create2(size: Int, format: TextureFormat, readable: Bool, renderTarget: Bool, depthStencil: DepthStencilFormat): CubeMap {
|
||||
var cubeMap = new CubeMap();
|
||||
cubeMap.format = format;
|
||||
if (renderTarget)
|
||||
cubeMap.initRenderTarget(size, getDepthBufferBits(depthStencil), getRenderTargetFormat(format), getStencilBufferBits(depthStencil));
|
||||
return cubeMap;
|
||||
}
|
||||
|
||||
function initRenderTarget(cubeMapSize: Int, depthBufferBits: Int, format: Int, stencilBufferBits: Int): Void {
|
||||
_renderTarget = kinc_cubemap_create(cubeMapSize, depthBufferBits, format, stencilBufferBits);
|
||||
_texture = null;
|
||||
}
|
||||
|
||||
static function getRenderTargetFormat(format: TextureFormat): Int {
|
||||
switch (format) {
|
||||
case RGBA32: // Target32Bit
|
||||
return 0;
|
||||
case RGBA64: // Target64BitFloat
|
||||
return 1;
|
||||
case RGBA128: // Target128BitFloat
|
||||
return 3;
|
||||
case DEPTH16: // Target16BitDepth
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static function getDepthBufferBits(depthAndStencil: DepthStencilFormat): Int {
|
||||
return switch (depthAndStencil) {
|
||||
case NoDepthAndStencil: -1;
|
||||
case DepthOnly: 24;
|
||||
case DepthAutoStencilAuto: 24;
|
||||
case Depth24Stencil8: 24;
|
||||
case Depth32Stencil8: 32;
|
||||
case Depth16: 16;
|
||||
}
|
||||
}
|
||||
|
||||
static function getStencilBufferBits(depthAndStencil: DepthStencilFormat): Int {
|
||||
return switch (depthAndStencil) {
|
||||
case NoDepthAndStencil: -1;
|
||||
case DepthOnly: -1;
|
||||
case DepthAutoStencilAuto: 8;
|
||||
case Depth24Stencil8: 8;
|
||||
case Depth32Stencil8: 8;
|
||||
case Depth16: 0;
|
||||
}
|
||||
}
|
||||
|
||||
static function getTextureFormat(format: TextureFormat): Int {
|
||||
switch (format) {
|
||||
case RGBA32:
|
||||
return 0;
|
||||
case RGBA128:
|
||||
return 3;
|
||||
case RGBA64:
|
||||
return 4;
|
||||
case A32:
|
||||
return 5;
|
||||
default:
|
||||
return 1; // Grey 8
|
||||
}
|
||||
}
|
||||
|
||||
public function unload(): Void {}
|
||||
|
||||
public function lock(level: Int = 0): Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function unlock(): Void {}
|
||||
|
||||
public var width(get, never): Int;
|
||||
public var height(get, never): Int;
|
||||
|
||||
function get_width(): Int {
|
||||
return _texture != null ? kinc_cubemap_texture_get_width(_texture) : kinc_cubemap_target_get_width(_renderTarget);
|
||||
}
|
||||
|
||||
function get_height(): Int {
|
||||
return _texture != null ? kinc_cubemap_texture_get_height(_texture) : kinc_cubemap_target_get_height(_renderTarget);
|
||||
}
|
||||
|
||||
public var g1(get, never): kha.graphics1.Graphics;
|
||||
|
||||
function get_g1(): kha.graphics1.Graphics {
|
||||
return null;
|
||||
}
|
||||
|
||||
public var g2(get, never): kha.graphics2.Graphics;
|
||||
|
||||
function get_g2(): kha.graphics2.Graphics {
|
||||
return null;
|
||||
}
|
||||
|
||||
public var g4(get, never): kha.graphics4.Graphics;
|
||||
|
||||
function get_g4(): kha.graphics4.Graphics {
|
||||
if (graphics4 == null) {
|
||||
graphics4 = new kha.korehl.graphics4.Graphics(this);
|
||||
}
|
||||
return graphics4;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_cubemap_create") static function kinc_cubemap_create(cubeMapSize: Int, depthBufferBits: Int, format: Int,
|
||||
stencilBufferBits: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_cubemap_texture_get_width") static function kinc_cubemap_texture_get_width(texture: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_cubemap_texture_get_height") static function kinc_cubemap_texture_get_height(texture: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_cubemap_target_get_width") static function kinc_cubemap_target_get_width(target: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_cubemap_target_get_height") static function kinc_cubemap_target_get_height(target: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
}
|
31
Kha/Backends/Kinc-HL/kha/graphics4/FragmentShader.hx
Normal file
31
Kha/Backends/Kinc-HL/kha/graphics4/FragmentShader.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
class FragmentShader {
|
||||
public var _shader: Pointer;
|
||||
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {
|
||||
initShader(sources[0]);
|
||||
}
|
||||
|
||||
function initShader(source: Blob): Void {
|
||||
_shader = kinc_create_fragmentshader(source.bytes.getData(), source.bytes.getData().length);
|
||||
}
|
||||
|
||||
public static function fromSource(source: String): FragmentShader {
|
||||
var sh = new FragmentShader(null, null);
|
||||
sh._shader = kinc_fragmentshader_from_source(StringHelper.convert(source));
|
||||
return sh;
|
||||
}
|
||||
|
||||
public function delete(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_create_fragmentshader") static function kinc_create_fragmentshader(data: hl.Bytes, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_fragmentshader_from_source") static function kinc_fragmentshader_from_source(source: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
31
Kha/Backends/Kinc-HL/kha/graphics4/GeometryShader.hx
Normal file
31
Kha/Backends/Kinc-HL/kha/graphics4/GeometryShader.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
class GeometryShader {
|
||||
public var _shader: Pointer;
|
||||
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {
|
||||
initShader(sources[0]);
|
||||
}
|
||||
|
||||
function initShader(source: Blob): Void {
|
||||
_shader = kinc_create_geometryshader(source.bytes.getData(), source.bytes.getData().length);
|
||||
}
|
||||
|
||||
public static function fromSource(source: String): GeometryShader {
|
||||
var sh = new GeometryShader(null, null);
|
||||
sh._shader = kinc_geometryshader_from_source(StringHelper.convert(source));
|
||||
return sh;
|
||||
}
|
||||
|
||||
public function delete(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_create_geometryshader") static function kinc_create_geometryshader(data: hl.Bytes, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_geometryshader_from_source") static function kinc_geometryshader_from_source(source: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
49
Kha/Backends/Kinc-HL/kha/graphics4/IndexBuffer.hx
Normal file
49
Kha/Backends/Kinc-HL/kha/graphics4/IndexBuffer.hx
Normal file
@ -0,0 +1,49 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import haxe.io.BytesData;
|
||||
|
||||
class IndexBuffer {
|
||||
public var _buffer: Pointer;
|
||||
|
||||
var myCount: Int;
|
||||
|
||||
public function new(indexCount: Int, usage: Usage, canRead: Bool = false) {
|
||||
myCount = indexCount;
|
||||
_buffer = kinc_create_indexbuffer(indexCount);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
kinc_delete_indexbuffer(_buffer);
|
||||
}
|
||||
|
||||
public function lock(?start: Int, ?count: Int): kha.arrays.Uint32Array {
|
||||
if (start == null)
|
||||
start = 0;
|
||||
if (count == null)
|
||||
count = this.count();
|
||||
return cast new kha.arrays.ByteArray(kinc_indexbuffer_lock(_buffer, start, count), 0, count * 4);
|
||||
}
|
||||
|
||||
public function unlock(?count: Int): Void {
|
||||
if (count == null)
|
||||
count = this.count();
|
||||
kinc_indexbuffer_unlock(_buffer, count);
|
||||
}
|
||||
|
||||
public function count(): Int {
|
||||
return myCount;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_create_indexbuffer") static function kinc_create_indexbuffer(count: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_delete_indexbuffer") static function kinc_delete_indexbuffer(buffer: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_indexbuffer_lock") static function kinc_indexbuffer_lock(buffer: Pointer, start: Int, count: Int): hl.Bytes {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_indexbuffer_unlock") static function kinc_indexbuffer_unlock(buffer: Pointer, count: Int): Void {}
|
||||
}
|
168
Kha/Backends/Kinc-HL/kha/graphics4/PipelineState.hx
Normal file
168
Kha/Backends/Kinc-HL/kha/graphics4/PipelineState.hx
Normal file
@ -0,0 +1,168 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.graphics4.FragmentShader;
|
||||
import kha.graphics4.VertexData;
|
||||
import kha.graphics4.VertexElement;
|
||||
import kha.graphics4.VertexShader;
|
||||
import kha.graphics4.VertexStructure;
|
||||
|
||||
class PipelineState extends PipelineStateBase {
|
||||
var _pipeline: Pointer;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
init();
|
||||
}
|
||||
|
||||
function init(): Void {
|
||||
_pipeline = kinc_create_pipeline();
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
kinc_delete_pipeline(_pipeline);
|
||||
}
|
||||
|
||||
function linkWithStructures2(structure0: VertexStructure, structure1: VertexStructure, structure2: VertexStructure, structure3: VertexStructure,
|
||||
count: Int): Void {
|
||||
kinc_pipeline_set_vertex_shader(_pipeline, vertexShader._shader);
|
||||
kinc_pipeline_set_fragment_shader(_pipeline, fragmentShader._shader);
|
||||
if (geometryShader != null)
|
||||
kinc_pipeline_set_geometry_shader(_pipeline, geometryShader._shader);
|
||||
if (tessellationControlShader != null)
|
||||
kinc_pipeline_set_tesscontrol_shader(_pipeline, tessellationControlShader._shader);
|
||||
if (tessellationEvaluationShader != null)
|
||||
kinc_pipeline_set_tesseval_shader(_pipeline, tessellationEvaluationShader._shader);
|
||||
|
||||
var structures = [structure0, structure1, structure2, structure3];
|
||||
var kinc_structures: Array<Pointer> = [];
|
||||
|
||||
for (i in 0...count) {
|
||||
var kinc_structure = VertexBuffer.kinc_create_vertexstructure(structures[i].instanced);
|
||||
kinc_structures.push(kinc_structure);
|
||||
for (j in 0...structures[i].size()) {
|
||||
var vertexElement = structures[i].get(j);
|
||||
VertexBuffer.kinc_vertexstructure_add(kinc_structure, StringHelper.convert(vertexElement.name),
|
||||
VertexBuffer.convertVertexDataToKinc(vertexElement.data));
|
||||
}
|
||||
}
|
||||
|
||||
kinc_pipeline_compile(_pipeline, kinc_structures[0], count > 1 ? kinc_structures[1] : null, count > 2 ? kinc_structures[2] : null,
|
||||
count > 3 ? kinc_structures[3] : null);
|
||||
}
|
||||
|
||||
static function getDepthBufferBits(depthAndStencil: DepthStencilFormat): Int {
|
||||
return switch (depthAndStencil) {
|
||||
case NoDepthAndStencil: 0;
|
||||
case DepthOnly: 24;
|
||||
case DepthAutoStencilAuto: 24;
|
||||
case Depth24Stencil8: 24;
|
||||
case Depth32Stencil8: 32;
|
||||
case Depth16: 16;
|
||||
}
|
||||
}
|
||||
|
||||
static function getStencilBufferBits(depthAndStencil: DepthStencilFormat): Int {
|
||||
return switch (depthAndStencil) {
|
||||
case NoDepthAndStencil: 0;
|
||||
case DepthOnly: 0;
|
||||
case DepthAutoStencilAuto: 8;
|
||||
case Depth24Stencil8: 8;
|
||||
case Depth32Stencil8: 8;
|
||||
case Depth16: 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function compile(): Void {
|
||||
var stencilReferenceValue = 0;
|
||||
switch (this.stencilReferenceValue) {
|
||||
case Static(value):
|
||||
stencilReferenceValue = value;
|
||||
default:
|
||||
}
|
||||
kinc_pipeline_set_states(_pipeline, cullMode, depthMode, stencilFrontMode, stencilFrontBothPass, stencilFrontDepthFail, stencilFrontFail,
|
||||
stencilBackMode, stencilBackBothPass, stencilBackDepthFail, stencilBackFail, getBlendFunc(blendSource), getBlendFunc(blendDestination),
|
||||
getBlendFunc(alphaBlendSource), getBlendFunc(alphaBlendDestination), depthWrite, stencilReferenceValue, stencilReadMask, stencilWriteMask,
|
||||
colorWriteMaskRed, colorWriteMaskGreen, colorWriteMaskBlue, colorWriteMaskAlpha, colorAttachmentCount, colorAttachments[0], colorAttachments[1],
|
||||
colorAttachments[2], colorAttachments[3], colorAttachments[4], colorAttachments[5], colorAttachments[6], colorAttachments[7],
|
||||
getDepthBufferBits(depthStencilAttachment), getStencilBufferBits(depthStencilAttachment), conservativeRasterization);
|
||||
linkWithStructures2(inputLayout.length > 0 ? inputLayout[0] : null, inputLayout.length > 1 ? inputLayout[1] : null,
|
||||
inputLayout.length > 2 ? inputLayout[2] : null, inputLayout.length > 3 ? inputLayout[3] : null, inputLayout.length);
|
||||
}
|
||||
|
||||
public function getConstantLocation(name: String): kha.graphics4.ConstantLocation {
|
||||
return new kha.korehl.graphics4.ConstantLocation(kinc_pipeline_get_constantlocation(_pipeline, StringHelper.convert(name)));
|
||||
}
|
||||
|
||||
public function getTextureUnit(name: String): kha.graphics4.TextureUnit {
|
||||
return new kha.korehl.graphics4.TextureUnit(kinc_pipeline_get_textureunit(_pipeline, StringHelper.convert(name)));
|
||||
}
|
||||
|
||||
static function getBlendFunc(factor: BlendingFactor): Int {
|
||||
switch (factor) {
|
||||
case BlendOne, Undefined:
|
||||
return 0;
|
||||
case BlendZero:
|
||||
return 1;
|
||||
case SourceAlpha:
|
||||
return 2;
|
||||
case DestinationAlpha:
|
||||
return 3;
|
||||
case InverseSourceAlpha:
|
||||
return 4;
|
||||
case InverseDestinationAlpha:
|
||||
return 5;
|
||||
case SourceColor:
|
||||
return 6;
|
||||
case DestinationColor:
|
||||
return 7;
|
||||
case InverseSourceColor:
|
||||
return 8;
|
||||
case InverseDestinationColor:
|
||||
return 9;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function set(): Void {
|
||||
kinc_pipeline_set(_pipeline);
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_create_pipeline") static function kinc_create_pipeline(): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_delete_pipeline") static function kinc_delete_pipeline(pipeline: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set_fragment_shader") static function kinc_pipeline_set_fragment_shader(pipeline: Pointer, shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set_vertex_shader") static function kinc_pipeline_set_vertex_shader(pipeline: Pointer, shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set_geometry_shader") static function kinc_pipeline_set_geometry_shader(pipeline: Pointer, shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set_tesscontrol_shader") static function kinc_pipeline_set_tesscontrol_shader(pipeline: Pointer, shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set_tesseval_shader") static function kinc_pipeline_set_tesseval_shader(pipeline: Pointer, shader: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_compile") static function kinc_pipeline_compile(pipeline: Pointer, structure0: Pointer, structure1: Pointer,
|
||||
structure2: Pointer, structure3: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_get_constantlocation") static function kinc_pipeline_get_constantlocation(pipeline: Pointer, name: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_get_textureunit") static function kinc_pipeline_get_textureunit(pipeline: Pointer, name: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set_states") static function kinc_pipeline_set_states(pipeline: Pointer, cullMode: Int, depthMode: Int,
|
||||
stencilFrontMode: Int, stencilFrontBothPass: Int, stencilFrontDepthFail: Int, stencilFrontFail: Int, stencilBackMode: Int, stencilBackBothPass: Int,
|
||||
stencilBackDepthFail: Int, stencilBackFail: Int, blendSource: Int, blendDestination: Int, alphaBlendSource: Int, alphaBlendDestination: Int,
|
||||
depthWrite: Bool, stencilReferenceValue: Int, stencilReadMask: Int, stencilWriteMask: Int, colorWriteMaskRed: Bool, colorWriteMaskGreen: Bool,
|
||||
colorWriteMaskBlue: Bool, colorWriteMaskAlpha: Bool, colorAttachmentCount: Int, colorAttachment0: TextureFormat, colorAttachment1: TextureFormat,
|
||||
colorAttachment2: TextureFormat, colorAttachment3: TextureFormat, colorAttachment4: TextureFormat, colorAttachment5: TextureFormat,
|
||||
colorAttachment6: TextureFormat, colorAttachment7: TextureFormat, depthAttachmentBits: Int, stencilAttachmentBits: Int,
|
||||
conservativeRasterization: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_pipeline_set") static function kinc_pipeline_set(pipeline: Pointer): Void {}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import kha.Blob;
|
||||
|
||||
class TessellationControlShader {
|
||||
public var _shader: Pointer;
|
||||
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {
|
||||
initShader(sources[0]);
|
||||
}
|
||||
|
||||
function initShader(source: Blob): Void {
|
||||
_shader = kinc_create_tesscontrolshader(source.bytes.getData(), source.bytes.getData().length);
|
||||
}
|
||||
|
||||
public static function fromSource(source: String): TessellationControlShader {
|
||||
var sh = new TessellationControlShader(null, null);
|
||||
sh._shader = kinc_tesscontrolshader_from_source(StringHelper.convert(source));
|
||||
return sh;
|
||||
}
|
||||
|
||||
public function delete(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_create_tesscontrolshader") static function kinc_create_tesscontrolshader(data: hl.Bytes, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_tesscontrolshader_from_source") static function kinc_tesscontrolshader_from_source(source: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
class TessellationEvaluationShader {
|
||||
public var _shader: Pointer;
|
||||
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {
|
||||
initShader(sources[0]);
|
||||
}
|
||||
|
||||
function initShader(source: Blob): Void {
|
||||
_shader = kinc_create_tessevalshader(source.bytes.getData(), source.bytes.getData().length);
|
||||
}
|
||||
|
||||
public static function fromSource(source: String): TessellationEvaluationShader {
|
||||
var sh = new TessellationEvaluationShader(null, null);
|
||||
sh._shader = kinc_tessevalshader_from_source(StringHelper.convert(source));
|
||||
return sh;
|
||||
}
|
||||
|
||||
public function delete(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_create_tessevalshader") static function kinc_create_tessevalshader(data: hl.Bytes, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_tessevalshader_from_source") static function kinc_tessevalshader_from_source(source: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
115
Kha/Backends/Kinc-HL/kha/graphics4/VertexBuffer.hx
Normal file
115
Kha/Backends/Kinc-HL/kha/graphics4/VertexBuffer.hx
Normal file
@ -0,0 +1,115 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.arrays.ByteArray;
|
||||
import kha.arrays.Float32Array;
|
||||
import kha.arrays.Int16Array;
|
||||
import kha.graphics4.VertexData;
|
||||
import kha.graphics4.VertexElement;
|
||||
import kha.graphics4.VertexStructure;
|
||||
|
||||
class VertexBuffer {
|
||||
public var _buffer: Pointer;
|
||||
|
||||
public function new(vertexCount: Int, structure: VertexStructure, usage: Usage, instanceDataStepRate: Int = 0, canRead: Bool = false) {
|
||||
var structure2 = kinc_create_vertexstructure(structure.instanced);
|
||||
for (i in 0...structure.size()) {
|
||||
var vertexElement = structure.get(i);
|
||||
kinc_vertexstructure_add(structure2, StringHelper.convert(vertexElement.name), convertVertexDataToKinc(vertexElement.data));
|
||||
}
|
||||
_buffer = kinc_create_vertexbuffer(vertexCount, structure2, usage, instanceDataStepRate);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
kinc_delete_vertexbuffer(_buffer);
|
||||
}
|
||||
|
||||
public function lock(?start: Int, ?count: Int): Float32Array {
|
||||
return cast new ByteArray(kinc_vertexbuffer_lock(_buffer), 0, this.count() * stride());
|
||||
}
|
||||
|
||||
public function lockInt16(?start: Int, ?count: Int): Int16Array {
|
||||
return cast new ByteArray(kinc_vertexbuffer_lock(_buffer), 0, this.count() * stride());
|
||||
}
|
||||
|
||||
public function unlock(?count: Int): Void {
|
||||
kinc_vertexbuffer_unlock(_buffer, count == null ? this.count() : count);
|
||||
}
|
||||
|
||||
public function stride(): Int {
|
||||
return kinc_vertexbuffer_stride(_buffer);
|
||||
}
|
||||
|
||||
public function count(): Int {
|
||||
return kinc_vertexbuffer_count(_buffer);
|
||||
}
|
||||
|
||||
/** Convert Kha vertex data enum values to Kinc enum values **/
|
||||
public static inline function convertVertexDataToKinc(data: VertexData): Int {
|
||||
return switch (data) {
|
||||
case Float32_1X: 1; // KINC_G4_VERTEX_DATA_F32_1X
|
||||
case Float32_2X: 2; // KINC_G4_VERTEX_DATA_F32_2X
|
||||
case Float32_3X: 3; // KINC_G4_VERTEX_DATA_F32_3X
|
||||
case Float32_4X: 4; // KINC_G4_VERTEX_DATA_F32_4X
|
||||
case Float32_4X4: 5; // KINC_G4_VERTEX_DATA_F32_4X4
|
||||
case Int8_1X: 6; // KINC_G4_VERTEX_DATA_I8_1X
|
||||
case UInt8_1X: 7; // KINC_G4_VERTEX_DATA_U8_1X
|
||||
case Int8_1X_Normalized: 8; // KINC_G4_VERTEX_DATA_I8_1X_NORMALIZED
|
||||
case UInt8_1X_Normalized: 9; // KINC_G4_VERTEX_DATA_U8_1X_NORMALIZED
|
||||
case Int8_2X: 10; // KINC_G4_VERTEX_DATA_I8_2X
|
||||
case UInt8_2X: 11; // KINC_G4_VERTEX_DATA_U8_2X
|
||||
case Int8_2X_Normalized: 12; // KINC_G4_VERTEX_DATA_I8_2X_NORMALIZED
|
||||
case UInt8_2X_Normalized: 13; // KINC_G4_VERTEX_DATA_U8_2X_NORMALIZED
|
||||
case Int8_4X: 14; // KINC_G4_VERTEX_DATA_I8_4X
|
||||
case UInt8_4X: 15; // KINC_G4_VERTEX_DATA_U8_4X
|
||||
case Int8_4X_Normalized: 16; // KINC_G4_VERTEX_DATA_I8_4X_NORMALIZED
|
||||
case UInt8_4X_Normalized: 17; // KINC_G4_VERTEX_DATA_U8_4X_NORMALIZED
|
||||
case Int16_1X: 18; // KINC_G4_VERTEX_DATA_I16_1X
|
||||
case UInt16_1X: 19; // KINC_G4_VERTEX_DATA_U16_1X
|
||||
case Int16_1X_Normalized: 20; // KINC_G4_VERTEX_DATA_I16_1X_NORMALIZED
|
||||
case UInt16_1X_Normalized: 21; // KINC_G4_VERTEX_DATA_U16_1X_NORMALIZED
|
||||
case Int16_2X: 22; // KINC_G4_VERTEX_DATA_I16_2X
|
||||
case UInt16_2X: 23; // KINC_G4_VERTEX_DATA_U16_2X
|
||||
case Int16_2X_Normalized: 24; // KINC_G4_VERTEX_DATA_I16_2X_NORMALIZED
|
||||
case UInt16_2X_Normalized: 25; // KINC_G4_VERTEX_DATA_U16_2X_NORMALIZED
|
||||
case Int16_4X: 26; // KINC_G4_VERTEX_DATA_I16_4X
|
||||
case UInt16_4X: 27; // KINC_G4_VERTEX_DATA_U16_4X
|
||||
case Int16_4X_Normalized: 28; // KINC_G4_VERTEX_DATA_I16_4X_NORMALIZED
|
||||
case UInt16_4X_Normalized: 29; // KINC_G4_VERTEX_DATA_U16_4X_NORMALIZED
|
||||
case Int32_1X: 30; // KINC_G4_VERTEX_DATA_I32_1X
|
||||
case UInt32_1X: 31; // KINC_G4_VERTEX_DATA_U32_1X
|
||||
case Int32_2X: 32; // KINC_G4_VERTEX_DATA_I32_2X
|
||||
case UInt32_2X: 33; // KINC_G4_VERTEX_DATA_U32_2X
|
||||
case Int32_3X: 34; // KINC_G4_VERTEX_DATA_I32_3X
|
||||
case UInt32_3X: 35; // KINC_G4_VERTEX_DATA_U32_3X
|
||||
case Int32_4X: 36; // KINC_G4_VERTEX_DATA_I32_4X
|
||||
case UInt32_4X: 37; // KINC_G4_VERTEX_DATA_U32_4X
|
||||
}
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_create_vertexstructure") public static function kinc_create_vertexstructure(instanced: Bool): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_vertexstructure_add") public static function kinc_vertexstructure_add(structure: Pointer, name: hl.Bytes, data: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_create_vertexbuffer") static function kinc_create_vertexbuffer(vertexCount: Int, structure: Pointer, usage: Int,
|
||||
stepRate: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_delete_vertexbuffer") static function kinc_delete_vertexbuffer(buffer: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_vertexbuffer_lock") static function kinc_vertexbuffer_lock(buffer: Pointer): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_vertexbuffer_unlock") static function kinc_vertexbuffer_unlock(buffer: Pointer, count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_vertexbuffer_stride") static function kinc_vertexbuffer_stride(buffer: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_vertexbuffer_count") static function kinc_vertexbuffer_count(buffer: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
}
|
31
Kha/Backends/Kinc-HL/kha/graphics4/VertexShader.hx
Normal file
31
Kha/Backends/Kinc-HL/kha/graphics4/VertexShader.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
class VertexShader {
|
||||
public var _shader: Pointer;
|
||||
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {
|
||||
initShader(sources[0]);
|
||||
}
|
||||
|
||||
function initShader(source: Blob): Void {
|
||||
_shader = kinc_create_vertexshader(source.bytes.getData(), source.bytes.getData().length);
|
||||
}
|
||||
|
||||
public static function fromSource(source: String): VertexShader {
|
||||
var sh = new VertexShader(null, null);
|
||||
sh._shader = kinc_vertexshader_from_source(StringHelper.convert(source));
|
||||
return sh;
|
||||
}
|
||||
|
||||
public function delete(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_create_vertexshader") static function kinc_create_vertexshader(data: hl.Bytes, length: Int): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_vertexshader_from_source") static function kinc_vertexshader_from_source(source: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
41
Kha/Backends/Kinc-HL/kha/input/MouseImpl.hx
Normal file
41
Kha/Backends/Kinc-HL/kha/input/MouseImpl.hx
Normal file
@ -0,0 +1,41 @@
|
||||
package kha.input;
|
||||
|
||||
import kha.SystemImpl;
|
||||
|
||||
class MouseImpl extends kha.input.Mouse {
|
||||
public function new() {
|
||||
super();
|
||||
}
|
||||
|
||||
override public function lock(): Void {
|
||||
SystemImpl.lockMouse();
|
||||
}
|
||||
|
||||
override public function unlock(): Void {
|
||||
SystemImpl.unlockMouse();
|
||||
}
|
||||
|
||||
override public function canLock(): Bool {
|
||||
return SystemImpl.canLockMouse();
|
||||
}
|
||||
|
||||
override public function isLocked(): Bool {
|
||||
return SystemImpl.isMouseLocked();
|
||||
}
|
||||
|
||||
override public function notifyOnLockChange(func: Void->Void, error: Void->Void): Void {
|
||||
SystemImpl.notifyOfMouseLockChange(func, error);
|
||||
}
|
||||
|
||||
override public function removeFromLockChange(func: Void->Void, error: Void->Void): Void {
|
||||
SystemImpl.removeFromMouseLockChange(func, error);
|
||||
}
|
||||
|
||||
override public function hideSystemCursor(): Void {
|
||||
SystemImpl.hideSystemCursor();
|
||||
}
|
||||
|
||||
override public function showSystemCursor(): Void {
|
||||
SystemImpl.showSystemCursor();
|
||||
}
|
||||
}
|
38
Kha/Backends/Kinc-HL/kha/input/Sensor.hx
Normal file
38
Kha/Backends/Kinc-HL/kha/input/Sensor.hx
Normal file
@ -0,0 +1,38 @@
|
||||
package kha.input;
|
||||
|
||||
@:keep
|
||||
class Sensor {
|
||||
static var accelerometer: Sensor = new Sensor();
|
||||
static var gyroscope: Sensor = new Sensor();
|
||||
|
||||
var listeners: Array<Float->Float->Float->Void> = new Array();
|
||||
|
||||
public static function get(type: SensorType): Sensor {
|
||||
switch (type) {
|
||||
case Accelerometer:
|
||||
return accelerometer;
|
||||
case Gyroscope:
|
||||
return gyroscope;
|
||||
}
|
||||
}
|
||||
|
||||
public function notify(listener: Float->Float->Float->Void): Void {
|
||||
listeners.push(listener);
|
||||
}
|
||||
|
||||
function new() {}
|
||||
|
||||
public static function _accelerometerChanged(x: Float, y: Float, z: Float): Void {
|
||||
var sensor = get(SensorType.Accelerometer);
|
||||
for (listener in sensor.listeners) {
|
||||
listener(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public static function _gyroscopeChanged(x: Float, y: Float, z: Float): Void {
|
||||
var sensor = get(SensorType.Gyroscope);
|
||||
for (listener in sensor.listeners) {
|
||||
listener(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
42
Kha/Backends/Kinc-HL/kha/korehl/Sound.hx
Normal file
42
Kha/Backends/Kinc-HL/kha/korehl/Sound.hx
Normal file
@ -0,0 +1,42 @@
|
||||
package kha.korehl;
|
||||
|
||||
import haxe.ds.Vector;
|
||||
import sys.io.File;
|
||||
|
||||
using StringTools;
|
||||
|
||||
@:keep
|
||||
class Sound extends kha.Sound {
|
||||
function initWav(filename: String) {
|
||||
var dataSize = new kha.arrays.Uint32Array(1);
|
||||
final sampleRateRef: hl.Ref<Int> = sampleRate;
|
||||
final lengthRef: hl.Ref<Float> = length;
|
||||
var data = kinc_sound_init_wav(StringHelper.convert(filename), dataSize.getData(), sampleRateRef, lengthRef);
|
||||
sampleRate = sampleRateRef.get();
|
||||
length = lengthRef.get();
|
||||
uncompressedData = cast new kha.arrays.ByteArray(data, 0, dataSize[0] * 4);
|
||||
(cast dataSize : kha.arrays.ByteArray).free();
|
||||
}
|
||||
|
||||
function initOgg(filename: String) {
|
||||
compressedData = File.getBytes(filename);
|
||||
}
|
||||
|
||||
public function new(filename: String) {
|
||||
super();
|
||||
if (filename.endsWith(".wav")) {
|
||||
initWav(filename);
|
||||
}
|
||||
else if (filename.endsWith(".ogg")) {
|
||||
initOgg(filename);
|
||||
}
|
||||
else {
|
||||
trace("Unknown sound format: " + filename);
|
||||
}
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_sound_init_wav") static function kinc_sound_init_wav(filename: hl.Bytes, outSize: Pointer, outSampleRate: hl.Ref<Int>,
|
||||
outLength: hl.Ref<Float>): Pointer {
|
||||
return null;
|
||||
}
|
||||
}
|
95
Kha/Backends/Kinc-HL/kha/korehl/Video.hx
Normal file
95
Kha/Backends/Kinc-HL/kha/korehl/Video.hx
Normal file
@ -0,0 +1,95 @@
|
||||
package kha.korehl;
|
||||
|
||||
class Video extends kha.Video {
|
||||
public var _video: Pointer;
|
||||
|
||||
public function new(filename: String) {
|
||||
super();
|
||||
init(filename);
|
||||
}
|
||||
|
||||
function init(filename: String) {
|
||||
_video = kinc_video_create(StringHelper.convert(filename));
|
||||
}
|
||||
|
||||
override public function play(loop: Bool = false): Void {
|
||||
kinc_video_play(_video);
|
||||
}
|
||||
|
||||
override public function pause(): Void {
|
||||
kinc_video_pause(_video);
|
||||
}
|
||||
|
||||
override public function stop(): Void {
|
||||
kinc_video_stop(_video);
|
||||
}
|
||||
|
||||
override public function getLength(): Int { // Miliseconds
|
||||
return kinc_video_get_duration(_video);
|
||||
}
|
||||
|
||||
override public function getCurrentPos(): Int { // Miliseconds
|
||||
return kinc_video_get_position(_video);
|
||||
}
|
||||
|
||||
override function get_position(): Int {
|
||||
return getCurrentPos();
|
||||
}
|
||||
|
||||
override function set_position(value: Int): Int {
|
||||
kinc_video_set_position(_video, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
override public function isFinished(): Bool {
|
||||
return kinc_video_is_finished(_video);
|
||||
}
|
||||
|
||||
override public function width(): Int {
|
||||
return kinc_video_width(_video);
|
||||
}
|
||||
|
||||
override public function height(): Int {
|
||||
return kinc_video_height(_video);
|
||||
}
|
||||
|
||||
override public function unload(): Void {
|
||||
kinc_video_unload(_video);
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_create") static function kinc_video_create(filename: hl.Bytes): Pointer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_play") static function kinc_video_play(video: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_video_pause") static function kinc_video_pause(video: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_video_stop") static function kinc_video_stop(video: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_video_get_duration") static function kinc_video_get_duration(video: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_get_position") static function kinc_video_get_position(video: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_set_position") static function kinc_video_set_position(video: Pointer, value: Int): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_is_finished") static function kinc_video_is_finished(video: Pointer): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_width") static function kinc_video_width(video: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_height") static function kinc_video_height(video: Pointer): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_video_unload") static function kinc_video_unload(video: Pointer): Void {}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package kha.korehl.graphics4;
|
||||
|
||||
class ConstantLocation implements kha.graphics4.ConstantLocation {
|
||||
public var _location: Pointer;
|
||||
|
||||
public function new(location: Pointer) {
|
||||
_location = location;
|
||||
}
|
||||
}
|
379
Kha/Backends/Kinc-HL/kha/korehl/graphics4/Graphics.hx
Normal file
379
Kha/Backends/Kinc-HL/kha/korehl/graphics4/Graphics.hx
Normal file
@ -0,0 +1,379 @@
|
||||
package kha.korehl.graphics4;
|
||||
|
||||
import kha.arrays.Float32Array;
|
||||
import kha.graphics4.CubeMap;
|
||||
import kha.graphics4.MipMapFilter;
|
||||
import kha.graphics4.PipelineState;
|
||||
import kha.graphics4.TextureAddressing;
|
||||
import kha.graphics4.TextureFilter;
|
||||
import kha.graphics4.Usage;
|
||||
import kha.graphics4.VertexBuffer;
|
||||
import kha.math.FastMatrix3;
|
||||
import kha.math.FastMatrix4;
|
||||
import kha.math.FastVector2;
|
||||
import kha.math.FastVector3;
|
||||
import kha.math.FastVector4;
|
||||
import kha.Canvas;
|
||||
import kha.Image;
|
||||
import kha.Video;
|
||||
import kha.Color;
|
||||
|
||||
class Graphics implements kha.graphics4.Graphics {
|
||||
var target: Canvas;
|
||||
|
||||
public function new(target: Canvas = null) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public function vsynced(): Bool {
|
||||
return kinc_graphics_vsynced();
|
||||
}
|
||||
|
||||
public function refreshRate(): Int {
|
||||
return kinc_graphics_refreshrate();
|
||||
}
|
||||
|
||||
public function clear(?color: Color, ?z: FastFloat, ?stencil: Int): Void {
|
||||
var flags: Int = 0;
|
||||
if (color != null)
|
||||
flags |= 1;
|
||||
if (z != null)
|
||||
flags |= 2;
|
||||
if (stencil != null)
|
||||
flags |= 4;
|
||||
kinc_graphics_clear(flags, color == null ? 0 : color.value, z, stencil);
|
||||
}
|
||||
|
||||
public function viewport(x: Int, y: Int, width: Int, height: Int): Void {
|
||||
kinc_graphics_viewport(x, y, width, height);
|
||||
}
|
||||
|
||||
public function setVertexBuffer(vertexBuffer: kha.graphics4.VertexBuffer): Void {
|
||||
kinc_graphics_set_vertexbuffer(vertexBuffer._buffer);
|
||||
}
|
||||
|
||||
public function setVertexBuffers(vertexBuffers: Array<kha.graphics4.VertexBuffer>): Void {
|
||||
kinc_graphics_set_vertexbuffers(vertexBuffers.length > 0 ? vertexBuffers[0]._buffer : null,
|
||||
vertexBuffers.length > 1 ? vertexBuffers[1]._buffer : null, vertexBuffers.length > 2 ? vertexBuffers[2]._buffer : null,
|
||||
vertexBuffers.length > 3 ? vertexBuffers[3]._buffer : null, vertexBuffers.length);
|
||||
}
|
||||
|
||||
public function setIndexBuffer(indexBuffer: kha.graphics4.IndexBuffer): Void {
|
||||
kinc_graphics_set_indexbuffer(indexBuffer._buffer);
|
||||
}
|
||||
|
||||
public function maxTextureSize(): Int {
|
||||
return 4096;
|
||||
}
|
||||
|
||||
public function supportsNonPow2Textures(): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setCubeMap(unit: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void {
|
||||
if (cubeMap == null)
|
||||
return;
|
||||
if (cubeMap._texture != null)
|
||||
kinc_graphics_set_cubemap_texture(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, cubeMap._texture);
|
||||
else
|
||||
kinc_graphics_set_cubemap_target(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, cubeMap._renderTarget);
|
||||
}
|
||||
|
||||
public function setCubeMapDepth(unit: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void {
|
||||
if (cubeMap == null)
|
||||
return;
|
||||
kinc_graphics_set_cubemap_depth(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, cubeMap._renderTarget);
|
||||
}
|
||||
|
||||
public function scissor(x: Int, y: Int, width: Int, height: Int): Void {
|
||||
kinc_graphics_scissor(x, y, width, height);
|
||||
}
|
||||
|
||||
public function disableScissor(): Void {
|
||||
kinc_graphics_disable_scissor();
|
||||
}
|
||||
|
||||
public function instancedRenderingAvailable(): Bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setTextureParameters(unit: kha.graphics4.TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing,
|
||||
minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void {
|
||||
kinc_graphics_set_texture_parameters(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, uAddressing, vAddressing, minificationFilter,
|
||||
magnificationFilter, mipmapFilter);
|
||||
}
|
||||
|
||||
public function setTexture3DParameters(unit: kha.graphics4.TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing,
|
||||
wAddressing: TextureAddressing, minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void {
|
||||
kinc_graphics_set_texture3d_parameters(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, uAddressing, vAddressing, wAddressing, minificationFilter,
|
||||
magnificationFilter, mipmapFilter);
|
||||
}
|
||||
|
||||
public function setTextureCompareMode(unit: kha.graphics4.TextureUnit, enabled: Bool) {
|
||||
kinc_graphics_set_texture_compare_mode(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, enabled);
|
||||
}
|
||||
|
||||
public function setCubeMapCompareMode(unit: kha.graphics4.TextureUnit, enabled: Bool) {
|
||||
kinc_graphics_set_cube_map_compare_mode(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, enabled);
|
||||
}
|
||||
|
||||
public function setTexture(unit: kha.graphics4.TextureUnit, texture: kha.Image): Void {
|
||||
if (texture == null)
|
||||
return;
|
||||
if (texture._texture != null)
|
||||
kinc_graphics_set_texture(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, texture._texture);
|
||||
else
|
||||
kinc_graphics_set_render_target(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, texture._renderTarget);
|
||||
}
|
||||
|
||||
public function setTextureArray(unit: kha.graphics4.TextureUnit, texture: kha.Image): Void {
|
||||
if (texture == null)
|
||||
return;
|
||||
kinc_graphics_set_texture_array(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, texture._textureArray);
|
||||
}
|
||||
|
||||
public function setTextureDepth(unit: kha.graphics4.TextureUnit, texture: kha.Image): Void {
|
||||
if (texture == null)
|
||||
return;
|
||||
kinc_graphics_set_texture_depth(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, texture._renderTarget);
|
||||
}
|
||||
|
||||
public function setVideoTexture(unit: kha.graphics4.TextureUnit, texture: kha.Video): Void {
|
||||
if (texture == null)
|
||||
return;
|
||||
kinc_graphics_set_texture(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, Image.fromVideo(texture)._texture);
|
||||
}
|
||||
|
||||
public function setImageTexture(unit: kha.graphics4.TextureUnit, texture: kha.Image): Void {
|
||||
kinc_graphics_set_image_texture(cast(unit, kha.korehl.graphics4.TextureUnit)._unit, texture._texture);
|
||||
}
|
||||
|
||||
public function maxBoundTextures(): Int {
|
||||
return 8;
|
||||
}
|
||||
|
||||
public function setPipeline(pipe: PipelineState): Void {
|
||||
pipe.set();
|
||||
}
|
||||
|
||||
public function setStencilReferenceValue(value: Int): Void {}
|
||||
|
||||
public function setBool(location: kha.graphics4.ConstantLocation, value: Bool): Void {
|
||||
kinc_graphics_set_bool(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value);
|
||||
}
|
||||
|
||||
public function setInt(location: kha.graphics4.ConstantLocation, value: Int): Void {
|
||||
kinc_graphics_set_int(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value);
|
||||
}
|
||||
|
||||
public function setInt2(location: kha.graphics4.ConstantLocation, value1: Int, value2: Int): Void {
|
||||
kinc_graphics_set_int2(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value1, value2);
|
||||
}
|
||||
|
||||
public function setInt3(location: kha.graphics4.ConstantLocation, value1: Int, value2: Int, value3: Int): Void {
|
||||
kinc_graphics_set_int3(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value1, value2, value3);
|
||||
}
|
||||
|
||||
public function setInt4(location: kha.graphics4.ConstantLocation, value1: Int, value2: Int, value3: Int, value4: Int): Void {
|
||||
kinc_graphics_set_int4(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value1, value2, value3, value4);
|
||||
}
|
||||
|
||||
public function setInts(location: kha.graphics4.ConstantLocation, values: kha.arrays.Int32Array): Void {
|
||||
kinc_graphics_set_ints(cast(location, kha.korehl.graphics4.ConstantLocation)._location, values.getData(), values.length);
|
||||
}
|
||||
|
||||
public function setFloat(location: kha.graphics4.ConstantLocation, value: FastFloat): Void {
|
||||
kinc_graphics_set_float(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value);
|
||||
}
|
||||
|
||||
public function setFloat2(location: kha.graphics4.ConstantLocation, value1: FastFloat, value2: FastFloat): Void {
|
||||
kinc_graphics_set_float2(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value1, value2);
|
||||
}
|
||||
|
||||
public function setFloat3(location: kha.graphics4.ConstantLocation, value1: FastFloat, value2: FastFloat, value3: FastFloat): Void {
|
||||
kinc_graphics_set_float3(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value1, value2, value3);
|
||||
}
|
||||
|
||||
public function setFloat4(location: kha.graphics4.ConstantLocation, value1: FastFloat, value2: FastFloat, value3: FastFloat, value4: FastFloat): Void {
|
||||
kinc_graphics_set_float4(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value1, value2, value3, value4);
|
||||
}
|
||||
|
||||
public function setVector2(location: kha.graphics4.ConstantLocation, value: FastVector2): Void {
|
||||
kinc_graphics_set_float2(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value.x, value.y);
|
||||
}
|
||||
|
||||
public function setVector3(location: kha.graphics4.ConstantLocation, value: FastVector3): Void {
|
||||
kinc_graphics_set_float3(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value.x, value.y, value.z);
|
||||
}
|
||||
|
||||
public function setVector4(location: kha.graphics4.ConstantLocation, value: FastVector4): Void {
|
||||
kinc_graphics_set_float4(cast(location, kha.korehl.graphics4.ConstantLocation)._location, value.x, value.y, value.z, value.w);
|
||||
}
|
||||
|
||||
public function setFloats(location: kha.graphics4.ConstantLocation, values: Float32Array): Void {
|
||||
kinc_graphics_set_floats(cast(location, kha.korehl.graphics4.ConstantLocation)._location, values.getData(), values.length);
|
||||
}
|
||||
|
||||
public inline function setMatrix(location: kha.graphics4.ConstantLocation, matrix: FastMatrix4): Void {
|
||||
kinc_graphics_set_matrix(cast(location, kha.korehl.graphics4.ConstantLocation)._location, matrix._00, matrix._10, matrix._20, matrix._30, matrix._01,
|
||||
matrix._11, matrix._21, matrix._31, matrix._02, matrix._12, matrix._22, matrix._32, matrix._03, matrix._13, matrix._23, matrix._33);
|
||||
}
|
||||
|
||||
public inline function setMatrix3(location: kha.graphics4.ConstantLocation, matrix: FastMatrix3): Void {
|
||||
kinc_graphics_set_matrix3(cast(location, kha.korehl.graphics4.ConstantLocation)._location, matrix._00, matrix._10, matrix._20, matrix._01, matrix._11,
|
||||
matrix._21, matrix._02, matrix._12, matrix._22);
|
||||
}
|
||||
|
||||
public function drawIndexedVertices(start: Int = 0, count: Int = -1): Void {
|
||||
if (count < 0)
|
||||
kinc_graphics_draw_all_indexed_vertices();
|
||||
else
|
||||
kinc_graphics_draw_indexed_vertices(start, count);
|
||||
}
|
||||
|
||||
public function drawIndexedVerticesInstanced(instanceCount: Int, start: Int = 0, count: Int = -1): Void {
|
||||
if (count < 0)
|
||||
kinc_graphics_draw_all_indexed_vertices_instanced(instanceCount);
|
||||
else
|
||||
kinc_graphics_draw_indexed_vertices_instanced(instanceCount, start, count);
|
||||
}
|
||||
|
||||
function renderToTexture(additionalRenderTargets: Array<Canvas>): Void {
|
||||
if (additionalRenderTargets != null) {
|
||||
var len = additionalRenderTargets.length;
|
||||
var rt0 = cast(target, Image)._renderTarget;
|
||||
var rt1 = len > 0 ? cast(additionalRenderTargets[0], Image)._renderTarget : null;
|
||||
var rt2 = len > 1 ? cast(additionalRenderTargets[1], Image)._renderTarget : null;
|
||||
var rt3 = len > 2 ? cast(additionalRenderTargets[2], Image)._renderTarget : null;
|
||||
var rt4 = len > 3 ? cast(additionalRenderTargets[3], Image)._renderTarget : null;
|
||||
var rt5 = len > 4 ? cast(additionalRenderTargets[4], Image)._renderTarget : null;
|
||||
var rt6 = len > 5 ? cast(additionalRenderTargets[5], Image)._renderTarget : null;
|
||||
var rt7 = len > 6 ? cast(additionalRenderTargets[6], Image)._renderTarget : null;
|
||||
kinc_graphics_render_to_textures(rt0, rt1, rt2, rt3, rt4, rt5, rt6, rt7, len + 1);
|
||||
}
|
||||
else {
|
||||
kinc_graphics_render_to_texture(cast(target, Image)._renderTarget);
|
||||
}
|
||||
}
|
||||
|
||||
public function begin(additionalRenderTargets: Array<Canvas> = null): Void {
|
||||
if (target == null)
|
||||
kinc_graphics_restore_render_target();
|
||||
else
|
||||
renderToTexture(additionalRenderTargets);
|
||||
}
|
||||
|
||||
public function beginFace(face: Int): Void {
|
||||
kinc_graphics_render_to_face(cast(target, CubeMap)._renderTarget, face);
|
||||
}
|
||||
|
||||
public function beginEye(eye: Int): Void {}
|
||||
|
||||
public function end(): Void {}
|
||||
|
||||
public function flush(): Void {
|
||||
kinc_graphics_flush();
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_clear") static function kinc_graphics_clear(flags: Int, color: Int, z: FastFloat, stencil: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_vsynced") static function kinc_graphics_vsynced(): Bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_refreshrate") static function kinc_graphics_refreshrate(): Int {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_viewport") static function kinc_graphics_viewport(x: Int, y: Int, width: Int, height: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_vertexbuffer") static function kinc_graphics_set_vertexbuffer(buffer: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_vertexbuffers") static function kinc_graphics_set_vertexbuffers(b0: Pointer, b1: Pointer, b2: Pointer, b3: Pointer,
|
||||
count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_indexbuffer") static function kinc_graphics_set_indexbuffer(buffer: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_scissor") static function kinc_graphics_scissor(x: Int, y: Int, width: Int, height: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_disable_scissor") static function kinc_graphics_disable_scissor(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_texture_parameters") static function kinc_graphics_set_texture_parameters(unit: Pointer, uAddressing: Int,
|
||||
vAddressing: Int, minificationFilter: Int, magnificationFilter: Int, mipmapFilter: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_texture3d_parameters") static function kinc_graphics_set_texture3d_parameters(unit: Pointer, uAddressing: Int,
|
||||
vAddressing: Int, wAddressing: Int, minificationFilter: Int, magnificationFilter: Int, mipmapFilter: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_texture_compare_mode") static function kinc_graphics_set_texture_compare_mode(unit: Pointer, enabled: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_cube_map_compare_mode") static function kinc_graphics_set_cube_map_compare_mode(unit: Pointer, enabled: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_texture") static function kinc_graphics_set_texture(unit: Pointer, texture: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_texture_depth") static function kinc_graphics_set_texture_depth(unit: Pointer, renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_texture_array") static function kinc_graphics_set_texture_array(unit: Pointer, textureArray: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_render_target") static function kinc_graphics_set_render_target(unit: Pointer, renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_cubemap_texture") static function kinc_graphics_set_cubemap_texture(unit: Pointer, texture: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_cubemap_target") static function kinc_graphics_set_cubemap_target(unit: Pointer, renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_cubemap_depth") static function kinc_graphics_set_cubemap_depth(unit: Pointer, renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_image_texture") static function kinc_graphics_set_image_texture(unit: Pointer, texture: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_bool") static function kinc_graphics_set_bool(location: Pointer, value: Bool): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_int") static function kinc_graphics_set_int(location: Pointer, value: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_int2") static function kinc_graphics_set_int2(location: Pointer, value1: Int, value2: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_int3") static function kinc_graphics_set_int3(location: Pointer, value1: Int, value2: Int, value3: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_int4") static function kinc_graphics_set_int4(location: Pointer, value1: Int, value2: Int, value3: Int,
|
||||
value4: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_ints") static function kinc_graphics_set_ints(location: Pointer, values: Pointer, count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_float") static function kinc_graphics_set_float(location: Pointer, value: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_float2") static function kinc_graphics_set_float2(location: Pointer, value1: FastFloat, value2: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_float3") static function kinc_graphics_set_float3(location: Pointer, value1: FastFloat, value2: FastFloat,
|
||||
value3: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_float4") static function kinc_graphics_set_float4(location: Pointer, value1: FastFloat, value2: FastFloat,
|
||||
value3: FastFloat, value4: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_floats") static function kinc_graphics_set_floats(location: Pointer, values: Pointer, count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_matrix") static function kinc_graphics_set_matrix(location: Pointer, _00: FastFloat, _10: FastFloat, _20: FastFloat,
|
||||
_30: FastFloat, _01: FastFloat, _11: FastFloat, _21: FastFloat, _31: FastFloat, _02: FastFloat, _12: FastFloat, _22: FastFloat, _32: FastFloat,
|
||||
_03: FastFloat, _13: FastFloat, _23: FastFloat, _33: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_set_matrix3") static function kinc_graphics_set_matrix3(location: Pointer, _00: FastFloat, _10: FastFloat,
|
||||
_20: FastFloat, _01: FastFloat, _11: FastFloat, _21: FastFloat, _02: FastFloat, _12: FastFloat, _22: FastFloat): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_draw_all_indexed_vertices") static function kinc_graphics_draw_all_indexed_vertices(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_draw_indexed_vertices") static function kinc_graphics_draw_indexed_vertices(start: Int, count: Int): Void {}
|
||||
|
||||
@:hlNative("std",
|
||||
"kinc_graphics_draw_all_indexed_vertices_instanced") static function kinc_graphics_draw_all_indexed_vertices_instanced(instanceCount: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_draw_indexed_vertices_instanced") static function kinc_graphics_draw_indexed_vertices_instanced(instanceCount: Int,
|
||||
start: Int, count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_restore_render_target") static function kinc_graphics_restore_render_target(): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_render_to_texture") static function kinc_graphics_render_to_texture(renderTarget: Pointer): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_render_to_textures") static function kinc_graphics_render_to_textures(rt0: Pointer, rt1: Pointer, rt2: Pointer,
|
||||
rt3: Pointer, rt4: Pointer, rt5: Pointer, rt6: Pointer, rt7: Pointer, count: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_render_to_face") static function kinc_graphics_render_to_face(renderTarget: Pointer, face: Int): Void {}
|
||||
|
||||
@:hlNative("std", "kinc_graphics_flush") static function kinc_graphics_flush(): Void {}
|
||||
}
|
19
Kha/Backends/Kinc-HL/kha/korehl/graphics4/Graphics2.hx
Normal file
19
Kha/Backends/Kinc-HL/kha/korehl/graphics4/Graphics2.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package kha.korehl.graphics4;
|
||||
|
||||
import kha.Canvas;
|
||||
import kha.graphics4.Graphics;
|
||||
import kha.graphics4.Graphics2;
|
||||
import kha.graphics4.TextureFormat;
|
||||
|
||||
class Graphics2 extends kha.graphics4.Graphics2 {
|
||||
public function new(canvas: Canvas) {
|
||||
super(canvas);
|
||||
}
|
||||
|
||||
override public function drawVideoInternal(video: kha.Video, x: Float, y: Float, width: Float, height: Float): Void {
|
||||
color = Color.Blue;
|
||||
fillRect(x, y, width, height);
|
||||
color = Color.White;
|
||||
drawScaledSubImage(Image.fromVideo(video), 0, 0, video.width(), video.height(), x, y, width, height);
|
||||
}
|
||||
}
|
9
Kha/Backends/Kinc-HL/kha/korehl/graphics4/TextureUnit.hx
Normal file
9
Kha/Backends/Kinc-HL/kha/korehl/graphics4/TextureUnit.hx
Normal file
@ -0,0 +1,9 @@
|
||||
package kha.korehl.graphics4;
|
||||
|
||||
class TextureUnit implements kha.graphics4.TextureUnit {
|
||||
public var _unit: Pointer;
|
||||
|
||||
public function new(unit: Pointer) {
|
||||
_unit = unit;
|
||||
}
|
||||
}
|
11
Kha/Backends/Kinc-HL/kha/netsync/Network.hx
Normal file
11
Kha/Backends/Kinc-HL/kha/netsync/Network.hx
Normal file
@ -0,0 +1,11 @@
|
||||
package kha.netsync;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
class Network {
|
||||
public function new(url: String, port: Int, errorCallback: Void->Void, closeCallback: Void->Void) {}
|
||||
|
||||
public function send(bytes: Bytes, mandatory: Bool): Void {}
|
||||
|
||||
public function listen(listener: Bytes->Void): Void {}
|
||||
}
|
8
Kha/Backends/Kinc-HL/kha/network/Http.hx
Normal file
8
Kha/Backends/Kinc-HL/kha/network/Http.hx
Normal file
@ -0,0 +1,8 @@
|
||||
package kha.network;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
class Http {
|
||||
public static function request(url: String, path: String, data: String, port: Int, secure: Bool, method: HttpMethod, contentType: String,
|
||||
callback: Int->Int->String->Void /*error, response, body*/): Void {}
|
||||
}
|
Reference in New Issue
Block a user