• R
    romamik

    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 Kode read more
  • R
    romamik

    g2.imageScaleQuality = ImageScaleQuality.Low;

    ???

    posted in Kode read more
  • R
    romamik

    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 Kode read more
  • R
    romamik

    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 Kode read more
  • R
    romamik

    Thank you for your answer! Will try this tool.

    posted in Kode read more
  • R
    romamik

    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 Kode read more
  • R
    romamik

    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');
    	trace(cls)
    	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 Kode read more
  • R
    romamik

    Here is the code:

    package;
    
    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 Kode read more
  • R
    romamik

    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 Kode read more
  • R
    romamik

    I want to add some files to Android build, and another files for html5 build. Is this possible?

    posted in Kode read more
  • R
    romamik

    I've created something. It's not finished, but you can look at it here:
    https://github.com/romamik/Kha/tree/_image_fromFileBytes
    https://github.com/romamik/Kore/tree/_kha_imageFromFileBytes

    I've added function

    Image.fromFileBytes(bytes: Bytes, fileExtention: String, doneCallback: Image -> Void, errorCallback: String->Void, readable:Bool = false)
    

    It currently works good for flash and html5.

    It also works for Kore, but there is no error checking at all for now. So if there is bad data application crashes. I will handle this, at least for cases where stbi_load_from_memory is used.

    Also the way I've done this in Kore feels a bit hacky: to create Texture from memory buffer one needs to call Image::setNullFilenameData and then create Texture suppling null instead of filename. That is because from one side Texture's constructor receives filename from the other side it has different implementations for different backends, and I currently do not want to write code that is not common for all backends. It can be refactored so that Texture's constructor receive Reader, not filename, but this involves changes and thus testing for every backend, which I can't handle.

    posted in Kode read more
  • R
    romamik

    Initially I was talking about conventional image formats like png or jpeg, but I'm also interested in loading compressed textures in gpu formats too. Look at Kore::Image constructor: it makes no difference between these, they are just different image formats it can handle.

    posted in Kode read more
  • R
    romamik

    Not sure if this is possible.

    1. What should be initial value of the locked buffer (before we write our data there)?
    2. What would be the size of the buffer?
    3. We do not know dimensions and texture format of the image before parsing. But parsing is supposed to be done in unlock() which is later then 'new Image(width, height, format)'

    Why not just add static function like

    	public static function fromFileBytes(bytes: Bytes, usage: Usage = Usage.StaticUsage, fileExtension=''): Image;
    

    posted in Kode read more
  • R
    romamik

    I then should uncompress the data...

    posted in Kode read more
  • R
    romamik

    What is the best strategy if I need download image from web and show it in kha?
    First of all downloading binary data in haxe is tricky, but I can do this.
    So lets say I have raw bytes in some format (jpeg, png...), that I want to show.
    Currently there is no way to do this as I can see. Am I right?

    Currenly I'm interested in flash, html5, windows, android-native (and possibly ios in future).
    I think I can implement this.

    1. Flash - just use Loader.loadBytes and then kha.Image.fromBitmap
    2. Html5 - create data url from blob, create image element with this data url, then use kha.Image.fromImage
    3. Kore - as I can see Kore::Image::Image(filename) constructor code is not very hard to rewrite to accept pointer to raw data instead of file. So it is possible to create constructor Image::Image(u8 *data, int length, char *fileExt) and call it from Image::Image(filename).

    This will also allow to load comressed textures on Kore targets...

    posted in Kode read more
  • R
    romamik

    If you are on windows you can try running khamake with option "--graphics opengl" and see if it works.

    posted in Kode read more
  • R
    romamik

    I definitely will try to do this, but currently I have no good ideas of what to try.

    posted in Kode read more
  • R
    romamik

    It's a pity, but I can't share the code from our project. And I still cannot reproduce issue in test project...

    But I fixed this in our project. I found that we was locking index and vertex buffer, but sometimes decided to not draw them, and in this case buffers were left unlocked (and later locked again and then used). After making them unlock everything began to render correctly. But in test project leaving some buffers unlocked does not harm at all...

    PS discovered that g4.scissor() does not work on windows direct3d9: https://github.com/KTXSoftware/Kore/pull/92

    posted in Kode read more
  • R
    romamik

    I've found that our project is not rendering properly on windows direct3d9 target (Direct3d11 build fails with runtime error for unknown reason, and I did not try Direct3d12 due to SDK not installed). It works ok on other targets, including windows opengl.
    It also begin to works good if I disable nine-slice images, and these are currenly the only images that have "non-standard" indices in my index buffers. This and the way the picture is damaged makes me think that the problem is with index buffers.
    I tried many different things including recording actual vertex and index buffers and dispalying them in test project, but bug did not reproduce.
    In the beginning of september it was working. And there were no changes in our render code since that.
    I understand that that is not enough information, but may be somebody knows what can I try to do to solve this issue?

    This is how it looks (and the image is not stable, it differes frame to frame):
    glitch
    glitch2

    posted in Kode read more