FXGen import problem

Hello

I’m trying to import zlib.h to iOS platform but FXGen fail. It can generate .fx file for OS X. I’m stuck with work :frowning: Check screenshot plz. Settings are same for iOS and OS X. Maybe I’m doing it wrong? Try same and let me know if it’s working for You.

log:

461794320461.zip (3.2 KB)

[EDIT]

FIGURED it out :slight_smile: For other ppls who will have same problem. In Headers path need add zconf.h header file too. So path should be: zlib.h;zconf.h

b.r.

1 Like

We probably should add lib to the list of libraries we pre-ship an .fx file for, too. Will look into that.

It will be great, because libz (zlib, gzip) is A MUST today :slight_smile: Also consider to add it to Sugar :slight_smile: I just have tested and it works perfect, but it need one tweak to make it working, simple one, but I lost 2 hours digging internet :). MAX_WBITS cannot be minus as You can find on net. No idea why, but here is not working and was reported by somone on one page, which give me help :slight_smile:

public static bool zlibDecompress(NSData _data, ref NSMutableData output)
{
	if ((_data == null) || (_data.length == 0)) return false;
	zlib.z_stream stream = new zlib.z_stream();
	stream.zalloc = zlib.Z_NULL;
	stream.zfree = zlib.Z_NULL;
	stream.avail_in = _data.length;
	stream.next_in = (zlib.Bytef*)_data.bytes;
	stream.total_out = 0;
	stream.avail_out = 0;
	output = null;
	if (zlib.inflateInit2_(&stream, zlib.MAX_WBITS, zlib.zlibVersion, sizeOf(stream)) == zlib.Z_OK)
	{
		int status = zlib.Z_OK;
		output = NSMutableData.dataWithCapacity(_data.length * 2);
		while (status == zlib.Z_OK)
		{
			if (stream.total_out >= output.length)
			{
				output.length += _data.length / 2;
			}
			stream.next_out = (uint8_t*)(output.mutableBytes + stream.total_out);
			stream.avail_out = (UInt)(output.length - stream.total_out);
			status = zlib.inflate(&stream, zlib.Z_SYNC_FLUSH);
		}
		if (zlib.inflateEnd(&stream) == zlib.Z_OK)
		{
			if (status == zlib.Z_STREAM_END)
			{
				output.length = stream.total_out;
				return true;
			}
		}		
	}
	return false;		
}

Btw. about code import. Let say I found Objective-C code like nice charts. It’s a lot of code. Is any other way that translate all code to C# or Oxygene to use it? Make library in xcode with exposed methods maybe and after import? You think it can be automated?

[EDIT]

There is big problem which I faced with NSMutableData. While all data are correct when are initialized inside method, then after returning it contain broken buffer (garbage). I’m not sure if it’s bug or not, but returning data as NSData is the only way which works: return NSData.dataWithData(output);
Will create new thread which point to this post. I’m sure is bug because I’m not found anything in google about similar problem.

b.r.

Next version has libz.fx included by default.

1 Like