Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0f5ecf6
WIP: Basis support
lbergman Oct 31, 2019
e6f75d9
Add all compressed texture formats to isSupportedFormat
lbergman Oct 31, 2019
c8b85c4
Remove unused pattern for supported format
lbergman Oct 31, 2019
1f50d20
Make BasisTextureLoader js only
lbergman Oct 31, 2019
599adb5
Add bsis support
lbergman Nov 18, 2019
0d4b759
Get image width/height from basis bytes
lbergman Nov 18, 2019
d3fc2f7
Throw when basis texture on non-js target
lbergman Nov 18, 2019
3bb8c54
Cleanup basis width detection
lbergman Nov 20, 2019
49d6a2d
Remove duplicate compressed texture detection
lbergman Nov 20, 2019
7779b53
Use stride 1 with ETC and PBRTC
lbergman Nov 20, 2019
42fa2b7
Prioritize ETC textures last
lbergman Nov 20, 2019
1c6f8ed
Remove unused import
lbergman Nov 20, 2019
e8067c3
Support non alpha PVRTC
lbergman Nov 20, 2019
4c91180
Merge pull request #4 from HacksawStudios/basis_support
lbergman Mar 9, 2020
eb65cd6
chore: Add util files
lbergman Mar 25, 2020
1ee5cd1
Merge remote-tracking branch 'upstream/master'
lbergman Mar 25, 2020
6cdee26
fix: Flickering due to incorrect timing of clear https://github.com/…
lbergman Mar 25, 2020
3a00b7f
Merge pull request #5 from HacksawStudios/clear_background_fix
lbergman Mar 25, 2020
b83bdbd
Merge pull request #6 from HacksawStudios/engine_clear_fix
lbergman Mar 25, 2020
34c18e4
fix; Making separate alpha handling configurable in h2d.RenderContex…
lbergman Apr 6, 2020
3c9b5b8
Merge pull request #7 from HacksawStudios/separate_alpha_handling_in_…
lbergman Apr 6, 2020
08597ae
Enable high precision shaders if supported
lbergman Apr 21, 2020
4784fd2
Merge pull request #8 from HacksawStudios/enable_highp_when_available
lbergman Apr 21, 2020
0d61641
chore: Merge latest heaps master
lbergman Aug 17, 2020
b1a1bd4
Merge pull request #9 from HacksawStudios/update_from_master
lbergman Aug 17, 2020
7ee2110
chore: Update package version
lbergman Aug 17, 2020
3f6dc7e
Merge branch 'master' of https://github.com/HacksawStudios/heaps
lbergman Aug 17, 2020
713cad9
Merge remote-tracking branch 'upstream/master' into update_from_upstream
lbergman Mar 2, 2021
438e64c
fix: Merge issues
lbergman Mar 2, 2021
9e4a14a
feat: Add 'addTangent' to HMDModel
lbergman Mar 2, 2021
702b50d
fix: Formatting
lbergman Mar 2, 2021
75d0407
Merge pull request #10 from HacksawStudios/update_from_upstream
lbergman Mar 2, 2021
7baf553
chore: Update version
lbergman Mar 2, 2021
ae4a753
Merge remote-tracking branch 'upstream/master' into update_from_upstream
tkwiatek Nov 22, 2022
ae0329a
Merge pull request #11 from HacksawStudios/update_from_upstream
tkwiatek Nov 23, 2022
a652075
chore: Add Basis condition to fix compilation issue
tkwiatek Nov 23, 2022
5865e61
Merge pull request #12 from HacksawStudios/add_missing_condition_to_i…
lbergman Nov 23, 2022
8ac0833
Merge branch 'HeapsIO:master' into master
lbergman Feb 16, 2023
e1c9372
Revert unnecessary changes
lbergman Feb 16, 2023
258ad00
chore: Remove unneccessary changes
lbergman Feb 17, 2023
42ca30e
chore: Update npmrc
lbergman Feb 17, 2023
b10ed37
fix: Add missing brace
lbergman Feb 17, 2023
53ed8cf
style: Use correct indenting
lbergman Feb 17, 2023
479ad86
style: Add ending linebreak
lbergman Feb 17, 2023
91c1d68
style: Remove unnecessary whitespace changes
lbergman Feb 17, 2023
4929a10
fix: Add missing return definitions for hxsl setParamIndexValue and s…
lbergman Feb 17, 2023
f116fe8
Merge pull request #14 from HacksawStudios/fix_merge
tkwiatek Feb 20, 2023
b099063
chore: Update version
lbergman Feb 20, 2023
433ebca
chore: Update version
lbergman Feb 20, 2023
dff1eba
chore: Set haxe-module-installer as dev dependency
lbergman Feb 20, 2023
4e10301
chore: Exectute toString function on transcoder bytes
tkwiatek May 12, 2023
306a104
chore: Fix haxe 4.3.1 warnings
tkwiatek May 19, 2023
b7f9c71
Merge pull request #15 from HacksawStudios/haxe_4.3.1_compability
lbergman May 25, 2023
a7956d2
chore: Update version
lbergman May 25, 2023
e9e43e6
Merge branch 'master' of https://github.com/HacksawStudios/heaps
Jan 17, 2024
048826f
Merge pull request #16 from Vekzzor/master
lbergman Feb 6, 2024
9c21164
Adding metadata for SDF
Aug 30, 2024
ce4cdb5
fix: Restore use of initSize
Aug 30, 2024
9f95949
Merge pull request #17 from HacksawStudios/addSdfFontMetadata2
lbergman Aug 30, 2024
0563d7e
chore: Update package version
lbergman Sep 2, 2024
7f0c8b4
Merge changes from upstream
lbergman Nov 14, 2024
cf4437f
Merge pull request #19 from HacksawStudios/update_from_upstream
lbergman Nov 14, 2024
77a5ba8
chore: Merge from master
lbergman Nov 14, 2024
eb8edff
feat: WIP ktx2 support
lbergman Nov 27, 2024
a986e7d
style: Fix formatting
lbergman Nov 28, 2024
de46321
chore: Merge master
lbergman Nov 28, 2024
2d7156b
chore: Update BasisTextureLoader to support ktx2 for testing (should …
lbergman Nov 28, 2024
e25fa5c
chore: WIP ktx2 support
lbergman Dec 4, 2024
a3e6d3a
feat: Remove support for PVRTC textures
lbergman Dec 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/sync_wiki.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ bin
/hxd/net/inspect.min.css
/hxd/inspect/inspect.min.css
/samples/build
/node_modules
/*.xml
.vscode
/tools/mikktspace/out
*.exe
.history
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.gitlab-ci.yml
.idea
*.iml
bin
.history
.haxelib
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/
//hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/:always-auth=true
//hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/:_authToken=${CODEARTIFACT_AUTH_TOKEN}
4 changes: 1 addition & 3 deletions all.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
-lib hlopenal
-xml heaps_hl.xml
hxsl.CacheFileBuilder
-D hl-ver=1.15.0

--next

-hl heaps.hl
-lib hldx
-lib hlopenal
-xml heaps_hldx.xml
-D hl-ver=1.15.0

--next

Expand All @@ -36,4 +34,4 @@ hxsl.CacheFileBuilder
-lib hlopenal
-D dx12
-xml heaps_hldx12.xml
-D hl-ver=1.15.0
-D hl-ver=1.14.0
Binary file added bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install]
registry = { url = "https://hacksawgaming-281033247142.d.codeartifact.eu-west-1.amazonaws.com/npm/hacksaw-client-artifacts/:_authToken=$CODEARTIFACT_AUTH_TOKEN" }
10 changes: 9 additions & 1 deletion h2d/Font.hx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ class Font {
Defaults to `hxd.Charset.getDefault()`.
**/
public var charset : hxd.Charset;
/**
Distance range used to generate SDF Font and usefull for some implementations of SDF Font rendering.
**/
public var distanceRange:Int;
/**
SDF Field type used when generating.
**/
public var fieldType:String;
var glyphs : Map<Int,FontChar>;
var nullChar : FontChar;
var defaultChar : FontChar;
Expand Down Expand Up @@ -279,7 +287,7 @@ class Font {
@param size The new font size.
**/
public function resizeTo( size : Int ) {
var ratio = size / this.size;
var ratio = size / initSize;
for( c in glyphs ) {
c.width *= ratio;
c.t.scaleToSize(c.t.width * ratio, c.t.height * ratio);
Expand Down
10 changes: 8 additions & 2 deletions h2d/Graphics.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ private class GraphicsContent extends h3d.prim.Primitive {
var buffers : Array<{ buf : hxd.FloatBuffer, vbuf : h3d.Buffer, idx : hxd.IndexBuffer, ibuf : h3d.Indexes, state : BatchDrawState }>;
var bufferDirty : Bool;
var indexDirty : Bool;
#if track_alloc
var allocPos : hxd.impl.AllocPos;
#end

public function new() {
buffers = [];
state = new BatchDrawState();
this.allocPos = hxd.impl.AllocPos.make();
#if track_alloc
this.allocPos = new hxd.impl.AllocPos();
#end
}

public inline function addIndex(i) {
Expand Down Expand Up @@ -84,7 +88,9 @@ private class GraphicsContent extends h3d.prim.Primitive {
if (index.length <= 0) return ;
var alloc = Allocator.get();
buffer = alloc.ofFloats(tmp, hxd.BufferFormat.H2D);
#if track_alloc
@:privateAccess buffer.allocPos = allocPos;
#end
indexes = alloc.ofIndexes(index);
for( b in buffers ) {
if( b.vbuf == null || b.vbuf.isDisposed() ) b.vbuf = alloc.ofFloats(b.buf, hxd.BufferFormat.H2D);
Expand Down Expand Up @@ -460,7 +466,7 @@ class Graphics extends Drawable {
Position a virtual tile at the given position and scale. Every draw will display a part of this tile relative
to these coordinates.

Note that in by default, Tile is not wrapped, and in order to render a tiling texture, `Drawable.tileWrap` has to be set.
Note that in by default, Tile is not wrapped, and in order to render tiling texture, `Drawable.tileWrap` have to be set.
Additionally, both `Tile.dx` and `Tile.dy` are ignored (use `dx`/`dy` arguments instead)
as well as tile defined size of the tile through `Tile.width` and `Tile.height` (use `scaleX`/`scaleY` relative to texture size).

Expand Down
24 changes: 10 additions & 14 deletions h2d/HtmlText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class HtmlText extends Text {
var str = splitNode.node.nodeValue;
var info = metrics[metrics.length - 1];
var w = info.width;
var cc = StringTools.fastCodeAt(str, splitNode.pos);
var cc = str.charCodeAt(splitNode.pos);
// Restore line metrics to ones before split.
// Potential bug: `Text<split> [Image] text<split>text` - third line will use metrics as if image is present in the line.
info.width = splitNode.width;
Expand Down Expand Up @@ -421,12 +421,12 @@ class HtmlText extends Text {
var x = leftMargin;
var breakChars = 0;
for ( i in 0...text.length ) {
var cc = StringTools.fastCodeAt(text, i);
var cc = text.charCodeAt(i);
var g = font.getChar(cc);
var newline = cc == '\n'.code;
var esize = g.width + g.getKerningOffset(prevChar);
var isComplement = (i < text.length - 1 && font.charset.isComplementChar(StringTools.fastCodeAt(text, i + 1)));
if ( font.charset.isBreakChar(cc) && !isComplement) {
var nc = text.charCodeAt(i+1);
if ( font.charset.isBreakChar(cc) && (nc == null || !font.charset.isComplementChar(nc) )) {
// Case: Very first word in text makes the line too long hence we want to start it off on a new line.
if (x > maxWidth && textSplit.length == 0 && splitNode.node != null) {
metrics.push(makeLineInfo(x, info.height, info.baseLine));
Expand All @@ -437,17 +437,13 @@ class HtmlText extends Text {
var k = i + 1, max = text.length;
var prevChar = cc;
while ( size <= maxWidth && k < max ) {
var cc = StringTools.fastCodeAt(text, k++);
var cc = text.charCodeAt(k++);
if ( lineBreak && (font.charset.isSpace(cc) || cc == '\n'.code ) ) break;
var e = font.getChar(cc);
size += e.width + letterSpacing + e.getKerningOffset(prevChar);
prevChar = cc;
if ( font.charset.isBreakChar(cc) ) {
if ( k >= text.length )
break;
var nc = StringTools.fastCodeAt(text, k);
if ( !font.charset.isComplementChar(nc) ) break;
}
var nc = text.charCodeAt(k);
if ( font.charset.isBreakChar(cc) && (nc == null || !font.charset.isComplementChar(nc)) ) break;
}
// Avoid empty line when last char causes line-break while being CJK
if ( lineBreak && size > maxWidth && i != max - 1 ) {
Expand Down Expand Up @@ -561,7 +557,7 @@ class HtmlText extends Text {
var startI = 0;
var index = Lambda.indexOf(e.parent, e);
for (i in 0...text.length) {
if (StringTools.fastCodeAt(text, i) == '\n'.code) {
if (text.charCodeAt(i) == '\n'.code) {
var pre = text.substring(startI, i);
if (pre != "") e.parent.insertChild(Xml.createPCData(pre), index++);
e.parent.insertChild(Xml.createElement("br"),index++);
Expand Down Expand Up @@ -675,7 +671,7 @@ class HtmlText extends Text {
switch( a.toLowerCase() ) {
case "color":
if( prevColor == null ) prevColor = @:privateAccess glyphs.curColor.clone();
if( v.length == 4 && StringTools.fastCodeAt(v, 0) == '#'.code )
if( v.charCodeAt(0) == '#'.code && v.length == 4 )
v = "#" + v.charAt(1) + v.charAt(1) + v.charAt(2) + v.charAt(2) + v.charAt(3) + v.charAt(3);
glyphs.setDefaultColor(Std.parseInt("0x" + v.substr(1)));
case "opacity":
Expand Down Expand Up @@ -785,7 +781,7 @@ class HtmlText extends Text {
var t = e.nodeValue;
var dy = metrics[sizePos].baseLine - font.baseLine;
for( i in 0...t.length ) {
var cc = StringTools.fastCodeAt(t, i);
var cc = t.charCodeAt(i);
if( cc == "\n".code ) {
makeLineBreak();
dy = metrics[sizePos].baseLine - font.baseLine;
Expand Down
38 changes: 8 additions & 30 deletions h2d/LoadingScene.hx
Original file line number Diff line number Diff line change
@@ -1,44 +1,22 @@
package h2d;

class LoadingScene extends h2d.Scene {
var renderTarget : h3d.mat.Texture;

var presentCooldown : Float;
public function new(presentCooldown : Float) {
super();
this.presentCooldown = presentCooldown;
renderTarget = new h3d.mat.Texture(width, height, [Target]);
}

var lastPresentTime : Float = 0.0;
public override function render( engine : h3d.Engine ) {
var time = haxe.Timer.stamp();
if ( time - lastPresentTime < presentCooldown)
override function render( engine : h3d.Engine ) {
hxd.Timer.update();
var dt = hxd.Timer.dt;
ctx.elapsedTime += dt;
if ( ctx.elapsedTime < presentCooldown )
return;
lastPresentTime = time;

#if usesys
haxe.System.emitEvents(@:privateAccess hxd.Window.inst.event);
#elseif hldx
dx.Loop.processEvents(@:privateAccess hxd.Window.inst.onEvent);
#elseif hlsdl
sdl.Sdl.processEvents(@:privateAccess hxd.Window.inst.onEvent);
#end

if ( renderTarget.width != engine.width || renderTarget.height != engine.height) {
renderTarget.dispose();
renderTarget = new h3d.mat.Texture(engine.width, engine.height, [Target]);
}

engine.pushTarget(renderTarget);
ctx.elapsedTime = 0.0;
hxd.System.timeoutTick();
super.render(engine);
engine.popTarget();
h3d.pass.Copy.run(renderTarget, null);
engine.driver.present();
}

override function onRemove() {
super.onRemove();
if ( renderTarget != null )
renderTarget.dispose();
}
}
15 changes: 2 additions & 13 deletions h2d/ObjectFollower.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class ObjectFollower extends Object {
**/
public var cameraRelative : Bool = false;

/**
If enabled, the ObjectFollower will remove itself if the object followed is null or removed.
**/
public var autoRemove : Bool = false;

var zValue : Float = 0.;
var outputScale : Float = 1.;
var tmpPos = new h3d.Vector();
Expand All @@ -76,17 +71,11 @@ class ObjectFollower extends Object {
}

function followObject() {
if( follow == null ) {
if ( autoRemove )
remove();
if( follow == null )
return;
}
var scene = @:privateAccess follow.getScene();
if( scene == null ) {
if ( autoRemove )
remove();
if( scene == null )
return;
}
var s2d = getScene();
var width = s2d == null ? h3d.Engine.getCurrent().width : s2d.width;
var height = s2d == null ? h3d.Engine.getCurrent().height : s2d.height;
Expand Down
30 changes: 4 additions & 26 deletions h2d/RenderContext.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package h2d;

private typedef ViewportStackEntry = {
private typedef CameraStackEntry = {
va : Float, vb : Float, vc : Float, vd : Float, vx : Float, vy : Float
};
private typedef CameraStackEntry = ViewportStackEntry & {
camera: h2d.Camera
};
private typedef TargetStackEntry = ViewportStackEntry & {
private typedef TargetStackEntry = CameraStackEntry & {
t : h3d.mat.Texture, hasRZ : Bool, rzX:Float, rzY:Float, rzW:Float, rzH:Float
};

Expand Down Expand Up @@ -81,12 +78,6 @@ class RenderContext extends h3d.impl.RenderContext {
**/
@:dox(hide)
public var tmpBounds = new h2d.col.Bounds();

/**
The camera instance that is currently being rendered, if present, `null` otherwise.
**/
public var currentCamera(default, null): Null<h2d.Camera> = null;

var texture : h3d.mat.Texture;
var baseShader : h3d.shader.Base2d;
var output : h3d.pass.OutputShader;
Expand All @@ -95,7 +86,6 @@ class RenderContext extends h3d.impl.RenderContext {
var pass : h3d.mat.Pass;
var currentShaders : hxsl.ShaderList;
var baseShaderList : hxsl.ShaderList;
var needInitShaders : Bool;
var currentObj : Drawable;
var stride : Int;
var targetsStack : Array<TargetStackEntry>;
Expand Down Expand Up @@ -218,7 +208,6 @@ class RenderContext extends h3d.impl.RenderContext {
}

function initShaders( shaders ) {
needInitShaders = false;
currentShaders = shaders;
compiledShader = output.compileShaders(globals, shaders);
var buffers = shaderBuffers;
Expand Down Expand Up @@ -253,7 +242,7 @@ class RenderContext extends h3d.impl.RenderContext {
public function pushCamera( cam : h2d.Camera ) {
var entry = cameraStack[cameraStackIndex++];
if ( entry == null ) {
entry = { va: 0, vb: 0, vc: 0, vd: 0, vx: 0, vy: 0, camera: null };
entry = { va: 0, vb: 0, vc: 0, vd: 0, vx: 0, vy: 0 };
cameraStack.push(entry);
}
var tmpA = viewA;
Expand All @@ -268,9 +257,6 @@ class RenderContext extends h3d.impl.RenderContext {
entry.vx = viewX;
entry.vy = viewY;

entry.camera = currentCamera;
currentCamera = cam;

viewA = cam.matA * tmpA + cam.matB * tmpC;
viewB = cam.matA * tmpB + cam.matB * tmpD;
viewC = cam.matC * tmpA + cam.matD * tmpC;
Expand All @@ -296,10 +282,6 @@ class RenderContext extends h3d.impl.RenderContext {
viewD = inf.vd;
viewX = inf.vx;
viewY = inf.vy;

currentCamera = inf.camera;
inf.camera = null;

var flipY = curTarget != null ? -targetFlipY : -baseFlipY;
baseShader.viewportA.set(viewA, viewC, viewX);
baseShader.viewportB.set(viewB * flipY, viewD * flipY, viewY * flipY);
Expand Down Expand Up @@ -779,7 +761,7 @@ class RenderContext extends h3d.impl.RenderContext {
var stride = 8;
if( hasBuffering() && currentObj != null && (texture != this.texture || stride != this.stride || obj.blendMode != currentObj.blendMode || obj.filter != currentObj.filter) )
flush();
var shaderChanged = needInitShaders, paramsChanged = false;
var shaderChanged = false, paramsChanged = false;
var objShaders = obj.shaders;
var curShaders = currentShaders.next;
while( objShaders != null && curShaders != null ) {
Expand Down Expand Up @@ -818,8 +800,4 @@ class RenderContext extends h3d.impl.RenderContext {
return true;
}

override function setCurrent() {
super.setCurrent();
needInitShaders = true;
}
}
Loading