Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,126 @@
package kha;
import haxe.io.Bytes;
import js.node.Buffer;
class Blob implements Resource {
var buffer: Buffer;
function new(bytes: Bytes) {
if (bytes != null) {
buffer = new Buffer(bytes.length);
for (i in 0...bytes.length) {
buffer.writeUInt8(bytes.get(i), i);
}
}
}
public static function fromBytes(bytes: Bytes): Blob {
return new Blob(bytes);
}
public static function alloc(size: Int): Blob {
var blob = new Blob(null);
var array = new Array();
array[size - 1] = 0;
blob.buffer = new Buffer(array);
return blob;
}
@:noCompletion
public static function _fromBuffer(buffer: Buffer): Blob {
var blob = new Blob(null);
blob.buffer = buffer;
return blob;
}
public function sub(start: Int, length: Int): Blob {
return _fromBuffer(buffer.slice(start, start + length));
}
public var length(get, never): Int;
function get_length(): Int {
return buffer.length;
}
public function writeU8(position: Int, value: Int): Void {
buffer.writeUInt8(value, position);
}
public function readU8(position: Int): Int {
var byte = buffer.readUInt8(position);
++position;
return byte;
}
public function readS8(position: Int): Int {
var byte = buffer.readInt8(position);
++position;
return byte;
}
public function readU16BE(position: Int): Int {
var value = buffer.readUInt16BE(position);
position += 2;
return value;
}
public function readU16LE(position: Int): Int {
var value = buffer.readUInt16LE(position);
position += 2;
return value;
}
public function readS16BE(position: Int): Int {
var value = buffer.readInt16BE(position);
position += 2;
return value;
}
public function readS16LE(position: Int): Int {
var value = buffer.readInt16LE(position);
position += 2;
return value;
}
public function readS32BE(position: Int): Int {
var value = buffer.readInt32BE(position);
position += 4;
return value;
}
public function readS32LE(position: Int): Int {
var value = buffer.readInt32LE(position);
position += 4;
return value;
}
public function readF32BE(position: Int): Float {
var value = buffer.readFloatBE(position);
position += 4;
return value;
}
public function readF32LE(position: Int): Float {
var value = buffer.readFloatLE(position);
position += 4;
return value;
}
public function toString(): String {
return buffer.toString();
}
public function readUtf8String(): String {
return toString();
}
public function toBytes(): Bytes {
return Bytes.ofData(cast buffer);
}
public function unload(): Void {
buffer = null;
}
}

View File

@ -0,0 +1,13 @@
package kha;
class Display {
public static final primary = new Display();
public static var all = [];
public final frequency = 60;
public final pixelsPerInch = 96;
public static function init(): Void {}
function new() {}
}

View File

@ -0,0 +1,3 @@
package kha;
typedef Font = kha.Kravur;

View File

@ -0,0 +1,152 @@
package kha;
import haxe.io.Bytes;
import kha.graphics4.TextureFormat;
import kha.graphics4.DepthStencilFormat;
import kha.graphics4.Usage;
import kha.js.EmptyGraphics1;
import kha.js.EmptyGraphics2;
import kha.js.EmptyGraphics4;
class Image implements Canvas implements Resource {
var w: Int;
var h: Int;
var graphics1: EmptyGraphics1;
var graphics2: EmptyGraphics2;
var graphics4: EmptyGraphics4;
var bytes: Bytes;
var myFormat: TextureFormat;
public function new(width: Int, height: Int, format: TextureFormat) {
w = width;
h = height;
var bytesPerPixel = 4;
if (format != null && format == TextureFormat.L8)
bytesPerPixel = 1;
myFormat = format;
bytes = Bytes.alloc(width * height * bytesPerPixel);
graphics1 = new EmptyGraphics1(w, h);
graphics2 = new EmptyGraphics2(w, h);
graphics4 = new EmptyGraphics4(w, h);
}
public static function create(width: Int, height: Int, format: TextureFormat = null, usage: Usage = null, readable: Bool = false): Image {
return new Image(width, height, format);
}
public static function create3D(width: Int, height: Int, depth: Int, format: TextureFormat = null, usage: Usage = null, readable: Bool = false): Image {
return null;
}
public static function createRenderTarget(width: Int, height: Int, format: TextureFormat = null,
depthStencil: DepthStencilFormat = DepthStencilFormat.NoDepthAndStencil, antiAliasingSamples: Int = 1): Image {
return new Image(width, height, format);
}
public static function fromBytes(bytes: Bytes, width: Int, height: Int, format: TextureFormat = null, usage: Usage = null, readable: Bool = false): Image {
return null;
}
public static function fromBytes3D(bytes: Bytes, width: Int, height: Int, depth: Int, format: TextureFormat = null, usage: Usage = null,
readable: Bool = false): Image {
return null;
}
public static var maxSize(get, never): Int;
static function get_maxSize(): Int {
return 1024 * 4;
}
public static var nonPow2Supported(get, never): Bool;
static function get_nonPow2Supported(): Bool {
return false;
}
public static function renderTargetsInvertedY(): Bool {
return false;
}
public function isOpaque(x: Int, y: Int): Bool {
return false;
}
public function at(x: Int, y: Int): Color {
return 0;
}
public function unload(): Void {}
public function lock(level: Int = 0): Bytes {
return bytes;
}
public function unlock(): Void {}
public function getPixels(): Bytes {
return null;
}
public function generateMipmaps(levels: Int): Void {}
public function setMipmaps(mipmaps: Array<Image>): Void {}
public function setDepthStencilFrom(image: Image): Void {}
public function clear(x: Int, y: Int, z: Int, width: Int, height: Int, depth: Int, color: Color): Void {}
public var width(get, never): Int;
function get_width(): Int {
return w;
}
public var height(get, never): Int;
function get_height(): Int {
return h;
}
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 w;
}
public var realHeight(get, never): Int;
function get_realHeight(): Int {
return h;
}
public var g1(get, never): kha.graphics1.Graphics;
function get_g1(): kha.graphics1.Graphics {
return graphics1;
}
public var g2(get, never): kha.graphics2.Graphics;
function get_g2(): kha.graphics2.Graphics {
return graphics2;
}
public var g4(get, never): kha.graphics4.Graphics;
function get_g4(): kha.graphics4.Graphics {
return graphics4;
}
}

View File

@ -0,0 +1,71 @@
package kha;
import js.Boot;
import js.Browser;
import js.lib.Error;
import js.html.audio.DynamicsCompressorNode;
import js.html.ImageElement;
import js.Node;
import js.node.Buffer;
import js.node.Fs;
import kha.FontStyle;
import kha.Blob;
import kha.graphics4.TextureFormat;
import kha.Image;
import kha.Kravur;
import haxe.io.Bytes;
import haxe.io.BytesData;
import js.Lib;
import js.html.XMLHttpRequest;
class LoaderImpl {
public static function getSoundFormats(): Array<String> {
return ["nix"];
}
public static function loadSoundFromDescription(desc: Dynamic, done: kha.Sound->Void, failed: AssetError->Void): Void {
Node.setTimeout(function() {
done(new Sound());
}, 0);
}
public static function getImageFormats(): Array<String> {
return ["nix"];
}
public static function loadImageFromDescription(desc: Dynamic, done: kha.Image->Void, failed: AssetError->Void): Void {
Node.setTimeout(function() {
done(new Image(100, 100, TextureFormat.RGBA32));
}, 0);
}
public static function getVideoFormats(): Array<String> {
return ["nix"];
}
public static function loadVideoFromDescription(desc: Dynamic, done: kha.Video->Void, failed: AssetError->Void): Void {
Node.setTimeout(function() {
done(new Video());
}, 0);
}
public static function loadBlobFromDescription(desc: Dynamic, done: Blob->Void, failed: AssetError->Void): Void {
Fs.readFile(desc.files[0], function(error: Error, data: Buffer) {
if (error != null) {
failed({
url: desc.files[0],
error: error,
});
}
else {
done(Blob._fromBuffer(data));
}
});
}
public static function loadFontFromDescription(desc: Dynamic, done: Font->Void, failed: AssetError->Void): Void {
loadBlobFromDescription(desc, function(blob: Blob) {
done(new Kravur(blob));
}, failed);
}
}

View File

@ -0,0 +1,15 @@
package kha;
import haxe.io.Bytes;
import haxe.io.BytesData;
import js.html.ArrayBuffer;
class Storage {
public static function namedFile(name: String): StorageFile {
return null;
}
public static function defaultFile(): StorageFile {
return namedFile("default.kha");
}
}

View File

@ -0,0 +1,218 @@
package kha;
import js.Browser;
import js.html.CanvasElement;
import js.Node;
import kha.System.SystemOptions;
import kha.input.Gamepad;
import kha.input.Keyboard;
import kha.input.Mouse;
import kha.js.EmptyGraphics1;
import kha.js.EmptyGraphics2;
import kha.js.EmptyGraphics4;
import kha.netsync.Session;
class SystemImpl {
static var screenRotation: ScreenRotation = ScreenRotation.RotationNone;
static inline var networkSendRate = 0.05;
public static function init(options: SystemOptions, callback: Window->Void): Void {
Window.get(0).width = options.width;
Window.get(0).height = options.height;
init2();
callback(null);
}
public static function initEx(title: String, options: Array<WindowOptions>, windowCallback: Int->Void, callback: Window->Void) {
trace('initEx is not supported on the node target, running init() with first window options');
init({title: title, width: options[0].width, height: options[0].height}, callback);
if (windowCallback != null) {
windowCallback(0);
}
}
public static function changeResolution(width: Int, height: Int): Void {}
public static function _updateSize(width: Int, height: Int): Void {
Window.get(0).width = width;
Window.get(0).height = height;
}
public static function _updateScreenRotation(value: Int): Void {
screenRotation = cast value;
}
public static function getTime(): Float {
var time = Node.process.hrtime();
return cast(time[0], Float) + cast(time[1], Float) / 1000000000;
}
public static function screenDpi(): Int {
return 96;
}
public static function getScreenRotation(): ScreenRotation {
return screenRotation;
}
public static function getVsync(): Bool {
return false;
}
public static function getRefreshRate(): Int {
return 60;
}
public static function getSystemId(): String {
return "nodejs";
}
public static function vibrate(ms: Int): Void {}
public static function getLanguage(): String {
return "en";
}
public static function requestShutdown(): Bool {
Node.process.exit(0);
return true;
}
static var frame: Framebuffer = null;
static var keyboard: Keyboard;
static var mouse: kha.input.Mouse;
static var gamepad: Gamepad;
public static var mouseX: Int;
public static var mouseY: Int;
static var lastTime: Float = 0;
static function init2() {
keyboard = new Keyboard();
mouse = new kha.input.Mouse();
gamepad = new Gamepad();
Scheduler.init();
Shaders.init();
final width = Window.get(0).width;
final height = Window.get(0).height;
frame = new Framebuffer(0, new EmptyGraphics1(width, height), new EmptyGraphics2(width, height), new EmptyGraphics4(width, height));
Scheduler.start();
lastTime = Scheduler.time();
run();
synch();
}
static function run() {
Scheduler.executeFrame();
var time = Scheduler.time();
// Was scheduler reset?
if (time < lastTime - 10) {
lastTime = time;
}
if (time >= lastTime + 10) {
lastTime = time;
Node.console.log(lastTime + " seconds.");
}
Node.setTimeout(run, 1);
}
static function synch() {
if (Session.the() != null) {
Session.the().update();
}
Node.setTimeout(synch, Std.int(networkSendRate * 1000));
}
public static function getKeyboard(num: Int): Keyboard {
if (num != 0)
return null;
return keyboard;
}
public static function getMouse(num: Int): Mouse {
if (num != 0)
return null;
return mouse;
}
public static function lockMouse(): Void {}
public static function unlockMouse(): Void {}
public static function canLockMouse(): Bool {
return false;
}
public static function isMouseLocked(): Bool {
return false;
}
public static function notifyOfMouseLockChange(func: Void->Void, error: Void->Void): Void {}
public static function removeFromMouseLockChange(func: Void->Void, error: Void->Void): Void {}
public static function canSwitchFullscreen(): Bool {
return false;
}
public static function isFullscreen(): Bool {
return false;
}
public static function requestFullscreen(): Void {}
public static function exitFullscreen(): Void {}
public static function notifyOfFullscreenChange(func: Void->Void, error: Void->Void): Void {}
public static function removeFromFullscreenChange(func: Void->Void, error: Void->Void): Void {}
public static function setKeepScreenOn(on: Bool): Void {}
public static function loadUrl(url: String): Void {}
public static function getGamepadId(index: Int): String {
return "unknown";
}
public static function getGamepadVendor(index: Int): String {
return "unknown";
}
public static function setGamepadRumble(index: Int, leftAmount: Float, rightAmount: Float): Void {}
public static function getPen(num: Int): kha.input.Pen {
return null;
}
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 {}
}

View File

@ -0,0 +1,40 @@
package kha;
class Window {
public static function create(win: WindowOptions = null, frame: FramebufferOptions = null): Window {
return instance;
}
public static function destroy(window: Window) {}
public static function get(index: Int): Window {
return instance;
}
public static var all = [];
public var x = 0;
public var y = 0;
public var width = 0;
public var height = 0;
public var mode = WindowMode.Windowed;
public var visible = false;
public var title = "";
public final vSynced = false;
static final instance = new Window();
function new() {}
public function notifyOnResize(callback: Int->Int->Void) {}
public function notifyOnPpiChange(callback: Int->Void) {}
public function changeWindowFeatures(features: WindowOptions.WindowFeatures) {}
public function changeFramebuffer(frame: FramebufferOptions) {}
public function resize(width: Int, height: Int) {}
public function move(x: Int, y: Int) {}
}

View File

@ -0,0 +1,187 @@
package kha.arrays;
import js.lib.DataView;
import kha.FastFloat;
@:forward
abstract ByteArray(DataView) to DataView {
static final LITTLE_ENDIAN: Bool = js.Syntax.code("new Uint8Array(new Uint32Array([0x12345678]).buffer)[0] === 0x78");
public var buffer(get, never): ByteBuffer;
inline function get_buffer(): ByteBuffer {
return cast this.buffer;
}
public function new(buffer: ByteBuffer, ?byteOffset: Int, ?byteLength: Int) {
this = new DataView(buffer, byteOffset, byteLength);
}
static public function make(byteLength: Int): ByteArray {
return new ByteArray(ByteBuffer.create(byteLength));
}
public inline function getInt8(byteOffset: Int): Int {
return this.getInt8(byteOffset);
}
public inline function getUint8(byteOffset: Int): Int {
return this.getUint8(byteOffset);
}
public inline function getInt16(byteOffset: Int): Int {
return this.getInt16(byteOffset, LITTLE_ENDIAN);
}
public inline function getUint16(byteOffset: Int): Int {
return this.getUint16(byteOffset, LITTLE_ENDIAN);
}
public inline function getInt32(byteOffset: Int): Int {
return this.getInt32(byteOffset, LITTLE_ENDIAN);
}
public inline function getUint32(byteOffset: Int): Int {
return this.getUint32(byteOffset, LITTLE_ENDIAN);
}
public inline function getFloat32(byteOffset: Int): FastFloat {
return this.getFloat32(byteOffset, LITTLE_ENDIAN);
}
public inline function getFloat64(byteOffset: Int): Float {
return this.getFloat64(byteOffset, LITTLE_ENDIAN);
}
public inline function setInt8(byteOffset: Int, value: Int): Void {
this.setInt8(byteOffset, value);
}
public inline function setUint8(byteOffset: Int, value: Int): Void {
this.setUint8(byteOffset, value);
}
public inline function setInt16(byteOffset: Int, value: Int): Void {
this.setInt16(byteOffset, value, LITTLE_ENDIAN);
}
public inline function setUint16(byteOffset: Int, value: Int): Void {
this.setUint16(byteOffset, value, LITTLE_ENDIAN);
}
public inline function setInt32(byteOffset: Int, value: Int): Void {
this.setInt32(byteOffset, value, LITTLE_ENDIAN);
}
public inline function setUint32(byteOffset: Int, value: Int): Void {
this.setUint32(byteOffset, value, LITTLE_ENDIAN);
}
public inline function setFloat32(byteOffset: Int, value: FastFloat): Void {
this.setFloat32(byteOffset, value, true);
}
public inline function setFloat64(byteOffset: Int, value: Float): Void {
this.setFloat64(byteOffset, value, LITTLE_ENDIAN);
}
public inline function getInt16LE(byteOffset: Int): Int {
return this.getInt16(byteOffset, true);
}
public inline function getUint16LE(byteOffset: Int): Int {
return this.getUint16(byteOffset, true);
}
public inline function getInt32LE(byteOffset: Int): Int {
return this.getInt32(byteOffset, true);
}
public inline function getUint32LE(byteOffset: Int): Int {
return this.getUint32(byteOffset, true);
}
public inline function getFloat32LE(byteOffset: Int): FastFloat {
return this.getFloat32(byteOffset, true);
}
public inline function getFloat64LE(byteOffset: Int): Float {
return this.getFloat64(byteOffset, true);
}
public inline function setInt16LE(byteOffset: Int, value: Int): Void {
this.setInt16(byteOffset, value, true);
}
public inline function setUint16LE(byteOffset: Int, value: Int): Void {
this.setUint16(byteOffset, value, true);
}
public inline function setInt32LE(byteOffset: Int, value: Int): Void {
this.setInt32(byteOffset, value, true);
}
public inline function setUint32LE(byteOffset: Int, value: Int): Void {
this.setUint32(byteOffset, value, true);
}
public inline function setFloat32LE(byteOffset: Int, value: FastFloat): Void {
this.setFloat32(byteOffset, value, true);
}
public inline function setFloat64LE(byteOffset: Int, value: Float): Void {
this.setFloat64(byteOffset, value, true);
}
public inline function getInt16BE(byteOffset: Int): Int {
return this.getInt16(byteOffset);
}
public inline function getUint16BE(byteOffset: Int): Int {
return this.getUint16(byteOffset);
}
public inline function getInt32BE(byteOffset: Int): Int {
return this.getInt32(byteOffset);
}
public inline function getUint32BE(byteOffset: Int): Int {
return this.getUint32(byteOffset);
}
public inline function getFloat32BE(byteOffset: Int): FastFloat {
return this.getFloat32(byteOffset);
}
public inline function getFloat64BE(byteOffset: Int): Float {
return this.getFloat64(byteOffset);
}
public inline function setInt16BE(byteOffset: Int, value: Int): Void {
this.setInt16(byteOffset, value);
}
public inline function setUint16BE(byteOffset: Int, value: Int): Void {
this.setUint16(byteOffset, value);
}
public inline function setInt32BE(byteOffset: Int, value: Int): Void {
this.setInt32(byteOffset, value);
}
public inline function setUint32BE(byteOffset: Int, value: Int): Void {
this.setUint32(byteOffset, value);
}
public inline function setFloat32BE(byteOffset: Int, value: FastFloat): Void {
this.setFloat32(byteOffset, value);
}
public inline function setFloat64BE(byteOffset: Int, value: Float): Void {
this.setFloat64(byteOffset, value);
}
public inline function subarray(start: Int, ?end: Int): ByteArray {
return new ByteArray(buffer, start, end != null ? end - start : null);
}
}

View File

@ -0,0 +1,14 @@
package kha.arrays;
import js.lib.ArrayBuffer;
@:forward
abstract ByteBuffer(ArrayBuffer) from ArrayBuffer to ArrayBuffer {
public static function create(length: Int): ByteBuffer {
return new ByteBuffer(length);
}
function new(length: Int) {
this = new ArrayBuffer(length);
}
}

View File

@ -0,0 +1,13 @@
package kha.audio1;
import kha.Sound;
class Audio {
public static function play(sound: Sound, loop: Bool = false): AudioChannel {
return new NodeAudioChannel();
}
public static function stream(sound: Sound, loop: Bool = false): AudioChannel {
return new NodeAudioChannel();
}
}

View File

@ -0,0 +1,43 @@
package kha.audio1;
class NodeAudioChannel implements AudioChannel {
public function new() {}
public function play(): Void {}
public function pause(): Void {}
public function stop(): Void {}
public var length(get, never): Float;
function get_length(): Float {
return 0;
}
public var position(get, set): Float;
function get_position(): Float {
return 0;
}
function set_position(value: Float): Float {
return value;
}
public var volume(get, set): Float;
function get_volume(): Float {
return 1;
}
function set_volume(value: Float): Float {
return 1;
}
public var finished(get, never): Bool;
function get_finished(): Bool {
return true;
}
}

View File

@ -0,0 +1,5 @@
package kha.compute;
class Shader {
public function new(sources: Array<Blob>, files: Array<String>) {}
}

View File

@ -0,0 +1,47 @@
package kha.graphics4;
import haxe.io.Bytes;
class CubeMap implements Canvas implements Resource {
public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap {
return null;
}
public function unload(): Void {}
public function lock(level: Int = 0): Bytes {
return null;
}
public function unlock(): Void {}
public var width(get, never): Int;
function get_width(): Int {
return 0;
}
public var height(get, never): Int;
function get_height(): Int {
return 0;
}
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 {
return null;
}
}

View File

@ -0,0 +1,13 @@
package kha.graphics4;
import kha.Blob;
class FragmentShader {
public function new(sources: Array<Blob>, files: Array<String>) {}
public static function fromSource(source: String): FragmentShader {
return null;
}
public function delete(): Void {}
}

View File

@ -0,0 +1,30 @@
package kha.graphics4;
import kha.graphics4.Usage;
class IndexBuffer {
var data: Array<Int>;
var mySize: Int;
public function new(indexCount: Int, usage: Usage, canRead: Bool = false) {
mySize = indexCount;
data = new Array<Int>();
data[indexCount - 1] = 0;
}
public function delete(): Void {
data = null;
}
public function lock(?start: Int, ?count: Int): Array<Int> {
return data;
}
public function unlock(?count: Int): Void {}
public function set(): Void {}
public function count(): Int {
return mySize;
}
}

View File

@ -0,0 +1,26 @@
package kha.graphics4;
import kha.graphics4.FragmentShader;
import kha.graphics4.VertexData;
import kha.graphics4.VertexShader;
import kha.graphics4.VertexStructure;
class PipelineState extends PipelineStateBase {
public function new() {
super();
}
public function delete(): Void {}
public function compile(): Void {}
public function set(): Void {}
public function getConstantLocation(name: String): kha.graphics4.ConstantLocation {
return new kha.js.graphics4.ConstantLocation();
}
public function getTextureUnit(name: String): kha.graphics4.TextureUnit {
return new kha.js.graphics4.TextureUnit();
}
}

View File

@ -0,0 +1,44 @@
package kha.graphics4;
import kha.arrays.Float32Array;
import kha.graphics4.Usage;
import kha.graphics4.VertexStructure;
import kha.graphics4.VertexData;
class VertexBuffer {
var data: Float32Array;
var mySize: Int;
var myStride: Int;
public function new(vertexCount: Int, structure: VertexStructure, usage: Usage, instanceDataStepRate: Int = 0, canRead: Bool = false) {
mySize = vertexCount;
myStride = 0;
for (element in structure.elements) {
myStride += VertexData.getStride(element.data);
}
data = new Float32Array(Std.int(vertexCount * myStride / 4));
}
public function delete(): Void {
data = null;
}
public function lock(?start: Int, ?count: Int): Float32Array {
return data;
}
public function unlock(?count: Int): Void {}
public function stride(): Int {
return myStride;
}
public function count(): Int {
return mySize;
}
public function set(offset: Int): Int {
return 0;
}
}

View File

@ -0,0 +1,13 @@
package kha.graphics4;
import kha.Blob;
class VertexShader {
public function new(sources: Array<Blob>, files: Array<String>) {}
public static function fromSource(source: String): VertexShader {
return null;
}
public function delete(): Void {}
}

View File

@ -0,0 +1,54 @@
package kha.js;
import kha.Font;
import kha.FontStyle;
class EmptyFont implements Font {
var myName: String;
var myStyle: FontStyle;
var mySize: Float;
public function new(name: String, style: FontStyle, size: Float) {
myName = name;
myStyle = style;
mySize = size;
}
public var name(get, never): String;
function get_name(): String {
return myName;
}
public var style(get, never): FontStyle;
function get_style(): FontStyle {
return myStyle;
}
public var size(get, never): Float;
function get_size(): Float {
return mySize;
}
public function getHeight(): Float {
return mySize;
}
public function charWidth(ch: String): Float {
return mySize / 2;
}
public function charsWidth(ch: String, offset: Int, length: Int): Float {
return mySize / 2 * length;
}
public function stringWidth(str: String): Float {
return mySize / 2 * str.length;
}
public function getBaselinePosition(): Float {
return mySize / 3 * 2;
}
}

View File

@ -0,0 +1,13 @@
package kha.js;
import kha.graphics1.Graphics;
class EmptyGraphics1 implements Graphics {
public function new(width: Int, height: Int) {}
public function begin(): Void {}
public function end(): Void {}
public function setPixel(x: Int, y: Int, color: Color): Void {}
}

View File

@ -0,0 +1,42 @@
package kha.js;
import js.Browser;
import kha.Color;
import kha.FontStyle;
import kha.graphics2.Graphics;
import kha.Kravur;
import kha.math.Matrix3;
import kha.Rotation;
class EmptyGraphics2 extends Graphics {
var width: Int;
var height: Int;
var myColor: Color;
var myFont: kha.Font;
static var instance: EmptyGraphics2;
public function new(width: Int, height: Int) {
super();
this.width = width;
this.height = height;
instance = this;
myColor = Color.fromBytes(0, 0, 0);
}
override function set_color(color: Color): Color {
return myColor = color;
}
override function get_color(): Color {
return myColor;
}
override function set_font(font: kha.Font): kha.Font {
return myFont = font;
}
override function get_font(): kha.Font {
return myFont;
}
}

View File

@ -0,0 +1,147 @@
package kha.js;
import kha.arrays.Float32Array;
import kha.graphics4.BlendingOperation;
import kha.graphics4.CompareMode;
import kha.graphics4.ConstantLocation;
import kha.graphics4.CubeMap;
import kha.graphics4.CullMode;
import kha.graphics4.Graphics;
import kha.graphics4.IndexBuffer;
import kha.graphics4.MipMapFilter;
import kha.graphics4.PipelineState;
import kha.graphics4.StencilAction;
import kha.graphics4.TextureAddressing;
import kha.graphics4.TextureFilter;
import kha.graphics4.TextureFormat;
import kha.graphics4.TextureUnit;
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.math.Matrix4;
import kha.math.Vector2;
import kha.math.Vector3;
import kha.math.Vector4;
class EmptyGraphics4 implements Graphics {
public function new(width: Int, height: Int) {}
public function init(?backbufferFormat: TextureFormat, antiAliasingSamples: Int = 1): Void {}
public function begin(additionalRenderTargets: Array<Canvas> = null): Void {}
public function beginFace(face: Int): Void {}
public function beginEye(eye: Int): Void {}
public function end(): Void {}
public function flush(): Void {}
public function vsynced(): Bool {
return true;
}
public function refreshRate(): Int {
return 60;
}
public function maxBoundTextures(): Int {
return 8;
}
public function clear(?color: Color, ?depth: Float, ?stencil: Int): Void {}
public function viewport(x: Int, y: Int, width: Int, height: Int): Void {}
public function setCullMode(mode: CullMode): Void {}
public function setDepthMode(write: Bool, mode: CompareMode): Void {}
public function setBlendingMode(source: BlendingOperation, destination: BlendingOperation): Void {}
public function setStencilParameters(compareMode: CompareMode, bothPass: StencilAction, depthFail: StencilAction, stencilFail: StencilAction,
referenceValue: Int, readMask: Int = 0xff, writeMask: Int = 0xff): Void {}
public function setStencilReferenceValue(value: Int) {}
public function scissor(x: Int, y: Int, width: Int, height: Int): Void {}
public function disableScissor(): Void {}
public function setVertexBuffer(vertexBuffer: VertexBuffer): Void {}
public function setVertexBuffers(vertexBuffers: Array<kha.graphics4.VertexBuffer>): Void {}
public function setIndexBuffer(indexBuffer: IndexBuffer): Void {}
public function setTexture(unit: TextureUnit, texture: Image): Void {}
public function setTextureArray(unit: TextureUnit, texture: kha.Image): Void {}
public function setTextureDepth(unit: TextureUnit, texture: Image): Void {}
public function setVideoTexture(unit: kha.graphics4.TextureUnit, texture: kha.Video): Void {}
public function setImageTexture(unit: kha.graphics4.TextureUnit, texture: kha.Image): Void {}
public function setTextureParameters(texunit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing,
minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void {}
public function setTexture3DParameters(texunit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing,
wAddressing: TextureAddressing, minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void {}
public function setTextureCompareMode(texunit: TextureUnit, enabled: Bool): Void {}
public function setCubeMapCompareMode(texunit: TextureUnit, enabled: Bool): Void {}
public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void {}
public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void {}
public function setPipeline(pipeline: PipelineState): Void {}
public function setBool(location: ConstantLocation, value: Bool): Void {}
public function setInt(location: ConstantLocation, value: Int): Void {}
public function setInt2(location: ConstantLocation, value1: Int, value2: Int): Void {}
public function setInt3(location: ConstantLocation, value1: Int, value2: Int, value3: Int): Void {}
public function setInt4(location: ConstantLocation, value1: Int, value2: Int, value3: Int, value4: Int): Void {}
public function setInts(location: ConstantLocation, values: kha.arrays.Int32Array): Void {}
public function setFloat(location: ConstantLocation, value: Float): Void {}
public function setFloat2(location: ConstantLocation, value1: Float, value2: Float): Void {}
public function setFloat3(location: ConstantLocation, value1: Float, value2: Float, value3: Float): Void {}
public function setFloat4(location: ConstantLocation, value1: Float, value2: Float, value3: Float, value4: Float): Void {}
public function setFloats(location: ConstantLocation, floats: Float32Array): Void {}
public function setVector2(location: ConstantLocation, value: FastVector2): Void {}
public function setVector3(location: ConstantLocation, value: FastVector3): Void {}
public function setVector4(location: ConstantLocation, value: FastVector4): Void {}
public function setMatrix(location: ConstantLocation, value: FastMatrix4): Void {}
public function setMatrix3(location: ConstantLocation, value: FastMatrix3): Void {}
public function drawIndexedVertices(start: Int = 0, count: Int = -1): Void {}
public function instancedRenderingAvailable(): Bool {
return true;
}
public function drawIndexedVerticesInstanced(instanceCount: Int, start: Int = 0, count: Int = -1): Void {}
}

View File

@ -0,0 +1,22 @@
package kha.js;
import js.Browser;
import js.html.CanvasElement;
import kha.Cursor;
import kha.Image;
class Mouse extends kha.Mouse {
public static var SystemCursor: String = "default";
public static function UpdateSystemCursor() {}
public function new() {
super();
}
override function hideSystemCursor(): Void {}
override function showSystemCursor(): Void {}
override public function update(): Void {}
}

View File

@ -0,0 +1,16 @@
package kha.js;
import js.Browser;
import js.html.AudioElement;
import js.html.ErrorEvent;
import js.html.Event;
import js.html.MediaError;
import js.Lib;
using StringTools;
class Music extends kha.Music {
public function new() {
super();
}
}

View File

@ -0,0 +1,31 @@
package kha.js;
class SoundChannel extends kha.SoundChannel {
public function new() {
super();
}
override public function play(): Void {
super.play();
}
override public function pause(): Void {}
override public function stop(): Void {
super.stop();
}
override public function getCurrentPos(): Int {
return 0;
}
override public function getLength(): Int {
return 0;
}
}
class Sound extends kha.Sound {
public function new() {
super();
}
}

View File

@ -0,0 +1,7 @@
package kha.js;
class Video extends kha.Video {
public function new() {
super();
}
}

View File

@ -0,0 +1,5 @@
package kha.js.graphics4;
class ConstantLocation implements kha.graphics4.ConstantLocation {
public function new() {}
}

View File

@ -0,0 +1,5 @@
package kha.js.graphics4;
class TextureUnit implements kha.graphics4.TextureUnit {
public function new() {}
}