Recent Posts

Color is 4 bytes, but we are using 4 floats in vertex data for color, which is 16 bytes.
In opengl we can specify GL_BYTE in glVertexAttribPointer and vec4 in shader and it will interpret our 4 bytes as 4 floats.
Is something like this possible in kha?

For just one color it's ok, but I want to pass color matrix to shader and using 12 (or even 20 if it should affect alpha) floats per vertex for that feels too expensive.

posted in Kha read more

g2.imageScaleQuality = ImageScaleQuality.Low;


posted in Kha read more

I personally do not see why should we emulate Mac behavior on other systems.
What we should do is allow Mac users to use app and for that purpose we can allow Mac users use Cmd button instead of Ctrl. I mean Cmd-click should give exactly the same result as Ctrl-click. Not sure if it should be done by Kha or by App.

posted in Kha read more

In html5 target ctrl-click is used to emulate right-mouse click. This prevents from using this combination for something else. For example multiselection is often done with ctrl-clicking.
Should this behavior be optional or even removed???

posted in Kha read more

Thank you for your answer! Will try this tool.

posted in Kha read more

Some time ago relative paths to Kha submodules were changed to absolute paths. I'm keeping copy of Kha and all sumbodules in repository on our server. And with this change it's not very easy task, because submodules now automatically point to github. Can I ask what was the purpose of this change?

posted in Kha read more

One more: this code crashes in release build with /O2 optimization

static public var instance:ClassDescription = Type.createInstance(Type.resolveClass('typedEval.ClassDescriptionImpl'), []);

but this works fine

static public var instance:ClassDescription = {
    var cls = Type.resolveClass('typedEval.ClassDescriptionImpl');
    Type.createInstance(cls, []);

In C++ code that crashes looks like this

HXLINE(  19)        instance = ( ( ::typedEval::ClassDescription)   (::Type_obj::createInstance(::Type_obj::resolveClass(HX_("typedEval.ClassDescriptionImpl",0c,ad,5a,64)),::cpp::VirtualArray_obj::__new(0))) );

But if I modify it to

                auto temp = ::Type_obj::resolveClass(HX_("typedEval.ClassDescriptionImpl", 0c, ad, 5a, 64));
HXLINE(  19)        instance = ( ( ::typedEval::ClassDescription)(::Type_obj::createInstance(temp,::cpp::VirtualArray_obj::__new(0))) );

It begins to work.

I wonder why there were no such problems before. May be haxe 3.3 was generating different c++ code or may be there were different compilation options in kha? And what to do with this?

posted in Kha read more

Here is the code:


class Main {
    public static function main() {

        System.init({}, function(){}); //c++ does not without this line in clean new build...

        var s = 'test';
        trace(s.substr(0, 1) + s.substr(1) + '_');

It works on most platforms and configurations but crashes in windows when using Visual C++ 2015 with /O2 (default for Kha project) or /Ox optimizations.
It crashes somewhere inside memcpy, which is called from String + operator. Not sure which of the two because adding logging between them fixes the problem :-)

This is generated c++

HXLINE(   6)         ::Dynamic _hx_tmp = ::haxe::Log_obj::trace;
HXDLIN(   6)        ::String _hx_tmp1 = HX_("test",52,c8,f9,4c).substr((int)0,(int)1);
HXDLIN(   6)        ::String _hx_tmp2 = ((_hx_tmp1 + HX_("test",52,c8,f9,4c).substr((int)1,null())) + HX_("_",5f,00,00,00)); // crashes here
HXDLIN(   6)        _hx_tmp(_hx_tmp2,hx::SourceInfo(HX_("Main.hx",05,5c,7e,08),6,HX_("Main",59,64,2f,33),HX_("main",39,38,56,48)));

I've tried to run similar code with plain hxcpp without Kha and it worked as expected, but I'm not aware of how to change c++ optimization options with hxcpp. I'm not even sure if I built debug or release...

PS Added some logging to String class:

//added this to String::operator+
Kore::log(Kore::LogLevel::Info, "%i %i %i", inRHS.length, inRHS.__s, *((int*)(&inRHS.__s)+1));

//added this to String::substr() (result is temp variable that stores the result of substr before returning it)
Kore::log(Kore::LogLevel::Info, "%i %i", result.length, result.__s );

and the output was:

 3 50990268 - result of substr
 20315128 3 50990268 - received by operator+ (pointer moved 4 bytes backwards)

This looks like Visual C++ compiler bug.

posted in Kha read more

posted in Kha read more

As I can see it is not possible to delete file created with kha.Storage.namedFile(). I need this functionality and I think I can add it to some targets (flash, html5, Kore).

If the file does not exist kha.Storage.namedFile(filename).read() will return null.
But writing null kha.Storage.namedFile(filename).write(null) will just make no changes, so if the file existed it will remain the same with it's contents.
So for consistency it will be good to delete the file with kha.Storage.namedFile(filename).write(null).

Or I can just add function like kha.Storage.removeNamedFile(filename).

posted in Kha read more