HeapsIO / heaps

Heaps : Haxe Game Framework
http://heaps.io
MIT License
3.19k stars 338 forks source link

Possible Fixes For Lime #243

Closed garrett-hopper closed 7 years ago

garrett-hopper commented 7 years ago

I figuring out that I needed to use the git version of hlsdl instead of the haxelib version for the HashLink samples to build. (While running haxe all.hxml) After I got the hl, swf, and js samples building, I tried to build using lime.

From what I can tell the main issue is that lime doesn't implement all of the GL variables that are expected. (Similar to the errors I was seeing with haxelib's hlsdl 1.1.0) Perhaps lime hasn't been updated to some new spec in the same way that hlsdl's git version was updated?

I worked through the GL errors with lime, and I believe I've found a workaround for these errors. Though I'm definitely nieve in this regard.

https://github.com/Jumblemuddle/heaps/commit/f8d3913ccd4a44d7b56a5aee0707835ee968c317

This seemed to allow lime to build android and linux mostly, but it still failed on html5.

It should be noted that arbitrarily choosing the samples/pad example for testing. I will try others in the future. I'm assuming there isn't something specifically wrong with this sample?

HTML5

HTML5 failed with:

root@hyperion:/tmp/haxe/samples/build/pad# lime build html5
/root/heaps/h3d/impl/GlDriver.hx:127: characters 27-46 : Class<hxd.Stage> has no field getCanvas
/root/heaps/hxd/fs/EmbedFileSystem.hx:136: characters 29-34 : js.html.Image should be hxd.fs.LoadedBitmapData
/root/heaps/hxd/fs/EmbedFileSystem.hx:136: characters 29-34 : js.html.Image should be lime.graphics.Image
/root/heaps/hxd/fs/EmbedFileSystem.hx:136: characters 29-34 : For function argument 'data'
/root/heaps/hxd/impl/LimeStage.hx:297: characters 3-27 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:298: characters 3-33 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:299: characters 3-25 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:301: characters 3-29 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:302: characters 3-27 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:303: characters 3-27 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:304: characters 3-23 : Warning : This case is unused
/root/heaps/hxd/impl/LimeStage.hx:320: characters 3-35 : Warning : This case is unused

The getCanvas seemed to be an issue because even with @:privateAccess to hxd.Stage#getCanvas (I suppose this might need to be @:access? I can't seem to find any documentation on @:privateAccess, even though I see it multiple times in that file.), hxd.Stage#getCanvas only has an @:allow for hxd.

Android

The android build mostly built, but then it threw:

FAILURE: Build failed with an exception.

* What went wrong:
java.lang.ExceptionInInitializerError (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

It seems the --stacktrace flag is for the actual command to build for android, not for lime.

Linux

The linux build seemed to succeed, but it seems I'm missing a libstdc++.so.6 library.

garrett-hopper commented 7 years ago

@ncannasse hopefully this is somewhat helpful. I'm going to need some time digging into the internals to figure out the actual issue here. Thanks for any help you can provide and your excellent work in creating heaps.

garrett-hopper commented 7 years ago

@ncannasse I'm curious; were Evoland and Northgard built for release using lime or hashlink?

dkolyesnik commented 7 years ago

@Jumblemuddle Northgard is built using hashlink, thats for sure. As for the Evoland I guess it was Air

ncannasse commented 7 years ago

As for the Lime support, you're right Lime is missing some additional GL constants that we have added recently. There are two possibilities : one is to use #if(js || lime) so we are sure to keep GL ES compatibility, another is to submit a patch to Lime so they add support for the new constants.

Regarding HTML5/Lime, this is not necessary since you can directly compile Heaps to JS without OpenFL

micage commented 7 years ago

After commenting out the FloatTexture constants which aren't supported by lime I was able to compile with openfl test mac, in folder samples/build/base3D. Nearly. I got the following error message:

Link: ApplicationMain
Error : An error occurred compiling the shaders: ERROR: 0:1: '' :  version '100' is not supported
ERROR: 0:2: 'precision' : syntax error: syntax error
(#version 100)

In the shader code for e.g. BaseMesh.hx there is no version string. How can I fix this? Has it to do with my GPU which is rather old (Nvidia 8800GTX)?

micage commented 7 years ago

After brutally commenting out the version stuff in hxsl/GlslOut.hx I get:

Error : An error occurred compiling the shaders: ERROR: 0:15: GLSL 110 does not allow sub- or super-matrix constructors
(transformedNormal = normalize((normal * mat3(mat4(vertexParams[0], vertexParams[1], vertexParams[2], vertexParams[3]))));)

Guessing that for older versions it has to be like this: mat3(vertexParams[0].xyz, vertexParams[1].xyz, vertexParams[2].xyz)

I think it's in h3d.shader.BaseMesh.x:59 transformedNormal = (input.normal * global.modelView.mat3()).normalize();

is transpiled to: transformedNormal = normalize((normal * mat3(mat4(vertexParams[0], vertexParams[1], vertexParams[2], vertexParams[3]))));

micage commented 7 years ago

Got it running :)

In h3d.shader.BaseMesh.hx changed: transformedNormal = (input.normal * global.modelView.mat3()).normalize();

to: transformedNormal = (input.normal * global.modelView.mat3x4()).normalize();

Ok, I know, not the right way, but after some fruitless efforts I urgently want it to run. At least I know now that there is a way.


Off-topic not really issue-related: I'm really impressed by this library. It's a huge effort. After doing 3D-Engine stuff for the last 15 years myself and finally transitioned to unity3d (with a heavy heart) and also BabylonJS (because my engine worked solely on windows, lack of cross platform capabilities). I'm looking for alternatives that could work on all platforms and your work is very promising in that regard. In fact it's more being overwhelmed - in a positive sense.

I'm writing a Pool Billard Engine with almost 100% correct physics (analytical solution, no delta time simulation) and it should run hardware-accelerated on OS X, Windows, Web, iOS and Android. I made native Applications (OpenGL/ES based) also emscripten for Web as my code base is C++, but maintenance for all platforms is hard. In process of time that leads to the situation where I only support my currently favorized platform (OS X), which is bad. I also liked DirectX (learned how to write component based C++ from DirectX ) but sadly it's only on Windows.

I will definitely dive deeper into Haxe and Heaps.

micage commented 7 years ago

samples/build/base3D: openfl test android -> build succeded.

but the app froze my phone :(

samples from openfl are all working on my android device (not emulator)

ncannasse commented 7 years ago

Lime is not officially supported, please submit a PR if you wish to see it fixed.