Which project are you testing? I would recommend Limeās āHelloWorldā sample as the first step, and see if you can get that to run
Yes, Iām using limeās HelloWorld sample
How can I force the screen size to 320x240?
For now, Iād just set <window width="320" height="240" />
for now, in the project. You might also need to add messages to try and see if it gets past the Haxe boot into the ApplicationMain, and if there, if it gets into the constructor of your class, and so on, to make sure it isnāt tripping up over Haxe standard library stuff, like tracing
./HelloWorld
Main.hx:15: Hello World
Segmentation fault
Even removing the render method I get the same result. I think my lime.ndll is brokenā¦
package;
import lime.app.Application;
class Main extends Application {
public function new () {
super ();
trace ("Hello World");
}
}
Great! Well this is a lot farther than most ports get at first. So it gets to the point of creating the application, umm, perhaps you could add trace messages into the Application class (or in the lime._backend.native.NativeApplication
class) to get an idea of what things are firing, perhaps even in the C++ of the native backend, to get an idea of what is firing properly, and what is triggering a segmentation fault
Some - but not all - segmentation faults can be debugged by defining HXCPP_STACK_LINE
and HXCPP_CHECK_POINTER
, as described here.
Problem found: SDL canāt init in SDLApplication.cpp
if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
returns
Main.hx:15: Hello World
Unable to init SDL: SDL not built with timer support
Which does not make any sense, since the timer normally works in other applications. If I remove SDL_INIT_TIMER
:
Main.hx:15: Hello World
Unable to init SDL: No available video device
Still no sense to me
Thank you for your tips, guys.
A green screen, finally
if you manage to do the port I buy one
@RafaelOliveira I hope so
One more mistery: building HelloWorld project in debug mode everything runs fine, but if I rebuild it in release mode I get āIllegal instruction
āā¦
What was the fix for SDL init? Was it a linker flag or something?
Can you tell when the āIllegal instructionā occurs? Is this before it even executes the C++ application code?
I forgot to not use the native SDL toolkit, so the following line on Build.xml fixed it:
<files id="native-toolkit-sdl" if="LIME_SDL" unless="emscripten || gcw0" />
It occurs exactly after execution, before the āHello Worldā trace. Iāll try to put some printfs on the C++ code. If I use gdb I canāt get anything as I donāt have debug info, but if I build with debug info thereās no errors o.O
Maybe you could use a try catch in the constructor
After some hacking in hxcpp I was able to use gdb:
(gdb) bt full
#0 lime::math::_ColorMatrix::ColorMatrix_Impl__obj::__boot ()
at ./src/lime/math/_ColorMatrix/ColorMatrix_Impl_.cpp:651
No locals.
#1 0x77279224 in __boot_all () at ./src/__boot__.cpp:331
No locals.
#2 0x77147070 in main (argc=<optimized out>, argv=<optimized out>)
at ./src/__main__.cpp:10
t0 = 99
Taking a look at the cpp generated code:
void ColorMatrix_Impl__obj::__boot()
{
__identity= Array_obj< Float >::__new().Add(1.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(1.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(1.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(1.0).Add(0.0);
}
I just donāt get what could be wrong there
What is the difference between debug and release in your build flags? Can you build with Haxe release code and C++ debug args, and get it to work?
Using C++ debug args (-g
, no strip, no optimizations flag, etc) still getting illegal instruction. It only works passing -debug
to lime.
Hmm, so perhaps something triggered by the HXCPP debug flags
Yeah, I think so. Iāll investigate this. Thanks again
I was doing some tests with several hxcpp parameters, but I could not come to any conclusion.
A strange discovery, however, was as follows: starting vector __identity
empty on the file lime/math/ColorMatrix.hx
the release version works normally.
abstract ColorMatrix(Float32Array) from Float32Array to Float32Array {
#if gcw0
private static var __identity = [ ];
#else
private static var __identity = [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ];
#end
I donāt know why o.O
Edit: Testing the SimpleImage demo, Iām getting illegal instruction here (generated cpp):
void Matrix4_Impl__obj::__boot()
{
__identity= Array_obj< Float >::__new().Add(1.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(1.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(1.0).Add(0.0).Add(0.0).Add(0.0).Add(0.0).Add(1.0);
}
Iāll take a look on lime/utils/Float32Array.hx
Could you later try with Luxe Engine? I have interest in this library too, and maybe it could help with your tests, it uses hxcpp too.